summaryrefslogtreecommitdiff
path: root/lib/gitlab/bitbucket_import
diff options
context:
space:
mode:
authorValery Sizov <valery@gitlab.com>2016-12-05 20:34:11 +0200
committerValery Sizov <valery@gitlab.com>2016-12-05 21:14:46 +0200
commit54221b5a3b9a2489f979944c77298c4adf004984 (patch)
treede9349c2f7559ce919b4dba1e466e23e42357370 /lib/gitlab/bitbucket_import
parent32c6c9c457d88071ad82728ea6111a2d7d31b634 (diff)
downloadgitlab-ce-54221b5a3b9a2489f979944c77298c4adf004984.tar.gz
Fix inline comment importing for 1:1 diff type
Diffstat (limited to 'lib/gitlab/bitbucket_import')
-rw-r--r--lib/gitlab/bitbucket_import/importer.rb26
1 files changed, 19 insertions, 7 deletions
diff --git a/lib/gitlab/bitbucket_import/importer.rb b/lib/gitlab/bitbucket_import/importer.rb
index 08705afcabb..6438c8a52e4 100644
--- a/lib/gitlab/bitbucket_import/importer.rb
+++ b/lib/gitlab/bitbucket_import/importer.rb
@@ -81,10 +81,10 @@ module Gitlab
description: description,
source_project: project,
source_branch: pull_request.source_branch_name,
- source_branch_sha: pull_request.source_branch_sha,
+ source_branch_sha: project.repository.rugged.lookup(pull_request.source_branch_sha).oid,
target_project: project,
target_branch: pull_request.target_branch_name,
- target_branch_sha: pull_request.target_branch_sha,
+ target_branch_sha: project.repository.rugged.lookup(pull_request.target_branch_sha).oid,
state: pull_request.state,
author_id: gitlab_user_id(project, pull_request.author),
assignee_id: nil,
@@ -94,7 +94,7 @@ module Gitlab
import_pull_request_comments(pull_request, merge_request) if merge_request.persisted?
rescue ActiveRecord::RecordInvalid
- Rails.log.error("Bitbucket importer ERROR in #{project.path_with_namespace}: Invalid pull request #{e.message}")
+ Rails.logger.error("Bitbucket importer ERROR in #{project.path_with_namespace}: Invalid pull request #{e.message}")
end
end
end
@@ -128,24 +128,36 @@ module Gitlab
begin
attributes = pull_request_comment_attributes(comment)
attributes.merge!(
- commit_id: pull_request.source_branch_sha,
+ position: build_position(merge_request, comment),
line_code: line_code_map.fetch(comment.iid),
- type: 'LegacyDiffNote')
+ type: 'DiffNote')
merge_request.notes.create!(attributes)
rescue ActiveRecord::RecordInvalid => e
- Rails.log.error("Bitbucket importer ERROR in #{project.path_with_namespace}: Invalid pull request comment #{e.message}")
+ Rails.logger.error("Bitbucket importer ERROR in #{project.path_with_namespace}: Invalid pull request comment #{e.message}")
nil
end
end
end
+ def build_position(merge_request, pr_comment)
+ params = {
+ diff_refs: merge_request.diff_refs,
+ old_path: pr_comment.file_path,
+ new_path: pr_comment.file_path,
+ old_line: pr_comment.old_pos,
+ new_line: pr_comment.new_pos
+ }
+
+ Gitlab::Diff::Position.new(params)
+ end
+
def import_standalone_pr_comments(pr_comments, merge_request)
pr_comments.each do |comment|
begin
merge_request.notes.create!(pull_request_comment_attributes(comment))
rescue ActiveRecord::RecordInvalid => e
- Rails.log.error("Bitbucket importer ERROR in #{project.path_with_namespace}: Invalid standalone pull request comment #{e.message}")
+ Rails.logger.error("Bitbucket importer ERROR in #{project.path_with_namespace}: Invalid standalone pull request comment #{e.message}")
nil
end
end