Commit 6316a420 authored by Patrick Bajao's avatar Patrick Bajao

Merge branch...

Merge branch '334273-when-not-showing-whitespace-changes-renamed-files-are-not-properly-identified-in-mr-diffs' into 'master'

Resolve "When not showing whitespace changes, renamed files are not properly identified in MR Diffs"

See merge request gitlab-org/gitlab!66873
parents abad6679 89a8c4f9
......@@ -395,10 +395,10 @@ class MergeRequestDiff < ApplicationRecord
if comparison
if diff_options[:paths].blank? && !without_files?
# Return the empty MergeRequestDiffBatch for an out of bound batch request
break diffs_batch if diffs_batch.diff_file_paths.blank?
break diffs_batch if diffs_batch.diff_paths.blank?
diff_options.merge!(
paths: diffs_batch.diff_file_paths,
paths: diffs_batch.diff_paths,
pagination_data: diffs_batch.pagination_data
)
end
......
......@@ -43,10 +43,16 @@ module Gitlab
end
end
# This is either the new path, otherwise the old path for the diff_file
def diff_file_paths
diff_files.map(&:file_path)
end
# This is both the new and old paths for the diff_file
def diff_paths
diff_files.map(&:paths).flatten.uniq
end
def pagination_data
@pagination_data || empty_pagination_data
end
......
......@@ -465,11 +465,13 @@ RSpec.describe MergeRequestDiff do
it 'sorts diff files directory first' do
diff_with_commits.update!(sorted: false) # Mark as unsorted so it'll re-order
expect(diff_with_commits.diffs_in_batch(0, 10, diff_options: diff_options).diff_file_paths).to eq([
# There will be 11 returned, as we have to take into account for new and old paths
expect(diff_with_commits.diffs_in_batch(0, 10, diff_options: diff_options).diff_paths).to eq([
'bar/branch-test.txt',
'custom-highlighting/test.gitlab-custom',
'encoding/iso8859.txt',
'files/images/wm.svg',
'files/js/commit.js.coffee',
'files/js/commit.coffee',
'files/lfs/lfs_object.iso',
'files/ruby/popen.rb',
......@@ -553,11 +555,12 @@ RSpec.describe MergeRequestDiff do
it 'sorts diff files directory first' do
diff_with_commits.update!(sorted: false) # Mark as unsorted so it'll re-order
expect(diff_with_commits.diffs(diff_options).diff_file_paths).to eq([
expect(diff_with_commits.diffs(diff_options).diff_paths).to eq([
'bar/branch-test.txt',
'custom-highlighting/test.gitlab-custom',
'encoding/iso8859.txt',
'files/images/wm.svg',
'files/js/commit.js.coffee',
'files/js/commit.coffee',
'files/lfs/lfs_object.iso',
'files/ruby/popen.rb',
......
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