diff options
author | Valery Sizov <valery@gitlab.com> | 2016-12-13 21:28:04 +0200 |
---|---|---|
committer | Valery Sizov <valery@gitlab.com> | 2016-12-13 21:28:07 +0200 |
commit | e39f024029b46322c1bf24409fd5ce7bfcef2da5 (patch) | |
tree | 52664136981b70c409f2cfb8e43235596821eb19 /lib/gitlab/bitbucket_import | |
parent | 0057ed1e69bc203d82fd3e8dfa6db7ea6a9b1de7 (diff) | |
download | gitlab-ce-e39f024029b46322c1bf24409fd5ce7bfcef2da5.tar.gz |
BB importer: Adding created_by only when used is not found[ci skip]
Diffstat (limited to 'lib/gitlab/bitbucket_import')
-rw-r--r-- | lib/gitlab/bitbucket_import/importer.rb | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/lib/gitlab/bitbucket_import/importer.rb b/lib/gitlab/bitbucket_import/importer.rb index a0a17333185..519a109c0c8 100644 --- a/lib/gitlab/bitbucket_import/importer.rb +++ b/lib/gitlab/bitbucket_import/importer.rb @@ -24,15 +24,23 @@ module Gitlab private - def gitlab_user_id(project, bitbucket_id) - if bitbucket_id - user = User.joins(:identities).find_by("identities.extern_uid = ? AND identities.provider = 'bitbucket'", bitbucket_id.to_s) + def gitlab_user_id(project, user) + if user.uuid + user = find_user_by_uuid(user.uuid) (user && user.id) || project.creator_id else project.creator_id end end + def find_user_by_uuid(uuid) + User.joins(:identities).find_by("identities.extern_uid = ? AND identities.provider = 'bitbucket'", uuid) + end + + def existing_gitlab_user?(user) + user.uuid && find_user_by_uuid(user.uuid) + end + def repo @repo ||= client.repo(project.import_source) end @@ -43,7 +51,8 @@ module Gitlab create_labels client.issues(repo).each do |issue| - description = @formatter.author_line(issue.author) + description = '' + description += @formatter.author_line(issue.author.username) unless existing_gitlab_user?(issue.author) description += issue.description label_name = issue.kind @@ -69,7 +78,8 @@ module Gitlab # we do this check. next unless comment.note.present? - note = @formatter.author_line(comment.author) + note = '' + note += @formatter.author_line(comment.author.username) unless existing_gitlab_user?(comment.author) note += comment.note issue.notes.create!( @@ -97,7 +107,8 @@ module Gitlab pull_requests.each do |pull_request| begin - description = @formatter.author_line(pull_request.author) + description = '' + description += @formatter.author_line(pull_request.author.username) unless existing_gitlab_user?(pull_request.author) description += pull_request.description merge_request = project.merge_requests.create( |