Don't synchronize default branch when updating a SSH mirror

Disable the default branch update if SSH project mirrors are
being used for now, since it is affecting GitLab.com users
parent 23a57022
......@@ -63,9 +63,20 @@ module Projects
# Update the default branch querying the remote to determine its HEAD
def update_root_ref
# Fetch remote default branch doesn't work with SSH mirrors:
# https://gitlab.com/gitlab-org/gitaly/issues/1363
return if ssh_mirror?
project.update_root_ref(::Repository::MIRROR_REMOTE)
end
def ssh_mirror?
uri = Addressable::URI.parse(project.import_url)
uri.scheme.present? && uri.scheme == 'ssh'
rescue Addressable::URI::InvalidURIError
false
end
def update_tags(&block)
old_tags = repository_tags_with_target.each_with_object({}) { |tag, tags| tags[tag.name] = tag }
......
---
title: Don't synchronize default branch when updating a SSH mirror
merge_request: 7891
author:
type: fixed
......@@ -209,6 +209,7 @@ describe Projects::UpdateMirrorService do
end
end
context 'synchronize the default branch' do
it 'updates the default branch when HEAD has changed' do
stub_fetch_mirror(project)
stub_find_remote_root_ref(project, ref: 'new-branch')
......@@ -223,6 +224,17 @@ describe Projects::UpdateMirrorService do
expect { service.execute }.not_to change { project.default_branch }
end
it 'does not update the default branch with SSH mirrors' do
project.update(import_url: 'ssh://git@example.com/foo/bar.git')
expect(project.repository)
.not_to receive(:find_remote_root_ref)
.with('upstream')
service.execute
end
end
it "fails when the mirror user doesn't have access" do
stub_fetch_mirror(project)
stub_find_remote_root_ref(project)
......
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