summaryrefslogtreecommitdiff
path: root/lib/gitlab/conflict/file.rb
diff options
context:
space:
mode:
authorSean McGivern <sean@gitlab.com>2016-08-02 09:20:22 +0100
committerFatih Acet <acetfatih@gmail.com>2016-08-12 23:24:46 +0300
commit261d47bce9d7cc80b4c2068cb612411fe51530ee (patch)
tree2f913169220c9e9e6d4e5e1610b085dedbdf864e /lib/gitlab/conflict/file.rb
parent6f3501fe252404b342984514b1b784ffa73edbd0 (diff)
downloadgitlab-ce-261d47bce9d7cc80b4c2068cb612411fe51530ee.tar.gz
Fix specs
- Add match line header to expected result for `File#sections`. - Lowercase CSS colours. - Remove unused `diff_refs` keyword argument. - Rename `parent` -> `parent_file`, to be more explicit. - Skip an iteration when highlighting.
Diffstat (limited to 'lib/gitlab/conflict/file.rb')
-rw-r--r--lib/gitlab/conflict/file.rb18
1 files changed, 7 insertions, 11 deletions
diff --git a/lib/gitlab/conflict/file.rb b/lib/gitlab/conflict/file.rb
index 2c7f6628c23..7f10b8ea8fd 100644
--- a/lib/gitlab/conflict/file.rb
+++ b/lib/gitlab/conflict/file.rb
@@ -6,14 +6,12 @@ module Gitlab
CONTEXT_LINES = 3
- attr_reader :merge_file_result, :their_path, :their_ref, :our_path, :our_ref, :repository
+ attr_reader :merge_file_result, :their_path, :our_path, :repository
- def initialize(merge_file_result, conflict, diff_refs:, repository:)
+ def initialize(merge_file_result, conflict, repository:)
@merge_file_result = merge_file_result
@their_path = conflict[:theirs][:path]
@our_path = conflict[:ours][:path]
- @their_ref = diff_refs.start_sha
- @our_ref = diff_refs.head_sha
@repository = repository
end
@@ -22,7 +20,7 @@ module Gitlab
@lines ||= Gitlab::Conflict::Parser.new.parse(merge_file_result[:data],
our_path: our_path,
their_path: their_path,
- parent: self)
+ parent_file: self)
end
def resolve!(resolution, index:, rugged:)
@@ -62,14 +60,14 @@ module Gitlab
their_file = lines.reject { |line| line.type == 'new' }.map(&:text).join("\n")
our_file = lines.reject { |line| line.type == 'old' }.map(&:text).join("\n")
- their_highlight = Gitlab::Highlight.highlight(their_path, their_file, repository: repository).lines.map(&:html_safe)
- our_highlight = Gitlab::Highlight.highlight(our_path, our_file, repository: repository).lines.map(&:html_safe)
+ their_highlight = Gitlab::Highlight.highlight(their_path, their_file, repository: repository).lines
+ our_highlight = Gitlab::Highlight.highlight(our_path, our_file, repository: repository).lines
lines.each do |line|
if line.type == 'old'
- line.rich_text = their_highlight[line.old_line - 1]
+ line.rich_text = their_highlight[line.old_line - 1].html_safe
else
- line.rich_text = our_highlight[line.new_line - 1]
+ line.rich_text = our_highlight[line.new_line - 1].html_safe
end
end
end
@@ -82,8 +80,6 @@ module Gitlab
end
chunked_lines = lines.chunk { |line| line.type.nil? }
- last_candidate_match_header = nil
- match_line_header = nil
match_line = nil
@sections = chunked_lines.flat_map.with_index do |(no_conflict, lines), i|