From 5ba77a49997221cc646f158d56c86a636b42e735 Mon Sep 17 00:00:00 2001 From: George Koltsov Date: Wed, 7 Aug 2019 14:01:18 +0100 Subject: Add author lines to project import comments --- lib/bitbucket/representation/comment.rb | 2 +- lib/bitbucket/representation/issue.rb | 2 +- lib/bitbucket/representation/pull_request.rb | 2 +- lib/gitlab/bitbucket_import/importer.rb | 12 ++++++++++-- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/bitbucket/representation/comment.rb b/lib/bitbucket/representation/comment.rb index 1b8dc27793a..127598a76ab 100644 --- a/lib/bitbucket/representation/comment.rb +++ b/lib/bitbucket/representation/comment.rb @@ -4,7 +4,7 @@ module Bitbucket module Representation class Comment < Representation::Base def author - user['username'] + user['nickname'] end def note diff --git a/lib/bitbucket/representation/issue.rb b/lib/bitbucket/representation/issue.rb index a88797cdab9..3f6db9cb75b 100644 --- a/lib/bitbucket/representation/issue.rb +++ b/lib/bitbucket/representation/issue.rb @@ -14,7 +14,7 @@ module Bitbucket end def author - raw.dig('reporter', 'username') + raw.dig('reporter', 'nickname') end def description diff --git a/lib/bitbucket/representation/pull_request.rb b/lib/bitbucket/representation/pull_request.rb index 6a0e8b354bf..a498c9bc213 100644 --- a/lib/bitbucket/representation/pull_request.rb +++ b/lib/bitbucket/representation/pull_request.rb @@ -4,7 +4,7 @@ module Bitbucket module Representation class PullRequest < Representation::Base def author - raw.fetch('author', {}).fetch('username', nil) + raw.fetch('author', {}).fetch('nickname', nil) end def description diff --git a/lib/gitlab/bitbucket_import/importer.rb b/lib/gitlab/bitbucket_import/importer.rb index 8047ef4fa15..e017b30050f 100644 --- a/lib/gitlab/bitbucket_import/importer.rb +++ b/lib/gitlab/bitbucket_import/importer.rb @@ -260,15 +260,23 @@ module Gitlab end def pull_request_comment_attributes(comment) + author_id = gitlab_user_id(project, comment.author) + { project: project, - note: comment.note, - author_id: gitlab_user_id(project, comment.author), + note: comment_note(comment, author_id), + author_id: author_id, created_at: comment.created_at, updated_at: comment.updated_at } end + def comment_note(comment, author_id) + note = '' + note += @formatter.author_line(comment.author) if author_id == project.creator_id + note + comment.note + end + def log_error(details) logger.error(log_base_data.merge(details)) end -- cgit v1.2.1