diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb index 6cae0fc1780548dab7d0c84e0c6b788a239c72f2..ed45d3eb0306d894330d1610ee8f7cce56ef645a 100644 --- a/lib/gitlab/git/repository.rb +++ b/lib/gitlab/git/repository.rb @@ -518,13 +518,15 @@ def diff_stats(left_id, right_id) empty_diff_stats end - def find_changed_paths(commits) + def find_changed_paths(commits, merge_commit_diff_mode: nil) processed_commits = commits.reject { |ref| ref.blank? || Gitlab::Git.blank_ref?(ref) } return [] if processed_commits.empty? wrapped_gitaly_errors do - gitaly_commit_client.find_changed_paths(processed_commits) + gitaly_commit_client.find_changed_paths( + processed_commits, merge_commit_diff_mode: merge_commit_diff_mode + ) end rescue CommandError, TypeError, NoRepository [] diff --git a/spec/lib/gitlab/git/repository_spec.rb b/spec/lib/gitlab/git/repository_spec.rb index 5e3b136cf2e53402539c68019d4841c18642ac58..b137157f2d5d6d93f96d5c44e6f7dda2a69b0da3 100644 --- a/spec/lib/gitlab/git/repository_spec.rb +++ b/spec/lib/gitlab/git/repository_spec.rb @@ -1675,6 +1675,41 @@ def create_commit(blobs) expect(collection).to be_a(Enumerable) expect(collection.to_a).to be_empty end + + describe 'merge_commit_diff_mode argument' do + let(:gitaly_commit_client) { double('Gitlab::GitalyClient::CommitService') } + + before do + allow(repository).to receive(:gitaly_commit_client).and_return(gitaly_commit_client) + allow(gitaly_commit_client).to receive(:find_changed_paths) + end + + context 'when omitted' do + before do + repository.find_changed_paths(['sha']) + end + + it 'defaults to nil' do + expect(gitaly_commit_client) + .to have_received(:find_changed_paths) + .with(['sha'], merge_commit_diff_mode: nil) + end + end + + context 'when included' do + let(:passed_value) { 'foobar' } + + before do + repository.find_changed_paths(['sha'], merge_commit_diff_mode: passed_value) + end + + it 'passes the value on to the commit client' do + expect(gitaly_commit_client) + .to have_received(:find_changed_paths) + .with(['sha'], merge_commit_diff_mode: passed_value) + end + end + end end describe "#ls_files" do