Commit ebab4f48 authored by Patrick Steinhardt's avatar Patrick Steinhardt

gitaly_client: Reimplement `#between` via `#list_commits`

The CommitsBetween RPC call has been deprecated by Gitaly in favor of
ListCommits, which is a much more flexible alternative which allows the
caller to specify a set of revisions and various other parameters.
Reimplement `#between` on top of `#list_commits` such that Gitaly can
eventually drop CommitsBetween.

Note that instead of using the range-notation "fromrev..torev", we use
its equivalent spelling "^fromrev torev". See also the gitrevisions(7)
man page.
parent 0b143a90
---
name: between_commits_via_list_commits
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/74273
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/345458
milestone: '14.5'
type: development
group: group::gitaly
default_enabled: false
......@@ -205,6 +205,8 @@ module Gitlab
end
def between(from, to)
return list_commits(["^" + from, to], reverse: true) if Feature.enabled?(:between_commits_via_list_commits)
request = Gitaly::CommitsBetweenRequest.new(
repository: @gitaly_repo,
from: from,
......
......@@ -112,6 +112,28 @@ RSpec.describe Gitlab::GitalyClient::CommitService do
let(:from) { 'master' }
let(:to) { Gitlab::Git::EMPTY_TREE_ID }
context 'with between_commits_via_list_commits enabled' do
before do
stub_feature_flags(between_commits_via_list_commits: true)
end
it 'sends an RPC request' do
request = Gitaly::ListCommitsRequest.new(
repository: repository_message, revisions: ["^" + from, to], reverse: true
)
expect_any_instance_of(Gitaly::CommitService::Stub).to receive(:list_commits)
.with(request, kind_of(Hash)).and_return([])
described_class.new(repository).between(from, to)
end
end
context 'with between_commits_via_list_commits disabled' do
before do
stub_feature_flags(between_commits_via_list_commits: false)
end
it 'sends an RPC request' do
request = Gitaly::CommitsBetweenRequest.new(
repository: repository_message, from: from, to: to
......@@ -123,6 +145,7 @@ RSpec.describe Gitlab::GitalyClient::CommitService do
described_class.new(repository).between(from, to)
end
end
end
describe '#diff_stats' do
let(:left_commit_id) { 'master' }
......
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