Commit 060cf16a authored by Patrick Steinhardt's avatar Patrick Steinhardt

repository: Drop remote name parameters

Starting with f1ef0bd0 (flags: Drop `fetch_remote_params` feature
flag, 2021-07-21), GitLab doesn't use the remote name anymore given that
we always use in-memory remotes.

Clean up all callsites to not pass a remote name anymore.
parent 9a177f6a
...@@ -938,8 +938,8 @@ class Repository ...@@ -938,8 +938,8 @@ class Repository
end end
end end
def fetch_as_mirror(url, forced: false, refmap: :all_refs, remote_name: nil, prune: true) def fetch_as_mirror(url, forced: false, refmap: :all_refs, prune: true)
fetch_remote(remote_name, url: url, refmap: refmap, forced: forced, prune: prune) fetch_remote(url, refmap: refmap, forced: forced, prune: prune)
end end
def fetch_source_branch!(source_repository, source_branch, local_ref) def fetch_source_branch!(source_repository, source_branch, local_ref)
......
...@@ -35,8 +35,7 @@ module EE ...@@ -35,8 +35,7 @@ module EE
def fetch_upstream(url, forced: false, check_tags_changed: false) def fetch_upstream(url, forced: false, check_tags_changed: false)
fetch_remote( fetch_remote(
MIRROR_REMOTE, url,
url: url,
refmap: ["+refs/heads/*:refs/remotes/#{MIRROR_REMOTE}/*"], refmap: ["+refs/heads/*:refs/remotes/#{MIRROR_REMOTE}/*"],
ssh_auth: project&.import_data, ssh_auth: project&.import_data,
forced: forced, forced: forced,
...@@ -96,8 +95,8 @@ module EE ...@@ -96,8 +95,8 @@ module EE
end end
# Update the default branch querying the remote to determine its HEAD # Update the default branch querying the remote to determine its HEAD
def update_root_ref(remote, remote_url, authorization) def update_root_ref(remote_url, authorization)
root_ref = find_remote_root_ref(remote, remote_url, authorization) root_ref = find_remote_root_ref(remote_url, authorization)
change_head(root_ref) if root_ref.present? change_head(root_ref) if root_ref.present?
rescue ::Gitlab::Git::Repository::NoRepository => e rescue ::Gitlab::Git::Repository::NoRepository => e
::Gitlab::AppLogger.error("Error updating root ref for repository #{full_path} (#{container.id}): #{e.message}.") ::Gitlab::AppLogger.error("Error updating root ref for repository #{full_path} (#{container.id}): #{e.message}.")
......
...@@ -15,7 +15,6 @@ module Geo ...@@ -15,7 +15,6 @@ module Geo
delegate :registry, to: :replicator delegate :registry, to: :replicator
GEO_REMOTE_NAME = 'geo'
LEASE_TIMEOUT = 8.hours LEASE_TIMEOUT = 8.hours
LEASE_KEY_PREFIX = 'geo_sync_ssf_service' LEASE_KEY_PREFIX = 'geo_sync_ssf_service'
RETRIES_BEFORE_REDOWNLOAD = 5 RETRIES_BEFORE_REDOWNLOAD = 5
...@@ -113,7 +112,7 @@ module Geo ...@@ -113,7 +112,7 @@ module Geo
def fetch_geo_mirror(repository) def fetch_geo_mirror(repository)
# Fetch the repository, using a JWT header for authentication # Fetch the repository, using a JWT header for authentication
repository.with_config(replicator.jwt_authentication_header) do repository.with_config(replicator.jwt_authentication_header) do
repository.fetch_as_mirror(replicator.remote_url, remote_name: GEO_REMOTE_NAME, forced: true) repository.fetch_as_mirror(replicator.remote_url, forced: true)
end end
end end
...@@ -265,7 +264,7 @@ module Geo ...@@ -265,7 +264,7 @@ module Geo
scope: repository.full_path scope: repository.full_path
).authorization ).authorization
repository.update_root_ref(GEO_REMOTE_NAME, replicator.remote_url, authorization) repository.update_root_ref(replicator.remote_url, authorization)
end end
end end
end end
...@@ -15,7 +15,6 @@ module Geo ...@@ -15,7 +15,6 @@ module Geo
attr_reader :project attr_reader :project
GEO_REMOTE_NAME = 'geo'
LEASE_TIMEOUT = 8.hours LEASE_TIMEOUT = 8.hours
LEASE_KEY_PREFIX = 'geo_sync_service' LEASE_KEY_PREFIX = 'geo_sync_service'
...@@ -97,7 +96,7 @@ module Geo ...@@ -97,7 +96,7 @@ module Geo
def fetch_geo_mirror(repository) def fetch_geo_mirror(repository)
# Fetch the repository, using a JWT header for authentication # Fetch the repository, using a JWT header for authentication
repository.with_config(jwt_authentication_header) do repository.with_config(jwt_authentication_header) do
repository.fetch_as_mirror(remote_url, remote_name: GEO_REMOTE_NAME, forced: true) repository.fetch_as_mirror(remote_url, forced: true)
end end
end end
......
...@@ -54,7 +54,7 @@ module Geo ...@@ -54,7 +54,7 @@ module Geo
scope: repository.full_path scope: repository.full_path
).authorization ).authorization
repository.update_root_ref(GEO_REMOTE_NAME, remote_url, authorization) repository.update_root_ref(remote_url, authorization)
end end
def execute_housekeeping def execute_housekeeping
......
...@@ -55,7 +55,7 @@ RSpec.describe Repository do ...@@ -55,7 +55,7 @@ RSpec.describe Repository do
it 'fetches the URL without creating a remote' do it 'fetches the URL without creating a remote' do
expect(repository) expect(repository)
.to receive(:fetch_remote) .to receive(:fetch_remote)
.with(described_class::MIRROR_REMOTE, url: url, refmap: ['+refs/heads/*:refs/remotes/upstream/*'], ssh_auth: nil, forced: true, check_tags_changed: true) .with(url, refmap: ['+refs/heads/*:refs/remotes/upstream/*'], ssh_auth: nil, forced: true, check_tags_changed: true)
.and_return(nil) .and_return(nil)
repository.fetch_upstream(url, forced: true, check_tags_changed: true) repository.fetch_upstream(url, forced: true, check_tags_changed: true)
...@@ -250,7 +250,7 @@ RSpec.describe Repository do ...@@ -250,7 +250,7 @@ RSpec.describe Repository do
it 'updates the default branch when HEAD has changed' do it 'updates the default branch when HEAD has changed' do
stub_find_remote_root_ref(repository, ref: 'feature') stub_find_remote_root_ref(repository, ref: 'feature')
expect { repository.update_root_ref('origin', url, auth) } expect { repository.update_root_ref(url, auth) }
.to change { project.default_branch } .to change { project.default_branch }
.from('master') .from('master')
.to('feature') .to('feature')
...@@ -261,7 +261,7 @@ RSpec.describe Repository do ...@@ -261,7 +261,7 @@ RSpec.describe Repository do
expect(repository).to receive(:change_head).with('master').and_call_original expect(repository).to receive(:change_head).with('master').and_call_original
repository.update_root_ref('origin', url, auth) repository.update_root_ref(url, auth)
expect(project.default_branch).to eq('master') expect(project.default_branch).to eq('master')
end end
...@@ -269,22 +269,22 @@ RSpec.describe Repository do ...@@ -269,22 +269,22 @@ RSpec.describe Repository do
it 'does not update the default branch when HEAD does not exist' do it 'does not update the default branch when HEAD does not exist' do
stub_find_remote_root_ref(repository, ref: 'foo') stub_find_remote_root_ref(repository, ref: 'foo')
expect { repository.update_root_ref('origin', url, auth) } expect { repository.update_root_ref(url, auth) }
.not_to change { project.default_branch } .not_to change { project.default_branch }
end end
it 'does not raise error when repository does not exist' do it 'does not raise error when repository does not exist' do
allow(repository).to receive(:find_remote_root_ref) allow(repository).to receive(:find_remote_root_ref)
.with('origin', url, auth) .with(url, auth)
.and_raise(Gitlab::Git::Repository::NoRepository) .and_raise(Gitlab::Git::Repository::NoRepository)
expect { repository.update_root_ref('origin', url, auth) }.not_to raise_error expect { repository.update_root_ref(url, auth) }.not_to raise_error
end end
def stub_find_remote_root_ref(repository, ref:) def stub_find_remote_root_ref(repository, ref:)
allow(repository) allow(repository)
.to receive(:find_remote_root_ref) .to receive(:find_remote_root_ref)
.with('origin', url, auth) .with(url, auth)
.and_return(ref) .and_return(ref)
end end
end end
......
...@@ -40,7 +40,7 @@ RSpec.describe Geo::DesignRepositorySyncService do ...@@ -40,7 +40,7 @@ RSpec.describe Geo::DesignRepositorySyncService do
allow_any_instance_of(Repository) allow_any_instance_of(Repository)
.to receive(:find_remote_root_ref) .to receive(:find_remote_root_ref)
.with('geo') .with(url_to_repo)
.and_return('master') .and_return('master')
allow_any_instance_of(Geo::ProjectHousekeepingService).to receive(:execute) allow_any_instance_of(Geo::ProjectHousekeepingService).to receive(:execute)
...@@ -59,7 +59,7 @@ RSpec.describe Geo::DesignRepositorySyncService do ...@@ -59,7 +59,7 @@ RSpec.describe Geo::DesignRepositorySyncService do
.and_call_original .and_call_original
expect(repository).to receive(:fetch_as_mirror) expect(repository).to receive(:fetch_as_mirror)
.with(url_to_repo, remote_name: 'geo', forced: true) .with(url_to_repo, forced: true)
.once .once
subject.execute subject.execute
...@@ -81,7 +81,7 @@ RSpec.describe Geo::DesignRepositorySyncService do ...@@ -81,7 +81,7 @@ RSpec.describe Geo::DesignRepositorySyncService do
it 'rescues when Gitlab::Shell::Error is raised' do it 'rescues when Gitlab::Shell::Error is raised' do
allow(repository).to receive(:fetch_as_mirror) allow(repository).to receive(:fetch_as_mirror)
.with(url_to_repo, remote_name: 'geo', forced: true) .with(url_to_repo, forced: true)
.and_raise(Gitlab::Shell::Error) .and_raise(Gitlab::Shell::Error)
expect { subject.execute }.not_to raise_error expect { subject.execute }.not_to raise_error
...@@ -89,7 +89,7 @@ RSpec.describe Geo::DesignRepositorySyncService do ...@@ -89,7 +89,7 @@ RSpec.describe Geo::DesignRepositorySyncService do
it 'rescues exception when Gitlab::Git::Repository::NoRepository is raised' do it 'rescues exception when Gitlab::Git::Repository::NoRepository is raised' do
allow(repository).to receive(:fetch_as_mirror) allow(repository).to receive(:fetch_as_mirror)
.with(url_to_repo, remote_name: 'geo', forced: true) .with(url_to_repo, forced: true)
.and_raise(Gitlab::Git::Repository::NoRepository) .and_raise(Gitlab::Git::Repository::NoRepository)
expect { subject.execute }.not_to raise_error expect { subject.execute }.not_to raise_error
...@@ -97,7 +97,7 @@ RSpec.describe Geo::DesignRepositorySyncService do ...@@ -97,7 +97,7 @@ RSpec.describe Geo::DesignRepositorySyncService do
it 'increases retry count when Gitlab::Git::Repository::NoRepository is raised' do it 'increases retry count when Gitlab::Git::Repository::NoRepository is raised' do
allow(repository).to receive(:fetch_as_mirror) allow(repository).to receive(:fetch_as_mirror)
.with(url_to_repo, remote_name: 'geo', forced: true) .with(url_to_repo, forced: true)
.and_raise(Gitlab::Git::Repository::NoRepository) .and_raise(Gitlab::Git::Repository::NoRepository)
subject.execute subject.execute
...@@ -111,7 +111,7 @@ RSpec.describe Geo::DesignRepositorySyncService do ...@@ -111,7 +111,7 @@ RSpec.describe Geo::DesignRepositorySyncService do
registry = create(:geo_design_registry, project: project) registry = create(:geo_design_registry, project: project)
allow(repository).to receive(:fetch_as_mirror) allow(repository).to receive(:fetch_as_mirror)
.with(url_to_repo, remote_name: 'geo', forced: true) .with(url_to_repo, forced: true)
.and_raise(Gitlab::Shell::Error.new(Gitlab::GitAccessDesign::ERROR_MESSAGES[:no_repo])) .and_raise(Gitlab::Shell::Error.new(Gitlab::GitAccessDesign::ERROR_MESSAGES[:no_repo]))
subject.execute subject.execute
...@@ -128,7 +128,7 @@ RSpec.describe Geo::DesignRepositorySyncService do ...@@ -128,7 +128,7 @@ RSpec.describe Geo::DesignRepositorySyncService do
expect(Geo::DesignRegistry.last.state).to eq 'synced' expect(Geo::DesignRegistry.last.state).to eq 'synced'
allow(repository).to receive(:fetch_as_mirror) allow(repository).to receive(:fetch_as_mirror)
.with(url_to_repo, remote_name: 'geo', forced: true) .with(url_to_repo, forced: true)
.and_raise(Gitlab::Git::Repository::NoRepository) .and_raise(Gitlab::Git::Repository::NoRepository)
subject.execute subject.execute
......
...@@ -53,7 +53,7 @@ RSpec.describe Geo::FrameworkRepositorySyncService, :geo do ...@@ -53,7 +53,7 @@ RSpec.describe Geo::FrameworkRepositorySyncService, :geo do
allow_any_instance_of(Repository) allow_any_instance_of(Repository)
.to receive(:find_remote_root_ref) .to receive(:find_remote_root_ref)
.with('geo', url_to_repo, anything) .with(url_to_repo, anything)
.and_return('master') .and_return('master')
end end
...@@ -65,7 +65,7 @@ RSpec.describe Geo::FrameworkRepositorySyncService, :geo do ...@@ -65,7 +65,7 @@ RSpec.describe Geo::FrameworkRepositorySyncService, :geo do
.and_call_original .and_call_original
expect(repository).to receive(:fetch_as_mirror) expect(repository).to receive(:fetch_as_mirror)
.with(url_to_repo, remote_name: 'geo', forced: true) .with(url_to_repo, forced: true)
.once .once
subject.execute subject.execute
...@@ -87,7 +87,7 @@ RSpec.describe Geo::FrameworkRepositorySyncService, :geo do ...@@ -87,7 +87,7 @@ RSpec.describe Geo::FrameworkRepositorySyncService, :geo do
it 'rescues when Gitlab::Shell::Error is raised' do it 'rescues when Gitlab::Shell::Error is raised' do
allow(repository).to receive(:fetch_as_mirror) allow(repository).to receive(:fetch_as_mirror)
.with(url_to_repo, remote_name: 'geo', forced: true) .with(url_to_repo, forced: true)
.and_raise(Gitlab::Shell::Error) .and_raise(Gitlab::Shell::Error)
expect { subject.execute }.not_to raise_error expect { subject.execute }.not_to raise_error
...@@ -95,7 +95,7 @@ RSpec.describe Geo::FrameworkRepositorySyncService, :geo do ...@@ -95,7 +95,7 @@ RSpec.describe Geo::FrameworkRepositorySyncService, :geo do
it 'rescues exception and fires after_create hook when Gitlab::Git::Repository::NoRepository is raised' do it 'rescues exception and fires after_create hook when Gitlab::Git::Repository::NoRepository is raised' do
allow(repository).to receive(:fetch_as_mirror) allow(repository).to receive(:fetch_as_mirror)
.with(url_to_repo, remote_name: 'geo', forced: true) .with(url_to_repo, forced: true)
.and_raise(Gitlab::Git::Repository::NoRepository) .and_raise(Gitlab::Git::Repository::NoRepository)
expect(repository).to receive(:after_create) expect(repository).to receive(:after_create)
...@@ -107,7 +107,7 @@ RSpec.describe Geo::FrameworkRepositorySyncService, :geo do ...@@ -107,7 +107,7 @@ RSpec.describe Geo::FrameworkRepositorySyncService, :geo do
registry.save! registry.save!
allow(repository).to receive(:fetch_as_mirror) allow(repository).to receive(:fetch_as_mirror)
.with(url_to_repo, remote_name: 'geo', forced: true) .with(url_to_repo, forced: true)
.and_raise(Gitlab::Git::Repository::NoRepository) .and_raise(Gitlab::Git::Repository::NoRepository)
subject.execute subject.execute
...@@ -120,7 +120,7 @@ RSpec.describe Geo::FrameworkRepositorySyncService, :geo do ...@@ -120,7 +120,7 @@ RSpec.describe Geo::FrameworkRepositorySyncService, :geo do
it 'marks sync as successful if no repository found' do it 'marks sync as successful if no repository found' do
allow(repository).to receive(:fetch_as_mirror) allow(repository).to receive(:fetch_as_mirror)
.with(url_to_repo, remote_name: 'geo', forced: true) .with(url_to_repo, forced: true)
.and_raise(Gitlab::Shell::Error.new(Gitlab::GitAccessSnippet::ERROR_MESSAGES[:no_repo])) .and_raise(Gitlab::Shell::Error.new(Gitlab::GitAccessSnippet::ERROR_MESSAGES[:no_repo]))
subject.execute subject.execute
...@@ -137,7 +137,7 @@ RSpec.describe Geo::FrameworkRepositorySyncService, :geo do ...@@ -137,7 +137,7 @@ RSpec.describe Geo::FrameworkRepositorySyncService, :geo do
expect(registry.synced?).to be true expect(registry.synced?).to be true
allow(repository).to receive(:fetch_as_mirror) allow(repository).to receive(:fetch_as_mirror)
.with(url_to_repo, remote_name: 'geo', forced: true) .with(url_to_repo, forced: true)
.and_raise(Gitlab::Git::Repository::NoRepository) .and_raise(Gitlab::Git::Repository::NoRepository)
subject.execute subject.execute
...@@ -178,7 +178,7 @@ RSpec.describe Geo::FrameworkRepositorySyncService, :geo do ...@@ -178,7 +178,7 @@ RSpec.describe Geo::FrameworkRepositorySyncService, :geo do
before do before do
allow(repository) allow(repository)
.to receive(:find_remote_root_ref) .to receive(:find_remote_root_ref)
.with('geo', url_to_repo, anything) .with(url_to_repo, anything)
.and_return('feature') .and_return('feature')
end end
...@@ -224,7 +224,7 @@ RSpec.describe Geo::FrameworkRepositorySyncService, :geo do ...@@ -224,7 +224,7 @@ RSpec.describe Geo::FrameworkRepositorySyncService, :geo do
context 'when repository sync fail' do context 'when repository sync fail' do
before do before do
allow(repository).to receive(:fetch_as_mirror) allow(repository).to receive(:fetch_as_mirror)
.with(url_to_repo, remote_name: 'geo', forced: true) .with(url_to_repo, forced: true)
.and_raise(Gitlab::Shell::Error.new('shell error')) .and_raise(Gitlab::Shell::Error.new('shell error'))
end end
......
...@@ -36,7 +36,7 @@ RSpec.describe Geo::RepositorySyncService, :geo do ...@@ -36,7 +36,7 @@ RSpec.describe Geo::RepositorySyncService, :geo do
allow_any_instance_of(Repository) allow_any_instance_of(Repository)
.to receive(:find_remote_root_ref) .to receive(:find_remote_root_ref)
.with('geo', url_to_repo, anything) .with(url_to_repo, anything)
.and_return('master') .and_return('master')
allow_any_instance_of(Geo::ProjectHousekeepingService).to receive(:execute) allow_any_instance_of(Geo::ProjectHousekeepingService).to receive(:execute)
...@@ -51,7 +51,7 @@ RSpec.describe Geo::RepositorySyncService, :geo do ...@@ -51,7 +51,7 @@ RSpec.describe Geo::RepositorySyncService, :geo do
.and_call_original .and_call_original
expect(repository).to receive(:fetch_as_mirror) expect(repository).to receive(:fetch_as_mirror)
.with(url_to_repo, remote_name: 'geo', forced: true) .with(url_to_repo, forced: true)
.once .once
subject.execute subject.execute
...@@ -73,7 +73,7 @@ RSpec.describe Geo::RepositorySyncService, :geo do ...@@ -73,7 +73,7 @@ RSpec.describe Geo::RepositorySyncService, :geo do
it 'rescues when Gitlab::Shell::Error is raised' do it 'rescues when Gitlab::Shell::Error is raised' do
allow(repository).to receive(:fetch_as_mirror) allow(repository).to receive(:fetch_as_mirror)
.with(url_to_repo, remote_name: 'geo', forced: true) .with(url_to_repo, forced: true)
.and_raise(Gitlab::Shell::Error) .and_raise(Gitlab::Shell::Error)
expect { subject.execute }.not_to raise_error expect { subject.execute }.not_to raise_error
...@@ -81,7 +81,7 @@ RSpec.describe Geo::RepositorySyncService, :geo do ...@@ -81,7 +81,7 @@ RSpec.describe Geo::RepositorySyncService, :geo do
it 'rescues exception and fires after_create hook when Gitlab::Git::Repository::NoRepository is raised' do it 'rescues exception and fires after_create hook when Gitlab::Git::Repository::NoRepository is raised' do
allow(repository).to receive(:fetch_as_mirror) allow(repository).to receive(:fetch_as_mirror)
.with(url_to_repo, remote_name: 'geo', forced: true) .with(url_to_repo, forced: true)
.and_raise(Gitlab::Git::Repository::NoRepository) .and_raise(Gitlab::Git::Repository::NoRepository)
expect(repository).to receive(:after_create) expect(repository).to receive(:after_create)
...@@ -91,7 +91,7 @@ RSpec.describe Geo::RepositorySyncService, :geo do ...@@ -91,7 +91,7 @@ RSpec.describe Geo::RepositorySyncService, :geo do
it 'increases retry count when Gitlab::Git::Repository::NoRepository is raised' do it 'increases retry count when Gitlab::Git::Repository::NoRepository is raised' do
allow(repository).to receive(:fetch_as_mirror) allow(repository).to receive(:fetch_as_mirror)
.with(url_to_repo, remote_name: 'geo', forced: true) .with(url_to_repo, forced: true)
.and_raise(Gitlab::Git::Repository::NoRepository) .and_raise(Gitlab::Git::Repository::NoRepository)
subject.execute subject.execute
...@@ -106,7 +106,7 @@ RSpec.describe Geo::RepositorySyncService, :geo do ...@@ -106,7 +106,7 @@ RSpec.describe Geo::RepositorySyncService, :geo do
registry = create(:geo_project_registry, project: project) registry = create(:geo_project_registry, project: project)
allow(repository).to receive(:fetch_as_mirror) allow(repository).to receive(:fetch_as_mirror)
.with(url_to_repo, remote_name: 'geo', forced: true) .with(url_to_repo, forced: true)
.and_raise(Gitlab::Shell::Error.new(Gitlab::GitAccess::ERROR_MESSAGES[:no_repo])) .and_raise(Gitlab::Shell::Error.new(Gitlab::GitAccess::ERROR_MESSAGES[:no_repo]))
subject.execute subject.execute
...@@ -124,7 +124,7 @@ RSpec.describe Geo::RepositorySyncService, :geo do ...@@ -124,7 +124,7 @@ RSpec.describe Geo::RepositorySyncService, :geo do
expect(Geo::ProjectRegistry.last.resync_repository).to be false expect(Geo::ProjectRegistry.last.resync_repository).to be false
allow(repository).to receive(:fetch_as_mirror) allow(repository).to receive(:fetch_as_mirror)
.with(url_to_repo, remote_name: 'geo', forced: true) .with(url_to_repo, forced: true)
.and_raise(Gitlab::Git::Repository::NoRepository) .and_raise(Gitlab::Git::Repository::NoRepository)
subject.execute subject.execute
...@@ -138,7 +138,7 @@ RSpec.describe Geo::RepositorySyncService, :geo do ...@@ -138,7 +138,7 @@ RSpec.describe Geo::RepositorySyncService, :geo do
create(:repository_state, :repository_verified, project: project) create(:repository_state, :repository_verified, project: project)
allow(repository).to receive(:fetch_as_mirror) allow(repository).to receive(:fetch_as_mirror)
.with(url_to_repo, remote_name: 'geo', forced: true) .with(url_to_repo, forced: true)
.and_raise(Gitlab::Shell::Error.new(Gitlab::GitAccess::ERROR_MESSAGES[:no_repo])) .and_raise(Gitlab::Shell::Error.new(Gitlab::GitAccess::ERROR_MESSAGES[:no_repo]))
subject.execute subject.execute
...@@ -237,7 +237,7 @@ RSpec.describe Geo::RepositorySyncService, :geo do ...@@ -237,7 +237,7 @@ RSpec.describe Geo::RepositorySyncService, :geo do
before do before do
allow(project.repository) allow(project.repository)
.to receive(:find_remote_root_ref) .to receive(:find_remote_root_ref)
.with('geo', url_to_repo, anything) .with(url_to_repo, anything)
.and_return('feature') .and_return('feature')
end end
...@@ -285,7 +285,7 @@ RSpec.describe Geo::RepositorySyncService, :geo do ...@@ -285,7 +285,7 @@ RSpec.describe Geo::RepositorySyncService, :geo do
before do before do
allow(repository).to receive(:fetch_as_mirror) allow(repository).to receive(:fetch_as_mirror)
.with(url_to_repo, remote_name: 'geo', forced: true) .with(url_to_repo, forced: true)
.and_raise(Gitlab::Shell::Error.new('shell error')) .and_raise(Gitlab::Shell::Error.new('shell error'))
end end
......
...@@ -39,7 +39,7 @@ RSpec.describe Geo::WikiSyncService, :geo do ...@@ -39,7 +39,7 @@ RSpec.describe Geo::WikiSyncService, :geo do
it 'fetches wiki repository with JWT credentials' do it 'fetches wiki repository with JWT credentials' do
expect(repository).to receive(:with_config).with("http.#{url_to_repo}.extraHeader" => anything).and_call_original expect(repository).to receive(:with_config).with("http.#{url_to_repo}.extraHeader" => anything).and_call_original
expect(repository).to receive(:fetch_as_mirror) expect(repository).to receive(:fetch_as_mirror)
.with(url_to_repo, remote_name: 'geo', forced: true) .with(url_to_repo, forced: true)
.once .once
subject.execute subject.execute
...@@ -53,7 +53,7 @@ RSpec.describe Geo::WikiSyncService, :geo do ...@@ -53,7 +53,7 @@ RSpec.describe Geo::WikiSyncService, :geo do
it 'rescues exception when Gitlab::Shell::Error is raised' do it 'rescues exception when Gitlab::Shell::Error is raised' do
allow(repository).to receive(:fetch_as_mirror) allow(repository).to receive(:fetch_as_mirror)
.with(url_to_repo, remote_name: 'geo', forced: true) .with(url_to_repo, forced: true)
.and_raise(Gitlab::Shell::Error) .and_raise(Gitlab::Shell::Error)
expect { subject.execute }.not_to raise_error expect { subject.execute }.not_to raise_error
...@@ -61,7 +61,7 @@ RSpec.describe Geo::WikiSyncService, :geo do ...@@ -61,7 +61,7 @@ RSpec.describe Geo::WikiSyncService, :geo do
it 'rescues exception when Gitlab::Git::Repository::NoRepository is raised' do it 'rescues exception when Gitlab::Git::Repository::NoRepository is raised' do
allow(repository).to receive(:fetch_as_mirror) allow(repository).to receive(:fetch_as_mirror)
.with(url_to_repo, remote_name: 'geo', forced: true) .with(url_to_repo, forced: true)
.and_raise(Gitlab::Git::Repository::NoRepository) .and_raise(Gitlab::Git::Repository::NoRepository)
expect { subject.execute }.not_to raise_error expect { subject.execute }.not_to raise_error
...@@ -69,7 +69,7 @@ RSpec.describe Geo::WikiSyncService, :geo do ...@@ -69,7 +69,7 @@ RSpec.describe Geo::WikiSyncService, :geo do
it 'increases retry count when Gitlab::Git::Repository::NoRepository is raised' do it 'increases retry count when Gitlab::Git::Repository::NoRepository is raised' do
allow(repository).to receive(:fetch_as_mirror) allow(repository).to receive(:fetch_as_mirror)
.with(url_to_repo, remote_name: 'geo', forced: true) .with(url_to_repo, forced: true)
.and_raise(Gitlab::Git::Repository::NoRepository) .and_raise(Gitlab::Git::Repository::NoRepository)
subject.execute subject.execute
...@@ -84,7 +84,7 @@ RSpec.describe Geo::WikiSyncService, :geo do ...@@ -84,7 +84,7 @@ RSpec.describe Geo::WikiSyncService, :geo do
registry = create(:geo_project_registry, project: project) registry = create(:geo_project_registry, project: project)
allow(repository).to receive(:fetch_as_mirror) allow(repository).to receive(:fetch_as_mirror)
.with(url_to_repo, remote_name: 'geo', forced: true) .with(url_to_repo, forced: true)
.and_raise(Gitlab::Shell::Error.new(Gitlab::GitAccessWiki::ERROR_MESSAGES[:no_repo])) .and_raise(Gitlab::Shell::Error.new(Gitlab::GitAccessWiki::ERROR_MESSAGES[:no_repo]))
subject.execute subject.execute
...@@ -100,7 +100,7 @@ RSpec.describe Geo::WikiSyncService, :geo do ...@@ -100,7 +100,7 @@ RSpec.describe Geo::WikiSyncService, :geo do
described_class.new(project).execute described_class.new(project).execute
allow(repository).to receive(:fetch_as_mirror) allow(repository).to receive(:fetch_as_mirror)
.with(url_to_repo, remote_name: 'geo', forced: true) .with(url_to_repo, forced: true)
.and_raise(Gitlab::Git::Repository::NoRepository) .and_raise(Gitlab::Git::Repository::NoRepository)
subject.execute subject.execute
...@@ -114,7 +114,7 @@ RSpec.describe Geo::WikiSyncService, :geo do ...@@ -114,7 +114,7 @@ RSpec.describe Geo::WikiSyncService, :geo do
create(:repository_state, :wiki_verified, project: project) create(:repository_state, :wiki_verified, project: project)
allow(repository).to receive(:fetch_as_mirror) allow(repository).to receive(:fetch_as_mirror)
.with(url_to_repo, remote_name: 'geo', forced: true) .with(url_to_repo, forced: true)
.and_raise(Gitlab::Shell::Error.new(Gitlab::GitAccessWiki::ERROR_MESSAGES[:no_repo])) .and_raise(Gitlab::Shell::Error.new(Gitlab::GitAccessWiki::ERROR_MESSAGES[:no_repo]))
subject.execute subject.execute
...@@ -203,7 +203,7 @@ RSpec.describe Geo::WikiSyncService, :geo do ...@@ -203,7 +203,7 @@ RSpec.describe Geo::WikiSyncService, :geo do
before do before do
allow(repository).to receive(:fetch_as_mirror) allow(repository).to receive(:fetch_as_mirror)
.with(url_to_repo, remote_name: 'geo', forced: true) .with(url_to_repo, forced: true)
.and_raise(Gitlab::Shell::Error.new('shell error')) .and_raise(Gitlab::Shell::Error.new('shell error'))
end end
......
...@@ -165,7 +165,7 @@ RSpec.shared_context 'lease handling' do ...@@ -165,7 +165,7 @@ RSpec.shared_context 'lease handling' do
it 'returns the lease when sync fail' do it 'returns the lease when sync fail' do
allow(repository).to receive(:fetch_as_mirror) allow(repository).to receive(:fetch_as_mirror)
.with(url_to_repo, remote_name: 'geo', forced: true) .with(url_to_repo, forced: true)
.and_raise(Gitlab::Shell::Error) .and_raise(Gitlab::Shell::Error)
expect_to_cancel_exclusive_lease(lease_key, lease_uuid) expect_to_cancel_exclusive_lease(lease_key, lease_uuid)
......
...@@ -7,7 +7,6 @@ module Gitlab ...@@ -7,7 +7,6 @@ module Gitlab
attr_reader :project, :project_key, :repository_slug, :client, :errors, :users, :already_imported_cache_key attr_reader :project, :project_key, :repository_slug, :client, :errors, :users, :already_imported_cache_key
attr_accessor :logger attr_accessor :logger
REMOTE_NAME = 'bitbucket_server'
BATCH_SIZE = 100 BATCH_SIZE = 100
# The base cache key to use for tracking already imported objects. # The base cache key to use for tracking already imported objects.
ALREADY_IMPORTED_CACHE_KEY = ALREADY_IMPORTED_CACHE_KEY =
...@@ -142,7 +141,7 @@ module Gitlab ...@@ -142,7 +141,7 @@ module Gitlab
log_info(stage: 'import_repository', message: 'starting import') log_info(stage: 'import_repository', message: 'starting import')
project.ensure_repository project.ensure_repository
project.repository.fetch_as_mirror(project.import_url, refmap: self.class.refmap, remote_name: REMOTE_NAME) project.repository.fetch_as_mirror(project.import_url, refmap: self.class.refmap)
log_info(stage: 'import_repository', message: 'finished import') log_info(stage: 'import_repository', message: 'finished import')
rescue Gitlab::Shell::Error => e rescue Gitlab::Shell::Error => e
......
...@@ -703,11 +703,11 @@ module Gitlab ...@@ -703,11 +703,11 @@ module Gitlab
write_ref(ref, start_point) write_ref(ref, start_point)
end end
def find_remote_root_ref(remote_name, remote_url, authorization = nil) def find_remote_root_ref(remote_url, authorization = nil)
return unless remote_name.present? && remote_url.present? return unless remote_url.present?
wrapped_gitaly_errors do wrapped_gitaly_errors do
gitaly_remote_client.find_remote_root_ref(remote_name, remote_url, authorization) gitaly_remote_client.find_remote_root_ref(remote_url, authorization)
end end
end end
...@@ -807,11 +807,10 @@ module Gitlab ...@@ -807,11 +807,10 @@ module Gitlab
# no_tags - should we use --no-tags flag? # no_tags - should we use --no-tags flag?
# prune - should we use --prune flag? # prune - should we use --prune flag?
# check_tags_changed - should we ask gitaly to calculate whether any tags changed? # check_tags_changed - should we ask gitaly to calculate whether any tags changed?
def fetch_remote(remote, url: nil, refmap: nil, ssh_auth: nil, forced: false, no_tags: false, prune: true, check_tags_changed: false) def fetch_remote(url, refmap: nil, ssh_auth: nil, forced: false, no_tags: false, prune: true, check_tags_changed: false)
wrapped_gitaly_errors do wrapped_gitaly_errors do
gitaly_repository_client.fetch_remote( gitaly_repository_client.fetch_remote(
remote, url,
url: url,
refmap: refmap, refmap: refmap,
ssh_auth: ssh_auth, ssh_auth: ssh_auth,
forced: forced, forced: forced,
......
...@@ -26,8 +26,7 @@ module Gitlab ...@@ -26,8 +26,7 @@ module Gitlab
@storage = repository.storage @storage = repository.storage
end end
# The remote_name parameter is deprecated and will be removed soon. def find_remote_root_ref(remote_url, authorization)
def find_remote_root_ref(remote_name, remote_url, authorization)
request = Gitaly::FindRemoteRootRefRequest.new(repository: @gitaly_repo, request = Gitaly::FindRemoteRootRefRequest.new(repository: @gitaly_repo,
remote_url: remote_url, remote_url: remote_url,
http_authorization_header: authorization) http_authorization_header: authorization)
......
...@@ -73,18 +73,20 @@ module Gitlab ...@@ -73,18 +73,20 @@ module Gitlab
# rubocop: disable Metrics/ParameterLists # rubocop: disable Metrics/ParameterLists
# The `remote` parameter is going away soonish anyway, at which point the # The `remote` parameter is going away soonish anyway, at which point the
# Rubocop warning can be enabled again. # Rubocop warning can be enabled again.
def fetch_remote(remote, url:, refmap:, ssh_auth:, forced:, no_tags:, timeout:, prune: true, check_tags_changed: false) def fetch_remote(url, refmap:, ssh_auth:, forced:, no_tags:, timeout:, prune: true, check_tags_changed: false)
request = Gitaly::FetchRemoteRequest.new( request = Gitaly::FetchRemoteRequest.new(
repository: @gitaly_repo, remote: remote, force: forced, repository: @gitaly_repo,
no_tags: no_tags, timeout: timeout, no_prune: !prune, force: forced,
check_tags_changed: check_tags_changed no_tags: no_tags,
timeout: timeout,
no_prune: !prune,
check_tags_changed: check_tags_changed,
remote_params: Gitaly::Remote.new(
url: url,
mirror_refmaps: Array.wrap(refmap).map(&:to_s)
)
) )
if url
request.remote_params = Gitaly::Remote.new(url: url,
mirror_refmaps: Array.wrap(refmap).map(&:to_s))
end
if ssh_auth&.ssh_mirror_url? if ssh_auth&.ssh_mirror_url?
if ssh_auth.ssh_key_auth? && ssh_auth.ssh_private_key.present? if ssh_auth.ssh_key_auth? && ssh_auth.ssh_private_key.present?
request.ssh_key = ssh_auth.ssh_private_key request.ssh_key = ssh_auth.ssh_private_key
......
...@@ -40,7 +40,7 @@ module Gitlab ...@@ -40,7 +40,7 @@ module Gitlab
# updating the timestamp. # updating the timestamp.
project.update_column(:last_repository_updated_at, Time.zone.now) project.update_column(:last_repository_updated_at, Time.zone.now)
project.repository.fetch_remote('github', url: project.import_url, refmap: Gitlab::GithubImport.refmap, forced: false) project.repository.fetch_remote(project.import_url, refmap: Gitlab::GithubImport.refmap, forced: false)
pname = project.path_with_namespace pname = project.path_with_namespace
......
...@@ -32,8 +32,7 @@ RSpec.describe Gitlab::BitbucketServerImport::Importer do ...@@ -32,8 +32,7 @@ RSpec.describe Gitlab::BitbucketServerImport::Importer do
expect(subject).to receive(:delete_temp_branches) expect(subject).to receive(:delete_temp_branches)
expect(project.repository).to receive(:fetch_as_mirror) expect(project.repository).to receive(:fetch_as_mirror)
.with('http://bitbucket:test@my-bitbucket', .with('http://bitbucket:test@my-bitbucket',
refmap: [:heads, :tags, '+refs/pull-requests/*/to:refs/merge-requests/*/head'], refmap: [:heads, :tags, '+refs/pull-requests/*/to:refs/merge-requests/*/head'])
remote_name: 'bitbucket_server')
subject.execute subject.execute
end end
......
...@@ -491,6 +491,8 @@ RSpec.describe Gitlab::Git::Repository, :seed_helper do ...@@ -491,6 +491,8 @@ RSpec.describe Gitlab::Git::Repository, :seed_helper do
end end
describe '#fetch_remote' do describe '#fetch_remote' do
let(:url) { 'http://example.clom' }
it 'delegates to the gitaly RepositoryService' do it 'delegates to the gitaly RepositoryService' do
ssh_auth = double(:ssh_auth) ssh_auth = double(:ssh_auth)
expected_opts = { expected_opts = {
...@@ -500,17 +502,17 @@ RSpec.describe Gitlab::Git::Repository, :seed_helper do ...@@ -500,17 +502,17 @@ RSpec.describe Gitlab::Git::Repository, :seed_helper do
timeout: described_class::GITLAB_PROJECTS_TIMEOUT, timeout: described_class::GITLAB_PROJECTS_TIMEOUT,
prune: false, prune: false,
check_tags_changed: false, check_tags_changed: false,
url: nil, refmap: nil,
refmap: nil http_authorization_header: ""
} }
expect(repository.gitaly_repository_client).to receive(:fetch_remote).with('remote-name', expected_opts) expect(repository.gitaly_repository_client).to receive(:fetch_remote).with(url, expected_opts)
repository.fetch_remote('remote-name', ssh_auth: ssh_auth, forced: true, no_tags: true, prune: false, check_tags_changed: false) repository.fetch_remote(url, ssh_auth: ssh_auth, forced: true, no_tags: true, prune: false, check_tags_changed: false)
end end
it_behaves_like 'wrapping gRPC errors', Gitlab::GitalyClient::RepositoryService, :fetch_remote do it_behaves_like 'wrapping gRPC errors', Gitlab::GitalyClient::RepositoryService, :fetch_remote do
subject { repository.fetch_remote('remote-name') } subject { repository.fetch_remote(url) }
end end
end end
...@@ -584,29 +586,29 @@ RSpec.describe Gitlab::Git::Repository, :seed_helper do ...@@ -584,29 +586,29 @@ RSpec.describe Gitlab::Git::Repository, :seed_helper do
expect_any_instance_of(Gitlab::GitalyClient::RemoteService) expect_any_instance_of(Gitlab::GitalyClient::RemoteService)
.to receive(:find_remote_root_ref).and_call_original .to receive(:find_remote_root_ref).and_call_original
expect(repository.find_remote_root_ref('origin', SeedHelper::GITLAB_GIT_TEST_REPO_URL)).to eq 'master' expect(repository.find_remote_root_ref(SeedHelper::GITLAB_GIT_TEST_REPO_URL)).to eq 'master'
end end
it 'returns UTF-8' do it 'returns UTF-8' do
expect(repository.find_remote_root_ref('origin', SeedHelper::GITLAB_GIT_TEST_REPO_URL)).to be_utf8 expect(repository.find_remote_root_ref(SeedHelper::GITLAB_GIT_TEST_REPO_URL)).to be_utf8
end end
it 'returns nil when remote name is nil' do it 'returns nil when remote name is nil' do
expect_any_instance_of(Gitlab::GitalyClient::RemoteService) expect_any_instance_of(Gitlab::GitalyClient::RemoteService)
.not_to receive(:find_remote_root_ref) .not_to receive(:find_remote_root_ref)
expect(repository.find_remote_root_ref(nil, nil)).to be_nil expect(repository.find_remote_root_ref(nil)).to be_nil
end end
it 'returns nil when remote name is empty' do it 'returns nil when remote name is empty' do
expect_any_instance_of(Gitlab::GitalyClient::RemoteService) expect_any_instance_of(Gitlab::GitalyClient::RemoteService)
.not_to receive(:find_remote_root_ref) .not_to receive(:find_remote_root_ref)
expect(repository.find_remote_root_ref('', '')).to be_nil expect(repository.find_remote_root_ref('')).to be_nil
end end
it_behaves_like 'wrapping gRPC errors', Gitlab::GitalyClient::RemoteService, :find_remote_root_ref do it_behaves_like 'wrapping gRPC errors', Gitlab::GitalyClient::RemoteService, :find_remote_root_ref do
subject { repository.find_remote_root_ref('origin', SeedHelper::GITLAB_GIT_TEST_REPO_URL) } subject { repository.find_remote_root_ref(SeedHelper::GITLAB_GIT_TEST_REPO_URL) }
end end
end end
......
...@@ -6,11 +6,9 @@ RSpec.describe Gitlab::GitalyClient::RemoteService do ...@@ -6,11 +6,9 @@ RSpec.describe Gitlab::GitalyClient::RemoteService do
let(:project) { create(:project) } let(:project) { create(:project) }
let(:storage_name) { project.repository_storage } let(:storage_name) { project.repository_storage }
let(:relative_path) { project.disk_path + '.git' } let(:relative_path) { project.disk_path + '.git' }
let(:remote_name) { 'my-remote' }
let(:client) { described_class.new(project.repository) } let(:client) { described_class.new(project.repository) }
describe '#find_remote_root_ref' do describe '#find_remote_root_ref' do
let(:remote) { 'origin' }
let(:url) { 'http://git.example.com/my-repo.git' } let(:url) { 'http://git.example.com/my-repo.git' }
let(:auth) { 'Basic secret' } let(:auth) { 'Basic secret' }
let(:expected_params) { { remote_url: url, http_authorization_header: auth } } let(:expected_params) { { remote_url: url, http_authorization_header: auth } }
...@@ -22,7 +20,7 @@ RSpec.describe Gitlab::GitalyClient::RemoteService do ...@@ -22,7 +20,7 @@ RSpec.describe Gitlab::GitalyClient::RemoteService do
.with(gitaly_request_with_params(expected_params), kind_of(Hash)) .with(gitaly_request_with_params(expected_params), kind_of(Hash))
.and_return(double(ref: 'master')) .and_return(double(ref: 'master'))
expect(client.find_remote_root_ref(remote, url, auth)).to eq 'master' expect(client.find_remote_root_ref(url, auth)).to eq 'master'
end end
it 'ensure ref is a valid UTF-8 string' do it 'ensure ref is a valid UTF-8 string' do
...@@ -32,7 +30,7 @@ RSpec.describe Gitlab::GitalyClient::RemoteService do ...@@ -32,7 +30,7 @@ RSpec.describe Gitlab::GitalyClient::RemoteService do
.with(gitaly_request_with_params(expected_params), kind_of(Hash)) .with(gitaly_request_with_params(expected_params), kind_of(Hash))
.and_return(double(ref: "an_invalid_ref_\xE5")) .and_return(double(ref: "an_invalid_ref_\xE5"))
expect(client.find_remote_root_ref(remote, url, auth)).to eq "an_invalid_ref_å" expect(client.find_remote_root_ref(url, auth)).to eq "an_invalid_ref_å"
end end
end end
......
...@@ -122,89 +122,75 @@ RSpec.describe Gitlab::GitalyClient::RepositoryService do ...@@ -122,89 +122,75 @@ RSpec.describe Gitlab::GitalyClient::RepositoryService do
end end
describe '#fetch_remote' do describe '#fetch_remote' do
shared_examples 'a fetch' do let(:url) { 'https://example.com/git/repo.git' }
it 'sends a fetch_remote_request message' do
expected_remote_params = Gitaly::Remote.new( it 'sends a fetch_remote_request message' do
url: url, http_authorization_header: "", mirror_refmaps: []) expected_request = gitaly_request_with_params(
remote_params: Gitaly::Remote.new(
expected_request = gitaly_request_with_params( url: url,
remote: remote, http_authorization_header: "",
remote_params: url ? expected_remote_params : nil, mirror_refmaps: []
ssh_key: '', ),
known_hosts: '', ssh_key: '',
force: false, known_hosts: '',
no_tags: false, force: false,
no_prune: false, no_tags: false,
check_tags_changed: false no_prune: false,
) check_tags_changed: false
)
expect_any_instance_of(Gitaly::RepositoryService::Stub)
.to receive(:fetch_remote)
.with(expected_request, kind_of(Hash))
.and_return(double(value: true))
client.fetch_remote(remote, url: url, refmap: nil, ssh_auth: nil, forced: false, no_tags: false, timeout: 1, check_tags_changed: false)
end
context 'SSH auth' do expect_any_instance_of(Gitaly::RepositoryService::Stub)
where(:ssh_mirror_url, :ssh_key_auth, :ssh_private_key, :ssh_known_hosts, :expected_params) do .to receive(:fetch_remote)
false | false | 'key' | 'known_hosts' | {} .with(expected_request, kind_of(Hash))
false | true | 'key' | 'known_hosts' | {} .and_return(double(value: true))
true | false | 'key' | 'known_hosts' | { known_hosts: 'known_hosts' }
true | true | 'key' | 'known_hosts' | { ssh_key: 'key', known_hosts: 'known_hosts' }
true | true | 'key' | nil | { ssh_key: 'key' }
true | true | nil | 'known_hosts' | { known_hosts: 'known_hosts' }
true | true | nil | nil | {}
true | true | '' | '' | {}
end
with_them do client.fetch_remote(url, refmap: nil, ssh_auth: nil, forced: false, no_tags: false, timeout: 1, check_tags_changed: false)
let(:ssh_auth) do
double(
:ssh_auth,
ssh_mirror_url?: ssh_mirror_url,
ssh_key_auth?: ssh_key_auth,
ssh_private_key: ssh_private_key,
ssh_known_hosts: ssh_known_hosts
)
end
it do
expected_remote_params = Gitaly::Remote.new(
url: url, http_authorization_header: "", mirror_refmaps: [])
expected_request = gitaly_request_with_params({
remote: remote,
remote_params: url ? expected_remote_params : nil,
ssh_key: '',
known_hosts: '',
force: false,
no_tags: false,
no_prune: false
}.update(expected_params))
expect_any_instance_of(Gitaly::RepositoryService::Stub)
.to receive(:fetch_remote)
.with(expected_request, kind_of(Hash))
.and_return(double(value: true))
client.fetch_remote(remote, url: url, refmap: nil, ssh_auth: ssh_auth, forced: false, no_tags: false, timeout: 1)
end
end
end
end end
context 'with remote' do context 'SSH auth' do
it_behaves_like 'a fetch' do where(:ssh_mirror_url, :ssh_key_auth, :ssh_private_key, :ssh_known_hosts, :expected_params) do
let(:remote) { 'remote-name' } false | false | 'key' | 'known_hosts' | {}
let(:url) { nil } false | true | 'key' | 'known_hosts' | {}
true | false | 'key' | 'known_hosts' | { known_hosts: 'known_hosts' }
true | true | 'key' | 'known_hosts' | { ssh_key: 'key', known_hosts: 'known_hosts' }
true | true | 'key' | nil | { ssh_key: 'key' }
true | true | nil | 'known_hosts' | { known_hosts: 'known_hosts' }
true | true | nil | nil | {}
true | true | '' | '' | {}
end end
end
context 'with URL' do with_them do
it_behaves_like 'a fetch' do let(:ssh_auth) do
let(:remote) { "" } double(
let(:url) { 'https://example.com/git/repo.git' } :ssh_auth,
ssh_mirror_url?: ssh_mirror_url,
ssh_key_auth?: ssh_key_auth,
ssh_private_key: ssh_private_key,
ssh_known_hosts: ssh_known_hosts
)
end
it do
expected_request = gitaly_request_with_params({
remote_params: Gitaly::Remote.new(
url: url,
http_authorization_header: "",
mirror_refmaps: []
),
ssh_key: '',
known_hosts: '',
force: false,
no_tags: false,
no_prune: false
}.update(expected_params))
expect_any_instance_of(Gitaly::RepositoryService::Stub)
.to receive(:fetch_remote)
.with(expected_request, kind_of(Hash))
.and_return(double(value: true))
client.fetch_remote(url, refmap: nil, ssh_auth: ssh_auth, forced: false, no_tags: false, timeout: 1)
end
end end
end end
end end
......
...@@ -164,7 +164,7 @@ RSpec.describe Gitlab::GithubImport::Importer::PullRequestsImporter do ...@@ -164,7 +164,7 @@ RSpec.describe Gitlab::GithubImport::Importer::PullRequestsImporter do
expect(project.repository) expect(project.repository)
.to receive(:fetch_remote) .to receive(:fetch_remote)
.with('github', forced: false, url: url, refmap: Gitlab::GithubImport.refmap) .with(url, forced: false, refmap: Gitlab::GithubImport.refmap)
freeze_time do freeze_time do
importer.update_repository importer.update_repository
......
...@@ -1096,15 +1096,14 @@ RSpec.describe Repository do ...@@ -1096,15 +1096,14 @@ RSpec.describe Repository do
describe '#fetch_as_mirror' do describe '#fetch_as_mirror' do
let(:url) { "http://example.com" } let(:url) { "http://example.com" }
let(:remote_name) { "remote-name" }
it 'fetches the URL without creating a remote' do it 'fetches the URL without creating a remote' do
expect(repository) expect(repository)
.to receive(:fetch_remote) .to receive(:fetch_remote)
.with(remote_name, url: url, forced: false, prune: true, refmap: :all_refs) .with(url, forced: false, prune: true, refmap: :all_refs)
.and_return(nil) .and_return(nil)
repository.fetch_as_mirror(url, remote_name: remote_name) repository.fetch_as_mirror(url)
end end
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