This is an automated email from the ASF dual-hosted git repository.
mappjzc pushed a commit to branch release-v0.17
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
The following commit(s) were added to refs/heads/release-v0.17 by this push:
new c7a8c8763 fix: fix gitlab lost mr commit (#5418)
c7a8c8763 is described below
commit c7a8c87635c1c4f509bb35567f6678c1dcc3b811
Author: mappjzc <[email protected]>
AuthorDate: Fri Jun 9 17:09:51 2023 +0800
fix: fix gitlab lost mr commit (#5418)
Fix gitlab lost merge request commit.
Fix gitlab lost merge request note.
Nddtfjiang <[email protected]>
---
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 a6f50cf45..61027c4de 100644
--- a/backend/plugins/gitlab/tasks/mr_commit_collector.go
+++ b/backend/plugins/gitlab/tasks/mr_commit_collector.go
@@ -40,7 +40,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 882dfc506..59289730d 100644
--- a/backend/plugins/gitlab/tasks/mr_note_collector.go
+++ b/backend/plugins/gitlab/tasks/mr_note_collector.go
@@ -46,10 +46,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...)