You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by kl...@apache.org on 2023/06/09 07:25:57 UTC

[incubator-devlake] branch main updated: fix: fix gitlab lost mr commit (#5412)

This is an automated email from the ASF dual-hosted git repository.

klesh pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


The following commit(s) were added to refs/heads/main by this push:
     new bd7567447 fix: fix gitlab lost mr commit (#5412)
bd7567447 is described below

commit bd7567447973d947e6790a9ffbf701283a111877
Author: mappjzc <zh...@merico.dev>
AuthorDate: Fri Jun 9 15:25:52 2023 +0800

    fix: fix gitlab lost mr commit (#5412)
    
    Fix gitlab lost merge request commit.
    Fix gitlab lost merge request note.
    
    Nddtfjiang <zh...@merico.dev>
---
 backend/plugins/gitlab/tasks/mr_commit_collector.go | 3 ++-
 backend/plugins/gitlab/tasks/mr_note_collector.go   | 4 +++-
 backend/plugins/gitlab/tasks/shared.go              | 6 ++++--
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/backend/plugins/gitlab/tasks/mr_commit_collector.go b/backend/plugins/gitlab/tasks/mr_commit_collector.go
index f0e4350ba..91bfe0b2e 100644
--- a/backend/plugins/gitlab/tasks/mr_commit_collector.go
+++ b/backend/plugins/gitlab/tasks/mr_commit_collector.go
@@ -45,7 +45,8 @@ func CollectApiMergeRequestsCommits(taskCtx plugin.SubTaskContext) errors.Error
 		return err
 	}
 
-	iterator, err := GetMergeRequestsIterator(taskCtx, collectorWithState)
+	// Due to the inability of incremental updates to handle force push on commits, we are temporarily abandoning incremental updates and passing nil to process the full data.
+	iterator, err := GetMergeRequestsIterator(taskCtx, nil)
 	if err != nil {
 		return err
 	}
diff --git a/backend/plugins/gitlab/tasks/mr_note_collector.go b/backend/plugins/gitlab/tasks/mr_note_collector.go
index ece1d47d5..817232708 100644
--- a/backend/plugins/gitlab/tasks/mr_note_collector.go
+++ b/backend/plugins/gitlab/tasks/mr_note_collector.go
@@ -51,10 +51,12 @@ func CollectApiMergeRequestsNotes(taskCtx plugin.SubTaskContext) errors.Error {
 	}
 	defer iterator.Close()
 
+	incremental := collectorWithState.IsIncremental()
+
 	err = collectorWithState.InitCollector(helper.ApiCollectorArgs{
 		ApiClient:      data.ApiClient,
 		PageSize:       100,
-		Incremental:    false,
+		Incremental:    incremental,
 		Input:          iterator,
 		UrlTemplate:    "projects/{{ .Params.ProjectId }}/merge_requests/{{ .Input.Iid }}/notes?system=false",
 		Query:          GetQuery,
diff --git a/backend/plugins/gitlab/tasks/shared.go b/backend/plugins/gitlab/tasks/shared.go
index e8468d3a8..3cced19fd 100644
--- a/backend/plugins/gitlab/tasks/shared.go
+++ b/backend/plugins/gitlab/tasks/shared.go
@@ -161,8 +161,10 @@ func GetMergeRequestsIterator(taskCtx plugin.SubTaskContext, collectorWithState
 			data.Options.ProjectId, data.Options.ConnectionId,
 		),
 	}
-	if collectorWithState.LatestState.LatestSuccessStart != nil {
-		clauses = append(clauses, dal.Where("gitlab_updated_at > ?", *collectorWithState.LatestState.LatestSuccessStart))
+	if collectorWithState != nil {
+		if collectorWithState.LatestState.LatestSuccessStart != nil {
+			clauses = append(clauses, dal.Where("gitlab_updated_at > ?", *collectorWithState.LatestState.LatestSuccessStart))
+		}
 	}
 	// construct the input iterator
 	cursor, err := db.Cursor(clauses...)