Import threaded discussions in diffs
This commit is contained in:
parent
ea727862df
commit
5817c67014
1 changed files with 21 additions and 6 deletions
|
@ -135,20 +135,35 @@ module Gitlab
|
||||||
end
|
end
|
||||||
|
|
||||||
inline_comments.each do |comment|
|
inline_comments.each do |comment|
|
||||||
begin
|
parent = build_diff_note(merge_request, comment, line_code_map)
|
||||||
attributes = pull_request_comment_attributes(comment)
|
|
||||||
|
next unless parent&.persisted?
|
||||||
|
|
||||||
|
comment.comments.each do |reply|
|
||||||
|
attributes = pull_request_comment_attributes(reply)
|
||||||
attributes.merge!(
|
attributes.merge!(
|
||||||
position: build_position(merge_request, comment),
|
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')
|
type: 'DiffNote')
|
||||||
|
|
||||||
merge_request.notes.create!(attributes)
|
merge_request.notes.create!(attributes)
|
||||||
rescue StandardError => e
|
|
||||||
errors << { type: :pull_request, id: comment.id, errors: e.message }
|
|
||||||
end
|
end
|
||||||
end
|
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)
|
def build_position(merge_request, pr_comment)
|
||||||
params = {
|
params = {
|
||||||
diff_refs: merge_request.diff_refs,
|
diff_refs: merge_request.diff_refs,
|
||||||
|
|
Loading…
Reference in a new issue