diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/conflict/file.rb | 18 | ||||
-rw-r--r-- | lib/gitlab/conflict/file_collection.rb | 1 | ||||
-rw-r--r-- | lib/gitlab/conflict/parser.rb | 6 | ||||
-rw-r--r-- | lib/gitlab/diff/line.rb | 6 |
4 files changed, 13 insertions, 18 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| diff --git a/lib/gitlab/conflict/file_collection.rb b/lib/gitlab/conflict/file_collection.rb index 5122a5b2111..da9994a7405 100644 --- a/lib/gitlab/conflict/file_collection.rb +++ b/lib/gitlab/conflict/file_collection.rb @@ -46,7 +46,6 @@ module Gitlab Gitlab::Conflict::File.new(merge_index.merge_file(conflict[:ours][:path]), conflict, - diff_refs: merge_request.diff_refs, repository: repository) end end diff --git a/lib/gitlab/conflict/parser.rb b/lib/gitlab/conflict/parser.rb index 9f27cba353a..6eccded7872 100644 --- a/lib/gitlab/conflict/parser.rb +++ b/lib/gitlab/conflict/parser.rb @@ -13,7 +13,7 @@ module Gitlab class UnmergeableFile < ParserError end - def parse(text, our_path:, their_path:, parent: nil) + def parse(text, our_path:, their_path:, parent_file: nil) raise UnmergeableFile if text.blank? # Typically a binary file raise UnmergeableFile if text.length > 102400 @@ -43,9 +43,9 @@ module Gitlab type = nil elsif line[0] == '\\' type = 'nonewline' - lines << Gitlab::Diff::Line.new(full_line, type, line_obj_index, line_old, line_new, parent: parent) + lines << Gitlab::Diff::Line.new(full_line, type, line_obj_index, line_old, line_new, parent_file: parent_file) else - lines << Gitlab::Diff::Line.new(full_line, type, line_obj_index, line_old, line_new, parent: parent) + lines << Gitlab::Diff::Line.new(full_line, type, line_obj_index, line_old, line_new, parent_file: parent_file) line_old += 1 if type != 'new' line_new += 1 if type != 'old' diff --git a/lib/gitlab/diff/line.rb b/lib/gitlab/diff/line.rb index 38400b48b5c..80a146b4a5a 100644 --- a/lib/gitlab/diff/line.rb +++ b/lib/gitlab/diff/line.rb @@ -5,10 +5,10 @@ module Gitlab attr_writer :rich_text attr_accessor :text - def initialize(text, type, index, old_pos, new_pos, parent: nil) + def initialize(text, type, index, old_pos, new_pos, parent_file: nil) @text, @type, @index = text, type, index @old_pos, @new_pos = old_pos, new_pos - @parent = parent + @parent_file = parent_file end def self.init_from_hash(hash) @@ -46,7 +46,7 @@ module Gitlab end def rich_text - @parent.highlight_lines! if @parent && !@rich_text + @parent_file.highlight_lines! if @parent_file && !@rich_text @rich_text end |