diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-20 09:55:51 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-20 09:55:51 +0000 |
commit | e8d2c2579383897a1dd7f9debd359abe8ae8373d (patch) | |
tree | c42be41678c2586d49a75cabce89322082698334 /lib/gitlab/github_import/importer | |
parent | fc845b37ec3a90aaa719975f607740c22ba6a113 (diff) | |
download | gitlab-ce-e8d2c2579383897a1dd7f9debd359abe8ae8373d.tar.gz |
Add latest changes from gitlab-org/gitlab@14-1-stable-eev14.1.0-rc42
Diffstat (limited to 'lib/gitlab/github_import/importer')
9 files changed, 45 insertions, 5 deletions
diff --git a/lib/gitlab/github_import/importer/diff_notes_importer.rb b/lib/gitlab/github_import/importer/diff_notes_importer.rb index 966f12c5c2f..49cbc8f7a42 100644 --- a/lib/gitlab/github_import/importer/diff_notes_importer.rb +++ b/lib/gitlab/github_import/importer/diff_notes_importer.rb @@ -22,6 +22,10 @@ module Gitlab :pull_requests_comments end + def object_type + :diff_note + end + def id_for_already_imported_cache(note) note.id end diff --git a/lib/gitlab/github_import/importer/issues_importer.rb b/lib/gitlab/github_import/importer/issues_importer.rb index ac6d0666b3a..6cc1a61b332 100644 --- a/lib/gitlab/github_import/importer/issues_importer.rb +++ b/lib/gitlab/github_import/importer/issues_importer.rb @@ -18,6 +18,10 @@ module Gitlab ImportIssueWorker end + def object_type + :issue + end + def collection_method :issues end diff --git a/lib/gitlab/github_import/importer/lfs_objects_importer.rb b/lib/gitlab/github_import/importer/lfs_objects_importer.rb index c74a7706117..40248ecbd31 100644 --- a/lib/gitlab/github_import/importer/lfs_objects_importer.rb +++ b/lib/gitlab/github_import/importer/lfs_objects_importer.rb @@ -18,6 +18,10 @@ module Gitlab ImportLfsObjectWorker end + def object_type + :lfs_object + end + def collection_method :lfs_objects end @@ -26,6 +30,8 @@ module Gitlab lfs_objects = Projects::LfsPointers::LfsObjectDownloadListService.new(project).execute lfs_objects.each do |object| + Gitlab::GithubImport::ObjectCounter.increment(project, object_type, :fetched) + yield object end rescue StandardError => e diff --git a/lib/gitlab/github_import/importer/notes_importer.rb b/lib/gitlab/github_import/importer/notes_importer.rb index 5aec760ea5f..ca1d7d60515 100644 --- a/lib/gitlab/github_import/importer/notes_importer.rb +++ b/lib/gitlab/github_import/importer/notes_importer.rb @@ -18,6 +18,10 @@ module Gitlab ImportNoteWorker end + def object_type + :note + end + def collection_method :issues_comments end diff --git a/lib/gitlab/github_import/importer/pull_request_merged_by_importer.rb b/lib/gitlab/github_import/importer/pull_request_merged_by_importer.rb index 8173fdd5e3e..640914acf4d 100644 --- a/lib/gitlab/github_import/importer/pull_request_merged_by_importer.rb +++ b/lib/gitlab/github_import/importer/pull_request_merged_by_importer.rb @@ -43,7 +43,7 @@ module Gitlab def missing_author_note s_("GitHubImporter|*Merged by: %{author} at %{timestamp}*") % { - author: pull_request.merged_by.login, + author: pull_request.merged_by&.login || 'ghost', timestamp: pull_request.merged_at } end diff --git a/lib/gitlab/github_import/importer/pull_request_review_importer.rb b/lib/gitlab/github_import/importer/pull_request_review_importer.rb index f476ee13392..dd5b7c93ced 100644 --- a/lib/gitlab/github_import/importer/pull_request_review_importer.rb +++ b/lib/gitlab/github_import/importer/pull_request_review_importer.rb @@ -69,8 +69,8 @@ module Gitlab author_id: author_id, note: note, system: false, - created_at: review.submitted_at, - updated_at: review.submitted_at + created_at: submitted_at, + updated_at: submitted_at }.merge(extra) end @@ -80,8 +80,8 @@ module Gitlab approval_attribues = { merge_request_id: merge_request.id, user_id: user_id, - created_at: review.submitted_at, - updated_at: review.submitted_at + created_at: submitted_at, + updated_at: submitted_at } result = ::Approval.insert( @@ -105,6 +105,10 @@ module Gitlab Note.create!(attributes) end + + def submitted_at + @submitted_at ||= (review.submitted_at || merge_request.updated_at) + end end end end diff --git a/lib/gitlab/github_import/importer/pull_requests_importer.rb b/lib/gitlab/github_import/importer/pull_requests_importer.rb index 28cd3f802a2..b2f099761b1 100644 --- a/lib/gitlab/github_import/importer/pull_requests_importer.rb +++ b/lib/gitlab/github_import/importer/pull_requests_importer.rb @@ -22,6 +22,10 @@ module Gitlab pr.number end + def object_type + :pull_request + end + def each_object_to_import super do |pr| update_repository if update_repository?(pr) diff --git a/lib/gitlab/github_import/importer/pull_requests_merged_by_importer.rb b/lib/gitlab/github_import/importer/pull_requests_merged_by_importer.rb index 94472cd341e..287e0ea7f7f 100644 --- a/lib/gitlab/github_import/importer/pull_requests_merged_by_importer.rb +++ b/lib/gitlab/github_import/importer/pull_requests_merged_by_importer.rb @@ -22,6 +22,10 @@ module Gitlab :pull_requests_merged_by end + def object_type + :pull_request_merged_by + end + def id_for_already_imported_cache(merge_request) merge_request.id end @@ -30,6 +34,8 @@ module Gitlab project.merge_requests.with_state(:merged).find_each do |merge_request| next if already_imported?(merge_request) + Gitlab::GithubImport::ObjectCounter.increment(project, object_type, :fetched) + pull_request = client.pull_request(project.import_source, merge_request.iid) yield(pull_request) diff --git a/lib/gitlab/github_import/importer/pull_requests_reviews_importer.rb b/lib/gitlab/github_import/importer/pull_requests_reviews_importer.rb index 809a518d13a..e389acbf877 100644 --- a/lib/gitlab/github_import/importer/pull_requests_reviews_importer.rb +++ b/lib/gitlab/github_import/importer/pull_requests_reviews_importer.rb @@ -29,6 +29,10 @@ module Gitlab :pull_request_reviews end + def object_type + :pull_request_review + end + def id_for_already_imported_cache(review) review.id end @@ -57,6 +61,8 @@ module Gitlab project.merge_requests.find_each do |merge_request| next if already_imported?(merge_request) + Gitlab::GithubImport::ObjectCounter.increment(project, object_type, :fetched) + client .pull_request_reviews(project.import_source, merge_request.iid) .each do |review| @@ -81,6 +87,8 @@ module Gitlab page.objects.each do |review| next if already_imported?(review) + Gitlab::GithubImport::ObjectCounter.increment(project, object_type, :fetched) + review.merge_request_id = merge_request.id yield(review) |