Commit 4743d194 authored by Sean McGivern's avatar Sean McGivern Committed by Alfredo Sumaran

Simplify conflict file JSON creation

parent 7529bbae
...@@ -9,7 +9,7 @@ module Gitlab ...@@ -9,7 +9,7 @@ module Gitlab
CONTEXT_LINES = 3 CONTEXT_LINES = 3
attr_reader :merge_file_result, :their_path, :our_path, :our_mode, :merge_request, :repository, :type attr_reader :merge_file_result, :their_path, :our_path, :our_mode, :merge_request, :repository
def initialize(merge_file_result, conflict, merge_request:) def initialize(merge_file_result, conflict, merge_request:)
@merge_file_result = merge_file_result @merge_file_result = merge_file_result
...@@ -25,6 +25,12 @@ module Gitlab ...@@ -25,6 +25,12 @@ module Gitlab
merge_file_result[:data] merge_file_result[:data]
end end
def type
lines unless @type
@type.inquiry
end
# Array of Gitlab::Diff::Line objects # Array of Gitlab::Diff::Line objects
def lines def lines
return @lines if defined?(@lines) return @lines if defined?(@lines)
...@@ -200,12 +206,14 @@ module Gitlab ...@@ -200,12 +206,14 @@ module Gitlab
::File.join(merge_request.diff_refs.head_sha, our_path)) ::File.join(merge_request.diff_refs.head_sha, our_path))
} }
json_hash.tap do |json_hash|
if opts[:full_content] if opts[:full_content]
json_hash.merge(content: content) json_hash[:content] = content
else else
json_hash.merge!(sections: sections) if type == 'text' json_hash[:sections] = sections if type.text?
json_hash[:type] = type
json_hash.merge(type: type, content_path: content_path) json_hash[:content_path] = content_path
end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment