Commit 8d299cf9 authored by Jan Provaznik's avatar Jan Provaznik

Merge branch 'kassio/relation-refactory-set-note-refactoring' into 'master'

Refactor Project/Group import missing author note

See merge request gitlab-org/gitlab!42881
parents 613044b1 36dea9f8
......@@ -248,25 +248,17 @@ module Gitlab
old_author_id = @original_user['author_id']
author = @relation_hash.delete('author')
update_note_for_missing_author(author['name']) unless has_author?(old_author_id)
end
def has_author?(old_author_id)
admin_user? && @members_mapper.include?(old_author_id)
unless @members_mapper.include?(old_author_id)
@relation_hash['note'] = "%{note}\n\n %{missing_author_note}" % {
note: @relation_hash['note'].presence || '*Blank note*',
missing_author_note: missing_author_note(@relation_hash['updated_at'], author['name'])
}
end
end
def missing_author_note(updated_at, author_name)
timestamp = updated_at.split('.').first
"\n\n *By #{author_name} on #{timestamp} (imported from GitLab project)*"
end
def update_note_for_missing_author(author_name)
@relation_hash['note'] = '*Blank note*' if @relation_hash['note'].blank?
@relation_hash['note'] = "#{@relation_hash['note']}#{missing_author_note(@relation_hash['updated_at'], author_name)}"
end
def admin_user?
@user.admin?
"*By #{author_name} on #{timestamp} (imported from GitLab)*"
end
def existing_object?
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment