diff options
author | James Lopez <james@jameslopez.es> | 2017-01-18 17:40:24 +0100 |
---|---|---|
committer | James Lopez <james@jameslopez.es> | 2017-01-18 17:40:24 +0100 |
commit | 17c099161ee582e627a531bda1d84574d6a8c0f7 (patch) | |
tree | 0e11bae49c5666b1cef71d1900ed7a1b82a503b3 /lib | |
parent | b3bb8dc46faf448d02e917586e7666143d7ab968 (diff) | |
download | gitlab-ce-17c099161ee582e627a531bda1d84574d6a8c0f7.tar.gz |
fix and refactor note user mapping
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/import_export/members_mapper.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/import_export/relation_factory.rb | 10 |
2 files changed, 3 insertions, 9 deletions
diff --git a/lib/gitlab/import_export/members_mapper.rb b/lib/gitlab/import_export/members_mapper.rb index 1dab7c37d25..ac7604d2461 100644 --- a/lib/gitlab/import_export/members_mapper.rb +++ b/lib/gitlab/import_export/members_mapper.rb @@ -7,7 +7,6 @@ module Gitlab @exported_members = user.admin? ? exported_members : [] @user = user @project = project - @missing_author_ids = [] # This needs to run first, as second call would be from #map # which means project members already exist. @@ -39,7 +38,6 @@ module Gitlab def missing_keys_tracking_hash Hash.new do |_, key| - @missing_author_ids << key default_user_id end end diff --git a/lib/gitlab/import_export/relation_factory.rb b/lib/gitlab/import_export/relation_factory.rb index a5f6fbbcfd3..e5f9aa39190 100644 --- a/lib/gitlab/import_export/relation_factory.rb +++ b/lib/gitlab/import_export/relation_factory.rb @@ -80,17 +80,13 @@ module Gitlab # is left. def set_note_author old_author_id = @relation_hash['author_id'] - - # Users with admin access can map users - @relation_hash['author_id'] = admin_user? ? @members_mapper.map[old_author_id] : @members_mapper.default_user_id - author = @relation_hash.delete('author') - update_note_for_missing_author(author['name']) if missing_author?(old_author_id) + update_note_for_missing_author(author['name']) unless has_author?(old_author_id) end - def missing_author?(old_author_id) - !admin_user? || @members_mapper.missing_author_ids.include?(old_author_id) + def has_author?(old_author_id) + admin_user? && !@members_mapper.map.keys.include?(old_author_id) end def missing_author_note(updated_at, author_name) |