diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-06 09:08:48 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-06 09:08:48 +0300 |
commit | c77b780ee080b978bd5a63f642f741e8892383dc (patch) | |
tree | 7c50ab6450a61d27485f9557b666af46ec5adfdd /app/workers | |
parent | 5e448ff06309854c838fb5eaa46fd05ebc5218ab (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/workers')
-rw-r--r-- | app/workers/gitlab/github_import/stage/import_pull_requests_worker.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/app/workers/gitlab/github_import/stage/import_pull_requests_worker.rb b/app/workers/gitlab/github_import/stage/import_pull_requests_worker.rb index e7eee0915d5..b2dfded0280 100644 --- a/app/workers/gitlab/github_import/stage/import_pull_requests_worker.rb +++ b/app/workers/gitlab/github_import/stage/import_pull_requests_worker.rb @@ -16,6 +16,12 @@ module Gitlab # project - An instance of Project. def import(client, project) info(project.id, message: "starting importer", importer: 'Importer::PullRequestsImporter') + + # If a user creates a new merge request while the import is in progress, GitLab can assign an IID + # to this merge request that already exists for a GitHub Pull Request. + # The workaround is to allocate IIDs before starting the importer. + allocate_merge_requests_internal_id!(project, client) + waiter = Importer::PullRequestsImporter .new(project, client) .execute @@ -41,6 +47,17 @@ module Gitlab private + def allocate_merge_requests_internal_id!(project, client) + return if InternalId.exists?(project: project, usage: :merge_requests) # rubocop: disable CodeReuse/ActiveRecord + + options = { state: 'all', sort: 'number', direction: 'desc', per_page: '1' } + last_github_pull_request = client.each_object(:pulls, project.import_source, options).first + + return unless last_github_pull_request + + MergeRequest.track_target_project_iid!(project, last_github_pull_request[:number]) + end + def abort_on_failure true end |