summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean McGivern <sean@gitlab.com>2017-04-17 13:58:07 +0100
committerSean McGivern <sean@gitlab.com>2017-04-17 14:56:45 +0100
commit2545f6adbfb6977a2d677805b3b04256103573ca (patch)
treeb940b76d47f7e8909365fd2a0ddcf9c91ac8f4bb
parenteeaeb2752a589c9046659d58d4a3f6be8030b699 (diff)
downloadgitlab-ce-fix-follow-with-multiple-paths.tar.gz
Fix following with multiple pathsfix-follow-with-multiple-paths
`git log --follow` is only supported for a single path. CE doesn't currently pass multiple paths, but EE does.
-rw-r--r--app/models/repository.rb2
-rw-r--r--spec/models/repository_spec.rb21
2 files changed, 22 insertions, 1 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb
index 2b11ed6128e..ec7acc6b6f7 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -109,7 +109,7 @@ class Repository
offset: offset,
after: after,
before: before,
- follow: path.present?,
+ follow: Array(path).length == 1,
skip_merges: skip_merges
}
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb
index 5e5c2b016b6..cbf2fc4a91b 100644
--- a/spec/models/repository_spec.rb
+++ b/spec/models/repository_spec.rb
@@ -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)