Commit 36dea9f8 authored by Kassio Borges's avatar Kassio Borges

Refactor Project/Group import missing author note

- Removes duplicated `admin?` check. This validation is already done in
  Gitlab::ImportExport::MembersMapper.
- Remove some accessory methods, making the conditional more explicit.
- Use String template to manipulate the note itself
parent 2d998d8c
......@@ -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)
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
def has_author?(old_author_id)
admin_user? && @members_mapper.include?(old_author_id)
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