Commit f5a058ee authored by Patrick Steinhardt's avatar Patrick Steinhardt

gitaly_client: Implement `#list_commits()` RPC wrapper

Implement a wrapper for the new `ListCommits()` RPC introduced in Gitaly
v14.0-rc3. This new RPC can take a set of revisions including the pseudo
revisions `--not` and `--all` and is thus slated to deprecate some of
the existing RPC calls which list commits.
parent 42fc5b5f
......@@ -472,7 +472,7 @@ end
gem 'spamcheck', '~> 0.1.0'
# Gitaly GRPC protocol definitions
gem 'gitaly', '~> 14.1.0.pre.rc2'
gem 'gitaly', '~> 14.1.0.pre.rc3'
# KAS GRPC protocol definitions
gem 'kas-grpc', '~> 0.0.2'
......
......@@ -460,7 +460,7 @@ GEM
rails (>= 3.2.0)
git (1.7.0)
rchardet (~> 1.8)
gitaly (14.1.0.pre.rc2)
gitaly (14.1.0.pre.rc3)
grpc (~> 1.0)
github-markup (1.7.0)
gitlab (4.16.1)
......@@ -1485,7 +1485,7 @@ DEPENDENCIES
gettext (~> 3.3)
gettext_i18n_rails (~> 1.8.0)
gettext_i18n_rails_js (~> 1.3)
gitaly (~> 14.1.0.pre.rc2)
gitaly (~> 14.1.0.pre.rc3)
github-markup (~> 1.7.0)
gitlab-chronic (~> 0.10.5)
gitlab-dangerfiles (~> 2.1.2)
......
......@@ -248,6 +248,16 @@ module Gitlab
consume_commits_response(response)
end
def list_commits(revisions)
request = Gitaly::ListCommitsRequest.new(
repository: @gitaly_repo,
revisions: Array.wrap(revisions)
)
response = GitalyClient.call(@repository.storage, :commit_service, :list_commits, request, timeout: GitalyClient.medium_timeout)
consume_commits_response(response)
end
def list_commits_by_oid(oids)
return [] if oids.empty?
......
......@@ -287,6 +287,39 @@ RSpec.describe Gitlab::GitalyClient::CommitService do
end
end
describe '#list_commits' do
shared_examples 'a ListCommits request' do
before do
::Gitlab::GitalyClient.clear_stubs!
end
it 'sends a list_commits message' do
expect_next_instance_of(Gitaly::CommitService::Stub) do |service|
expect(service)
.to receive(:list_commits)
.with(gitaly_request_with_params(expected_params), kind_of(Hash))
.and_return([])
end
client.list_commits(revisions)
end
end
context 'with a single revision' do
let(:revisions) { 'master' }
let(:expected_params) { %w[master] }
it_behaves_like 'a ListCommits request'
end
context 'with multiple revisions' do
let(:revisions) { %w[master --not --all] }
let(:expected_params) { %w[master --not --all] }
it_behaves_like 'a ListCommits request'
end
end
describe '#commit_stats' do
let(:request) do
Gitaly::CommitStatsRequest.new(
......
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