Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2018-06-28 11:49:35 +0300
committerStan Hu <stanhu@gmail.com>2018-06-28 11:49:35 +0300
commit5817c67014576fab899fac3d8478f3620af4dda2 (patch)
tree8b76edb5ba00b8ba6b50902a827fad0a869d351c /lib/gitlab/bitbucket_server_import
parentea727862df2861c0dd8ac874b40fbd96009e8ea9 (diff)
Import threaded discussions in diffs
Diffstat (limited to 'lib/gitlab/bitbucket_server_import')
-rw-r--r--lib/gitlab/bitbucket_server_import/importer.rb27
1 files changed, 21 insertions, 6 deletions
diff --git a/lib/gitlab/bitbucket_server_import/importer.rb b/lib/gitlab/bitbucket_server_import/importer.rb
index fcf75dc493b..33bd1aeb127 100644
--- a/lib/gitlab/bitbucket_server_import/importer.rb
+++ b/lib/gitlab/bitbucket_server_import/importer.rb
@@ -135,20 +135,35 @@ module Gitlab
end
inline_comments.each do |comment|
- begin
- attributes = pull_request_comment_attributes(comment)
+ parent = build_diff_note(merge_request, comment, line_code_map)
+
+ 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(comment.id),
+ line_code: line_code_map.fetch(reply.id)
+ 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
+ def build_diff_note(merge_request, comment, line_code_map)
+ 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)
+ rescue StandardError => e
+ errors << { type: :pull_request, id: comment.id, errors: e.message }
+ nil
+ end
+
def build_position(merge_request, pr_comment)
params = {
diff_refs: merge_request.diff_refs,