Commit b6602573 authored by Igor Drozdov's avatar Igor Drozdov

Merge branch '209786-stream-diff-stats-gitaly-call' into 'master'

Use the stream_call method when using the Gitaly Client for querying Diff Stats

See merge request gitlab-org/gitlab!33606
parents b7fc4b31 561dc293
......@@ -212,8 +212,9 @@ module Gitlab
right_commit_id: right_commit_sha
)
response = GitalyClient.call(@repository.storage, :diff_service, :diff_stats, request, timeout: GitalyClient.medium_timeout)
response.flat_map(&:stats)
GitalyClient.streaming_call(@repository.storage, :diff_service, :diff_stats, request, timeout: GitalyClient.medium_timeout) do |response|
response.flat_map(&:stats)
end
end
def find_all_commits(opts = {})
......
......@@ -124,15 +124,20 @@ describe Gitlab::GitalyClient::CommitService do
let(:left_commit_id) { 'master' }
let(:right_commit_id) { 'cfe32cf61b73a0d5e9f13e774abde7ff789b1660' }
it 'sends an RPC request' do
it 'sends an RPC request and returns the stats' do
request = Gitaly::DiffStatsRequest.new(repository: repository_message,
left_commit_id: left_commit_id,
right_commit_id: right_commit_id)
diff_stat_response = Gitaly::DiffStatsResponse.new(
stats: [{ additions: 1, deletions: 2, path: 'test' }])
expect_any_instance_of(Gitaly::DiffService::Stub).to receive(:diff_stats)
.with(request, kind_of(Hash)).and_return([])
.with(request, kind_of(Hash)).and_return([diff_stat_response])
returned_value = described_class.new(repository).diff_stats(left_commit_id, right_commit_id)
described_class.new(repository).diff_stats(left_commit_id, right_commit_id)
expect(returned_value).to eq(diff_stat_response.stats)
end
end
......
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