You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by GitBox <gi...@apache.org> on 2022/11/24 10:13:30 UTC

[GitHub] [incubator-devlake] mindlesscloud commented on a diff in pull request #3801: feat: add new table ref_commits for the refdiff plugin

mindlesscloud commented on code in PR #3801:
URL: https://github.com/apache/incubator-devlake/pull/3801#discussion_r1031330502


##########
plugins/refdiff/tasks/commit_diff_calculator.go:
##########
@@ -41,18 +42,29 @@ func CalculateCommitsDiff(taskCtx core.SubTaskContext) errors.Error {
 
 	// get all data from finish_commits_diffs
 	commitPairs := data.Options.AllPairs
-	var ExistFinishedCommitDiff []code.FinishedCommitsDiffs
-	err := db.All(&ExistFinishedCommitDiff,
+	var existFinishedCommitDiff []code.FinishedCommitsDiff
+	err := db.All(&existFinishedCommitDiff,
 		dal.Select("*"),
 		dal.From("finished_commits_diffs"),
 	)
 	if err != nil {
 		return err
 	}
+
+	refCommit := &code.RefCommit{}
 	for i := 0; i < len(commitPairs); i++ {
 		pair := commitPairs[i]
-		for _, item := range ExistFinishedCommitDiff {
+		for _, item := range existFinishedCommitDiff {
 			if pair[0] == item.NewCommitSha && pair[1] == item.OldCommitSha {
+				newRefId := fmt.Sprintf("%s:%s", repoId, pair[2])
+				oldRefId := fmt.Sprintf("%s:%s", repoId, pair[3])
+				if pair[2] != newRefId || pair[3] != oldRefId {
+					refCommit.NewCommitSha = pair[0]
+					refCommit.OldCommitSha = pair[1]
+					refCommit.NewRefId = newRefId
+					refCommit.OldRefId = oldRefId
+				}
+
 				commitPairs = append(commitPairs[:i], commitPairs[i+1:]...)

Review Comment:
   Removing items from the `commitPairs` would affect the underlying `data.Options.AllPairs` which is shared among all subtasks.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org