Commit a65fec0b authored by Sean McGivern's avatar Sean McGivern

Merge branch 'jprovazn-extra-line' into 'master'

Don't add bottom 'match' line for deleted files

Closes #48160

See merge request gitlab-org/gitlab-ce!20255
parents 275fbf24 26a8472d
---
title: Don't show context button for diffs of deleted files.
merge_request:
author:
type: fixed
...@@ -250,7 +250,7 @@ module Gitlab ...@@ -250,7 +250,7 @@ module Gitlab
last_line = lines.last last_line = lines.last
if last_line.new_pos < total_blob_lines(blob) if last_line.new_pos < total_blob_lines(blob) && !deleted_file?
match_line = Gitlab::Diff::Line.new("", 'match', nil, last_line.old_pos, last_line.new_pos) match_line = Gitlab::Diff::Line.new("", 'match', nil, last_line.old_pos, last_line.new_pos)
lines.push(match_line) lines.push(match_line)
end end
......
...@@ -26,6 +26,21 @@ describe Gitlab::Diff::File do ...@@ -26,6 +26,21 @@ describe Gitlab::Diff::File do
end end
end end
describe '#diff_lines_for_serializer' do
it 'includes bottom match line if not in the end' do
expect(diff_file.diff_lines_for_serializer.last.type).to eq('match')
end
context 'when deleted' do
let(:commit) { project.commit('d59c60028b053793cecfb4022de34602e1a9218e') }
let(:diff_file) { commit.diffs.diff_file_with_old_path('files/js/commit.js.coffee') }
it 'does not include bottom match line' do
expect(diff_file.diff_lines_for_serializer.last.type).not_to eq('match')
end
end
end
describe '#mode_changed?' do describe '#mode_changed?' do
it { expect(diff_file.mode_changed?).to be_falsey } it { expect(diff_file.mode_changed?).to be_falsey }
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment