diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2018-07-03 08:21:08 +0000 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2018-07-03 08:21:08 +0000 |
commit | a65fec0b0b36879960d92cef337d0f3094a7275a (patch) | |
tree | 4c4cf0ff8ed9a7b240fd3b80fb8e781030d70fc5 | |
parent | 275fbf24b1810e2fbef92b6599d5372855b97b46 (diff) | |
parent | 26a8472d6d0aa1eb40285105a0f55f2f7d439897 (diff) | |
download | gitlab-ce-a65fec0b0b36879960d92cef337d0f3094a7275a.tar.gz |
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
-rw-r--r-- | changelogs/unreleased/jprovazn-extra-line.yml | 5 | ||||
-rw-r--r-- | lib/gitlab/diff/file.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/diff/file_spec.rb | 15 |
3 files changed, 21 insertions, 1 deletions
diff --git a/changelogs/unreleased/jprovazn-extra-line.yml b/changelogs/unreleased/jprovazn-extra-line.yml new file mode 100644 index 00000000000..2628620f8ec --- /dev/null +++ b/changelogs/unreleased/jprovazn-extra-line.yml @@ -0,0 +1,5 @@ +--- +title: Don't show context button for diffs of deleted files. +merge_request: +author: +type: fixed diff --git a/lib/gitlab/diff/file.rb b/lib/gitlab/diff/file.rb index 40bcfa20e7d..a9e209d5b71 100644 --- a/lib/gitlab/diff/file.rb +++ b/lib/gitlab/diff/file.rb @@ -250,7 +250,7 @@ module Gitlab 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) lines.push(match_line) end diff --git a/spec/lib/gitlab/diff/file_spec.rb b/spec/lib/gitlab/diff/file_spec.rb index 5dfbb8e71f8..ebeb05d6e02 100644 --- a/spec/lib/gitlab/diff/file_spec.rb +++ b/spec/lib/gitlab/diff/file_spec.rb @@ -26,6 +26,21 @@ describe Gitlab::Diff::File do 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 it { expect(diff_file.mode_changed?).to be_falsey } end |