diff options
author | Stan Hu <stanhu@gmail.com> | 2018-06-28 10:50:10 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2018-06-28 10:50:10 +0300 |
commit | c4dbe61a846ddc97f8161e14771a58f406f65c81 (patch) | |
tree | 1339d0bfbc4b911a2ef698153ba01a4daedb12c0 /lib/gitlab/bitbucket_server_import | |
parent | 014abc9c07c1389e64ccf336559b488835730a45 (diff) |
First iteration of importing diff notes
Diffstat (limited to 'lib/gitlab/bitbucket_server_import')
-rw-r--r-- | lib/gitlab/bitbucket_server_import/importer.rb | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/lib/gitlab/bitbucket_server_import/importer.rb b/lib/gitlab/bitbucket_server_import/importer.rb index f8871ade6e7..fcf75dc493b 100644 --- a/lib/gitlab/bitbucket_server_import/importer.rb +++ b/lib/gitlab/bitbucket_server_import/importer.rb @@ -104,7 +104,7 @@ module Gitlab inline_comments, pr_comments = comments.partition(&:inline_comment?) -# import_inline_comments(inline_comments, pull_request, merge_request) + import_inline_comments(inline_comments.map(&:comment), pull_request, merge_request) import_standalone_pr_comments(pr_comments.map(&:comment), merge_request) end @@ -125,17 +125,13 @@ module Gitlab def import_inline_comments(inline_comments, pull_request, merge_request) line_code_map = {} - children, parents = inline_comments.partition(&:has_parent?) - - # The BitbucketServer API returns threaded replies as parent-child - # relationships. We assume that the child can appear in any order in - # the JSON. - parents.each do |comment| - line_code_map[comment.iid] = generate_line_code(comment) - end + inline_comments.each do |comment| + line_code = generate_line_code(comment) + line_code_map[comment.id] = line_code - children.each do |comment| - line_code_map[comment.iid] = line_code_map.fetch(comment.parent_id, nil) + comment.comments.each do |reply| + line_code_map[reply.id] = line_code + end end inline_comments.each do |comment| @@ -143,12 +139,12 @@ module Gitlab attributes = pull_request_comment_attributes(comment) attributes.merge!( position: build_position(merge_request, comment), - line_code: line_code_map.fetch(comment.iid), + line_code: line_code_map.fetch(comment.id), type: 'DiffNote') merge_request.notes.create!(attributes) rescue StandardError => e - errors << { type: :pull_request, iid: comment.iid, errors: e.message } + errors << { type: :pull_request, id: comment.id, errors: e.message } end end end |