Fix following with multiple paths

`git log --follow` is only supported for a single path. CE doesn't currently
pass multiple paths, but EE does.
This commit is contained in:
Sean McGivern 2017-04-17 13:58:07 +01:00
parent eeaeb2752a
commit 2545f6adbf
2 changed files with 22 additions and 1 deletions

View File

@ -109,7 +109,7 @@ class Repository
offset: offset,
after: after,
before: before,
follow: path.present?,
follow: Array(path).length == 1,
skip_merges: skip_merges
}

View File

@ -171,6 +171,27 @@ describe Repository, models: true do
end
end
describe '#commits' do
it 'sets follow when path is a single path' do
expect(Gitlab::Git::Commit).to receive(:where).with(a_hash_including(follow: true)).and_call_original.twice
repository.commits('master', path: 'README.md')
repository.commits('master', path: ['README.md'])
end
it 'does not set follow when path is multiple paths' do
expect(Gitlab::Git::Commit).to receive(:where).with(a_hash_including(follow: false)).and_call_original
repository.commits('master', path: ['README.md', 'CHANGELOG'])
end
it 'does not set follow when there are no paths' do
expect(Gitlab::Git::Commit).to receive(:where).with(a_hash_including(follow: false)).and_call_original
repository.commits('master')
end
end
describe '#find_commits_by_message' do
it 'returns commits with messages containing a given string' do
commit_ids = repository.find_commits_by_message('submodule').map(&:id)