Commit 646c8c4f authored by Robert Speicher's avatar Robert Speicher

Skip remote mirror fetch when using ls-remote

When the `gitaly_ruby_remote_branches_ls_remote` feature flag is
enabled, Gitaly will gather remote branches from the mirror via
`ls-remote`, so a fetch is unnecessary.

See https://gitlab.com/gitlab-org/gitaly/-/issues/2670.
parent f5bfe560
......@@ -27,7 +27,11 @@ module Projects
remote_mirror.update_start!
remote_mirror.ensure_remote!
repository.fetch_remote(remote_mirror.remote_name, ssh_auth: remote_mirror, no_tags: true)
# https://gitlab.com/gitlab-org/gitaly/-/issues/2670
if Feature.disabled?(:gitaly_ruby_remote_branches_ls_remote)
repository.fetch_remote(remote_mirror.remote_name, ssh_auth: remote_mirror, no_tags: true)
end
response = remote_mirror.update_repository
......
......@@ -10,6 +10,10 @@ describe Projects::UpdateRemoteMirrorService do
subject(:service) { described_class.new(project, project.creator) }
before do
stub_feature_flags(gitaly_ruby_remote_branches_ls_remote: false)
end
describe '#execute' do
subject(:execute!) { service.execute(remote_mirror, 0) }
......@@ -102,6 +106,19 @@ describe Projects::UpdateRemoteMirrorService do
expect(remote_mirror.last_error).to include("refs/heads/develop")
end
end
# https://gitlab.com/gitlab-org/gitaly/-/issues/2670
context 'when `gitaly_ruby_remote_branches_ls_remote` is enabled' do
before do
stub_feature_flags(gitaly_ruby_remote_branches_ls_remote: true)
end
it 'does not perform a fetch' do
expect(project.repository).not_to receive(:fetch_remote)
execute!
end
end
end
def stub_fetch_remote(project, remote_name:, ssh_auth:)
......
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