diff options
author | Stan Hu <stanhu@gmail.com> | 2018-06-29 01:18:53 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2018-06-29 01:18:53 +0300 |
commit | 7b67350a0c7ed11343420b4d01258c09ce2fa49c (patch) | |
tree | ad0f7d4fc0e15fb4bb3df489ed09465dfee61d07 /lib/gitlab/bitbucket_server_import | |
parent | ee5f8f2830f7bdfcbd36b2368dd15b109bf29c69 (diff) |
Remove unnecessary code and fix branch names
Diffstat (limited to 'lib/gitlab/bitbucket_server_import')
-rw-r--r-- | lib/gitlab/bitbucket_server_import/importer.rb | 46 |
1 files changed, 15 insertions, 31 deletions
diff --git a/lib/gitlab/bitbucket_server_import/importer.rb b/lib/gitlab/bitbucket_server_import/importer.rb index f035cc58acf..5f6230438bc 100644 --- a/lib/gitlab/bitbucket_server_import/importer.rb +++ b/lib/gitlab/bitbucket_server_import/importer.rb @@ -2,12 +2,6 @@ module Gitlab module BitbucketServerImport class Importer include Gitlab::ShellAdapter - - LABELS = [{ title: 'bug', color: '#FF0000' }, - { title: 'enhancement', color: '#428BCA' }, - { title: 'proposal', color: '#69D100' }, - { title: 'task', color: '#7F8C8D' }].freeze - attr_reader :project, :project_key, :repository_slug, :client, :errors, :users def initialize(project) @@ -16,7 +10,6 @@ module Gitlab @repository_slug = project.import_data.data['repo_slug'] @client = BitbucketServer::Client.new(project.import_data.credentials) @formatter = Gitlab::ImportFormatter.new - @labels = {} @errors = [] @users = {} end @@ -75,10 +68,10 @@ module Gitlab title: pull_request.title, description: description, source_project: project, - source_branch: pull_request.source_branch_name, - source_branch_sha: source_branch_sha, + source_branch: Gitlab::Git.ref_name(pull_request.source_branch_name), + source_branch_sha: pull_request.source_branch_sha, target_project: project, - target_branch: pull_request.target_branch_name, + target_branch: Gitlab::Git.ref_name(pull_request.target_branch_name), target_branch_sha: target_branch_sha, state: pull_request.state, author_id: gitlab_user_id(project, pull_request.author_email), @@ -123,39 +116,30 @@ module Gitlab end def import_inline_comments(inline_comments, pull_request, merge_request) - line_code_map = {} - - inline_comments.each do |comment| - line_code = generate_line_code(comment) - line_code_map[comment.id] = line_code - - comment.comments.each do |reply| - line_code_map[reply.id] = line_code - end - end - inline_comments.each do |comment| - parent = build_diff_note(merge_request, comment, line_code_map) + parent = build_diff_note(merge_request, comment) next unless parent&.persisted? comment.comments.each do |reply| - attributes = pull_request_comment_attributes(reply) - attributes.merge!( - position: build_position(merge_request, comment), - line_code: line_code_map.fetch(reply.id), - discussion_id: parent.discussion_id, - type: 'DiffNote') - merge_request.notes.create!(attributes) + begin + attributes = pull_request_comment_attributes(reply) + attributes.merge!( + position: build_position(merge_request, comment), + discussion_id: parent.discussion_id, + type: 'DiffNote') + merge_request.notes.create!(attributes) + rescue StandardError => e + errors << { type: :pull_request, id: comment.id, errors: e.message } + end end end end - def build_diff_note(merge_request, comment, line_code_map) + def build_diff_note(merge_request, comment) attributes = pull_request_comment_attributes(comment) attributes.merge!( position: build_position(merge_request, comment), - line_code: line_code_map.fetch(comment.id), type: 'DiffNote') merge_request.notes.create!(attributes) |