summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Koltsov <gkoltsov@gitlab.com>2019-08-08 10:26:37 +0100
committerGeorge Koltsov <gkoltsov@gitlab.com>2019-08-08 13:16:33 +0100
commitba429a6e2023242a55f9199b1381ac331cc92e1c (patch)
tree9f02ca8e7bf79e27962419a2d4d58c1871aa5978
parent9baa7ee14f1e404b1e3ba74512fd2fc026c70276 (diff)
downloadgitlab-ce-ba429a6e2023242a55f9199b1381ac331cc92e1c.tar.gz
Apply code review feedback
-rw-r--r--changelogs/unreleased/georgekoltsov-63408-user-mapping.yml3
-rw-r--r--doc/user/project/import/bitbucket.md12
-rw-r--r--lib/gitlab/bitbucket_import/importer.rb10
-rw-r--r--spec/lib/gitlab/bitbucket_import/importer_spec.rb4
4 files changed, 13 insertions, 16 deletions
diff --git a/changelogs/unreleased/georgekoltsov-63408-user-mapping.yml b/changelogs/unreleased/georgekoltsov-63408-user-mapping.yml
index 323d0447e54..451aac9c2e3 100644
--- a/changelogs/unreleased/georgekoltsov-63408-user-mapping.yml
+++ b/changelogs/unreleased/georgekoltsov-63408-user-mapping.yml
@@ -1,6 +1,5 @@
---
-title: 'Fix BitBucketCloud imported project''s comments missing author line (''Created
- by: <user>'')'
+title: 'Fix missing author line (`Created by: <user>`) in MRs/issues/comments of imported Bitbucket Cloud project'
merge_request: 31579
author:
type: fixed
diff --git a/doc/user/project/import/bitbucket.md b/doc/user/project/import/bitbucket.md
index c9f60db0656..a950cdff41e 100644
--- a/doc/user/project/import/bitbucket.md
+++ b/doc/user/project/import/bitbucket.md
@@ -31,12 +31,12 @@ to enable this if not already.
## How it works
When issues/pull requests are being imported, the Bitbucket importer tries to find
-the Bitbucket author/assignee in GitLab's database using the Bitbucket `nickname`. For this
-to work, the Bitbucket author/assignee should have their `nickname` match their Bitbucket
-`username`, signed in beforehand in GitLab and **associated their Bitbucket account**.
-If the user is not found in GitLab's database, the project creator (most of the times the
-current user that started the import process) is set as the author, but a reference on
-the issue about the original Bitbucket author is kept.
+the Bitbucket author/assignee in GitLab's database using the Bitbucket `nickname`.
+For this to work, the Bitbucket author/assignee should have signed in beforehand in GitLab
+and **associated their Bitbucket account**. Their `nickname` must also match their Bitbucket
+`username.`. If the user is not found in GitLab's database, the project creator
+(most of the times the current user that started the import process) is set as the author,
+but a reference on the issue about the original Bitbucket author is kept.
The importer will create any new namespaces (groups) if they don't exist or in
the case the namespace is taken, the repository will be imported under the user's
diff --git a/lib/gitlab/bitbucket_import/importer.rb b/lib/gitlab/bitbucket_import/importer.rb
index e017b30050f..9560b187292 100644
--- a/lib/gitlab/bitbucket_import/importer.rb
+++ b/lib/gitlab/bitbucket_import/importer.rb
@@ -260,20 +260,18 @@ module Gitlab
end
def pull_request_comment_attributes(comment)
- author_id = gitlab_user_id(project, comment.author)
-
{
project: project,
- note: comment_note(comment, author_id),
- author_id: author_id,
+ note: comment_note(comment),
+ author_id: gitlab_user_id(project, comment.author),
created_at: comment.created_at,
updated_at: comment.updated_at
}
end
- def comment_note(comment, author_id)
+ def comment_note(comment)
note = ''
- note += @formatter.author_line(comment.author) if author_id == project.creator_id
+ note += @formatter.author_line(comment.author) unless find_user_id(comment.author)
note + comment.note
end
diff --git a/spec/lib/gitlab/bitbucket_import/importer_spec.rb b/spec/lib/gitlab/bitbucket_import/importer_spec.rb
index 56ccd899cc6..3d0d3f91859 100644
--- a/spec/lib/gitlab/bitbucket_import/importer_spec.rb
+++ b/spec/lib/gitlab/bitbucket_import/importer_spec.rb
@@ -184,11 +184,11 @@ describe Gitlab::BitbucketImport::Importer do
notes = merge_request.notes.order(:id).to_a
start_note = notes.first
- expect(start_note.note).to include(@inline_note.note)
+ expect(start_note.note).to eq(@inline_note.note)
expect(start_note.note).not_to include(author_line)
reply_note = notes.last
- expect(reply_note.note).to include(@reply.note)
+ expect(reply_note.note).to eq(@reply.note)
expect(reply_note.note).not_to include(author_line)
end
end