Commit e4a9b077 authored by Zeger-Jan van de Weg's avatar Zeger-Jan van de Weg

ListCommitByOid isn't called with an empty batch

Batching commits for performance improvements, might lead to empty
batches being used. This isn't the case yet, but to guard against this
in future cases, a guard clause is added.
parent 7fc47fae
......@@ -179,6 +179,8 @@ module Gitlab
end
def list_commits_by_oid(oids)
return [] if oids.empty?
request = Gitaly::ListCommitsByOidRequest.new(repository: @gitaly_repo, oid: oids)
response = GitalyClient.call(@repository.storage, :commit_service, :list_commits_by_oid, request, timeout: GitalyClient.medium_timeout)
......
......@@ -421,6 +421,16 @@ describe Gitlab::Git::Commit, seed_helper: true do
end
end
describe '#batch_by_oid' do
context 'when oids is empty' do
it 'makes no Gitaly request' do
expect(Gitlab::GitalyClient).not_to receive(:call)
described_class.batch_by_oid(repository, [])
end
end
end
shared_examples 'extracting commit signature' do
context 'when the commit is signed' do
let(:commit_id) { '0b4bc9a49b562e85de7cc9e834518ea6828729b9' }
......
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