summaryrefslogtreecommitdiff
path: root/lib/gitlab/diff/highlight.rb
diff options
context:
space:
mode:
authorDouwe Maan <douwe@selenight.nl>2016-06-20 19:15:44 +0200
committerDouwe Maan <douwe@selenight.nl>2016-07-06 18:50:59 -0400
commita27462a5c6da0182f6b3a55c9417e6405f2c0415 (patch)
tree6bdf936568c0f9274cbf24db7f8b6517b2200980 /lib/gitlab/diff/highlight.rb
parent375193455aa5cb752f1035a6cc69160170a58477 (diff)
downloadgitlab-ce-a27462a5c6da0182f6b3a55c9417e6405f2c0415.tar.gz
Extract parts of LegacyDiffNote into DiffOnNote concern and move part of responsibility to other classes
Diffstat (limited to 'lib/gitlab/diff/highlight.rb')
-rw-r--r--lib/gitlab/diff/highlight.rb16
1 files changed, 4 insertions, 12 deletions
diff --git a/lib/gitlab/diff/highlight.rb b/lib/gitlab/diff/highlight.rb
index 3ad68728d65..44ea6bf6102 100644
--- a/lib/gitlab/diff/highlight.rb
+++ b/lib/gitlab/diff/highlight.rb
@@ -42,10 +42,9 @@ module Gitlab
line_prefix = diff_line.text.match(/\A(.)/) ? $1 : ' '
- case diff_line.type
- when 'new', nil
+ if diff_line.unchanged? || diff_line.added?
rich_line = new_lines[diff_line.new_pos - 1]
- when 'old'
+ elsif diff_line.removed?
rich_line = old_lines[diff_line.old_pos - 1]
end
@@ -60,19 +59,12 @@ module Gitlab
def old_lines
return unless diff_file
- @old_lines ||= Gitlab::Highlight.highlight_lines(*processing_args(:old))
+ @old_lines ||= Gitlab::Highlight.highlight_lines(self.repository, diff_old_ref, diff_old_path)
end
def new_lines
return unless diff_file
- @new_lines ||= Gitlab::Highlight.highlight_lines(*processing_args(:new))
- end
-
- def processing_args(version)
- ref = send("diff_#{version}_ref")
- path = send("diff_#{version}_path")
-
- [self.repository, ref, path]
+ @new_lines ||= Gitlab::Highlight.highlight_lines(self.repository, diff_new_ref, diff_new_path)
end
end
end