diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-02-18 12:45:46 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-02-18 12:45:46 +0300 |
commit | a7b3560714b4d9cc4ab32dffcd1f74a284b93580 (patch) | |
tree | 7452bd5c3545c2fa67a28aa013835fb4fa071baf /lib/gitlab/github_import | |
parent | ee9173579ae56a3dbfe5afe9f9410c65bb327ca7 (diff) |
Add latest changes from gitlab-org/gitlab@14-8-stable-eev14.8.0-rc42
Diffstat (limited to 'lib/gitlab/github_import')
6 files changed, 18 insertions, 31 deletions
diff --git a/lib/gitlab/github_import/importer/diff_note_importer.rb b/lib/gitlab/github_import/importer/diff_note_importer.rb index 8a8d23401c1..02b582190b6 100644 --- a/lib/gitlab/github_import/importer/diff_note_importer.rb +++ b/lib/gitlab/github_import/importer/diff_note_importer.rb @@ -26,7 +26,7 @@ module Gitlab # because it cannot use the BulkImporting strategy, which skips # callbacks and validations. For this reason, notes that don't have # suggestions are still imported with LegacyDiffNote - if import_with_diff_note? + if note.contains_suggestion? import_with_diff_note else import_with_legacy_diff_note @@ -48,17 +48,6 @@ module Gitlab attr_reader :note, :project, :client, :author_id, :author_found - def import_with_diff_note? - note.contains_suggestion? && use_diff_note_with_suggestions_enabled? - end - - def use_diff_note_with_suggestions_enabled? - Feature.enabled?( - :github_importer_use_diff_note_with_suggestions, - default_enabled: :yaml - ) - end - def build_author_attributes @author_id, @author_found = user_finder.author_id_for(note) end diff --git a/lib/gitlab/github_import/importer/pull_requests_importer.rb b/lib/gitlab/github_import/importer/pull_requests_importer.rb index d7eaa5a470b..fc0c099b71c 100644 --- a/lib/gitlab/github_import/importer/pull_requests_importer.rb +++ b/lib/gitlab/github_import/importer/pull_requests_importer.rb @@ -38,7 +38,7 @@ module Gitlab # deliberate. If we were to update this column after the fetch we may # miss out on changes pushed during the fetch or between the fetch and # updating the timestamp. - project.update_column(:last_repository_updated_at, Time.zone.now) + project.touch(:last_repository_updated_at) # rubocop: disable Rails/SkipsModelValidations project.repository.fetch_remote(project.import_url, refmap: Gitlab::GithubImport.refmap, forced: true) diff --git a/lib/gitlab/github_import/importer/releases_importer.rb b/lib/gitlab/github_import/importer/releases_importer.rb index c1fbd868800..64ec0251e54 100644 --- a/lib/gitlab/github_import/importer/releases_importer.rb +++ b/lib/gitlab/github_import/importer/releases_importer.rb @@ -21,10 +21,12 @@ module Gitlab end def already_imported?(release) - existing_tags.include?(release.tag_name) + existing_tags.include?(release.tag_name) || release.tag_name.nil? end def build(release) + existing_tags.add(release.tag_name) + { name: release.name, tag: release.tag_name, diff --git a/lib/gitlab/github_import/importer/repository_importer.rb b/lib/gitlab/github_import/importer/repository_importer.rb index 20068a33019..aba4729e9c8 100644 --- a/lib/gitlab/github_import/importer/repository_importer.rb +++ b/lib/gitlab/github_import/importer/repository_importer.rb @@ -80,7 +80,7 @@ module Gitlab end def update_clone_time - project.update_column(:last_repository_updated_at, Time.zone.now) + project.touch(:last_repository_updated_at) # rubocop: disable Rails/SkipsModelValidations end private diff --git a/lib/gitlab/github_import/object_counter.rb b/lib/gitlab/github_import/object_counter.rb index 4c9a8da601f..7ce88280209 100644 --- a/lib/gitlab/github_import/object_counter.rb +++ b/lib/gitlab/github_import/object_counter.rb @@ -71,11 +71,7 @@ module Gitlab add_counter_to_list(project, operation, counter_key) - if Feature.disabled?(:import_redis_increment_by, default_enabled: :yaml) - CACHING.increment(counter_key) - else - CACHING.increment_by(counter_key, value) - end + CACHING.increment_by(counter_key, value) end def add_counter_to_list(project, operation, key) diff --git a/lib/gitlab/github_import/representation/diff_note.rb b/lib/gitlab/github_import/representation/diff_note.rb index 04f53accfeb..883abef9bdb 100644 --- a/lib/gitlab/github_import/representation/diff_note.rb +++ b/lib/gitlab/github_import/representation/diff_note.rb @@ -129,17 +129,7 @@ module Gitlab def discussion_id strong_memoize(:discussion_id) do - if in_reply_to_id.present? - current_discussion_id - else - Discussion.discussion_id( - Struct - .new(:noteable_id, :noteable_type) - .new(merge_request.id, NOTEABLE_TYPE) - ).tap do |discussion_id| - cache_discussion_id(discussion_id) - end - end + (in_reply_to_id.present? && current_discussion_id) || generate_discussion_id end end @@ -160,6 +150,16 @@ module Gitlab side == 'RIGHT' end + def generate_discussion_id + Discussion.discussion_id( + Struct + .new(:noteable_id, :noteable_type) + .new(merge_request.id, NOTEABLE_TYPE) + ).tap do |discussion_id| + cache_discussion_id(discussion_id) + end + end + def cache_discussion_id(discussion_id) Gitlab::Cache::Import::Caching.write(discussion_id_cache_key(note_id), discussion_id) end |