summaryrefslogtreecommitdiff
path: root/lib/gitlab/conflict
diff options
context:
space:
mode:
authorSean McGivern <sean@gitlab.com>2016-09-07 12:28:13 +0100
committerAlfredo Sumaran <alfredo@gitlab.com>2016-10-13 14:16:34 -0500
commit4743d19463e7aef965665e43238af73820d18d7f (patch)
treee0aff3161a657dbdb0de2ac75650472124e869b5 /lib/gitlab/conflict
parent7529bbae944823041e8690c011c4cfb39534074b (diff)
downloadgitlab-ce-4743d19463e7aef965665e43238af73820d18d7f.tar.gz
Simplify conflict file JSON creation
Diffstat (limited to 'lib/gitlab/conflict')
-rw-r--r--lib/gitlab/conflict/file.rb22
1 files changed, 15 insertions, 7 deletions
diff --git a/lib/gitlab/conflict/file.rb b/lib/gitlab/conflict/file.rb
index 26a9f170298..661e43d3fa9 100644
--- a/lib/gitlab/conflict/file.rb
+++ b/lib/gitlab/conflict/file.rb
@@ -9,7 +9,7 @@ module Gitlab
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:)
@merge_file_result = merge_file_result
@@ -25,6 +25,12 @@ module Gitlab
merge_file_result[:data]
end
+ def type
+ lines unless @type
+
+ @type.inquiry
+ end
+
# Array of Gitlab::Diff::Line objects
def lines
return @lines if defined?(@lines)
@@ -200,12 +206,14 @@ module Gitlab
::File.join(merge_request.diff_refs.head_sha, our_path))
}
- if opts[:full_content]
- json_hash.merge(content: content)
- else
- json_hash.merge!(sections: sections) if type == 'text'
-
- json_hash.merge(type: type, content_path: content_path)
+ json_hash.tap do |json_hash|
+ if opts[:full_content]
+ json_hash[:content] = content
+ else
+ json_hash[:sections] = sections if type.text?
+ json_hash[:type] = type
+ json_hash[:content_path] = content_path
+ end
end
end