diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2017-06-19 18:25:06 +0000 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2017-06-19 18:25:06 +0000 |
commit | 365670d814bf57396a9ce02190fa297d15c79cb9 (patch) | |
tree | 874e443734883f6bf020a9da42bfbe79af5e2d59 /lib | |
parent | 435d1a01749a2b0a3d96ef3802aaa382e5b78429 (diff) | |
parent | 5e8aca215243d2eaacb0a1b744909af2b7264a32 (diff) | |
download | gitlab-ce-365670d814bf57396a9ce02190fa297d15c79cb9.tar.gz |
Merge branch 'dm-parallel-diff-unchanged-line-comment' into 'master'
Don't display comment on unchanged line on both sides in parallel diff
Closes #33864
See merge request !12275
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/diff/line.rb | 20 | ||||
-rw-r--r-- | lib/gitlab/diff/parallel_diff.rb | 20 |
2 files changed, 20 insertions, 20 deletions
diff --git a/lib/gitlab/diff/line.rb b/lib/gitlab/diff/line.rb index bd52ae47e9f..2d89ccfc354 100644 --- a/lib/gitlab/diff/line.rb +++ b/lib/gitlab/diff/line.rb @@ -42,25 +42,25 @@ module Gitlab end def added? - type == 'new' || type == 'new-nonewline' + %w[new new-nonewline].include?(type) end def removed? - type == 'old' || type == 'old-nonewline' - end - - def rich_text - @parent_file.highlight_lines! if @parent_file && !@rich_text - - @rich_text + %w[old old-nonewline].include?(type) end def meta? - type == 'match' + %w[match new-nonewline old-nonewline].include?(type) end def discussable? - !['match', 'new-nonewline', 'old-nonewline'].include?(type) + !meta? + end + + def rich_text + @parent_file.highlight_lines! if @parent_file && !@rich_text + + @rich_text end def as_json(opts = nil) diff --git a/lib/gitlab/diff/parallel_diff.rb b/lib/gitlab/diff/parallel_diff.rb index 481536a380b..0cb26fa45c8 100644 --- a/lib/gitlab/diff/parallel_diff.rb +++ b/lib/gitlab/diff/parallel_diff.rb @@ -14,16 +14,7 @@ module Gitlab lines = [] highlighted_diff_lines = diff_file.highlighted_diff_lines highlighted_diff_lines.each do |line| - if line.meta? || line.unchanged? - # line in the right panel is the same as in the left one - lines << { - left: line, - right: line - } - - free_right_index = nil - i += 1 - elsif line.removed? + if line.removed? lines << { left: line, right: nil @@ -51,6 +42,15 @@ module Gitlab free_right_index = nil i += 1 end + elsif line.meta? || line.unchanged? + # line in the right panel is the same as in the left one + lines << { + left: line, + right: line + } + + free_right_index = nil + i += 1 end end |