diff --git a/ee/spec/models/repository_spec.rb b/ee/spec/models/repository_spec.rb index bb1f5cba82ea427bd11e3ba59ba07e288d1e9b88..c6c8c7697e4ce9297cc237c92cd996ead1eca7b0 100644 --- a/ee/spec/models/repository_spec.rb +++ b/ee/spec/models/repository_spec.rb @@ -53,7 +53,6 @@ RSpec.describe Repository do let(:url) { "http://example.com" } it 'fetches the URL without creating a remote' do - expect(repository).not_to receive(:add_remote) expect(repository) .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) diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb index 70d072e80821c4b23ae3f21073731650cc22cb95..b60a616006675e6f93c8fa68bb3770b21f7c0933 100644 --- a/lib/gitlab/git/repository.rb +++ b/lib/gitlab/git/repository.rb @@ -703,19 +703,6 @@ module Gitlab write_ref(ref, start_point) end - # If `mirror_refmap` is present the remote is set as mirror with that mapping - def add_remote(remote_name, url, mirror_refmap: nil) - wrapped_gitaly_errors do - gitaly_remote_client.add_remote(remote_name, url, mirror_refmap) - end - end - - def remove_remote(remote_name) - wrapped_gitaly_errors do - gitaly_remote_client.remove_remote(remote_name) - end - end - def find_remote_root_ref(remote_name, remote_url, authorization = nil) return unless remote_name.present? && remote_url.present? diff --git a/lib/gitlab/gitaly_client/remote_service.rb b/lib/gitlab/gitaly_client/remote_service.rb index 487127b7b7469f28e6ac3b9b8e7f7ce63abef124..652b28c9290b1a1efedd43115f71e849466dc70e 100644 --- a/lib/gitlab/gitaly_client/remote_service.rb +++ b/lib/gitlab/gitaly_client/remote_service.rb @@ -26,23 +26,6 @@ module Gitlab @storage = repository.storage end - def add_remote(name, url, mirror_refmaps) - request = Gitaly::AddRemoteRequest.new( - repository: @gitaly_repo, - name: name, - url: url, - mirror_refmaps: Array.wrap(mirror_refmaps).map(&:to_s) - ) - - GitalyClient.call(@storage, :remote_service, :add_remote, request, timeout: GitalyClient.fast_timeout) - end - - def remove_remote(name) - request = Gitaly::RemoveRemoteRequest.new(repository: @gitaly_repo, name: name) - - GitalyClient.call(@storage, :remote_service, :remove_remote, request, timeout: GitalyClient.long_timeout).result - end - # The remote_name parameter is deprecated and will be removed soon. def find_remote_root_ref(remote_name, remote_url, authorization) request = Gitaly::FindRemoteRootRefRequest.new(repository: @gitaly_repo, diff --git a/spec/lib/gitlab/git/repository_spec.rb b/spec/lib/gitlab/git/repository_spec.rb index 706bcdea291701d364794c5c59b4507e16a60820..9b3d8c8ef3aaa3bc80a59d8ad90bd63c9d341977 100644 --- a/spec/lib/gitlab/git/repository_spec.rb +++ b/spec/lib/gitlab/git/repository_spec.rb @@ -2001,47 +2001,6 @@ RSpec.describe Gitlab::Git::Repository, :seed_helper do end end - describe 'remotes' do - let(:repository) { mutable_repository } - let(:remote_name) { 'my-remote' } - let(:url) { 'http://my-repo.git' } - - after do - ensure_seeds - end - - describe '#add_remote' do - let(:mirror_refmap) { '+refs/*:refs/*' } - - it 'added the remote' do - begin - repository_rugged.remotes.delete(remote_name) - rescue Rugged::ConfigError - end - - repository.add_remote(remote_name, url, mirror_refmap: mirror_refmap) - - expect(repository_rugged.remotes[remote_name]).not_to be_nil - expect(repository_rugged.config["remote.#{remote_name}.mirror"]).to eq('true') - expect(repository_rugged.config["remote.#{remote_name}.prune"]).to eq('true') - expect(repository_rugged.config["remote.#{remote_name}.fetch"]).to eq(mirror_refmap) - end - end - - describe '#remove_remote' do - it 'removes the remote' do - repository_rugged.remotes.create(remote_name, url) - - expect(repository.remove_remote(remote_name)).to be true - - # Since we deleted the remote via Gitaly, Rugged doesn't know - # this changed underneath it. Let's refresh the Rugged repo. - repository_rugged = Rugged::Repository.new(repository_path) - expect(repository_rugged.remotes[remote_name]).to be_nil - end - end - end - describe '#bundle_to_disk' do let(:save_path) { File.join(Dir.tmpdir, "repo-#{SecureRandom.hex}.bundle") } diff --git a/spec/lib/gitlab/gitaly_client/remote_service_spec.rb b/spec/lib/gitlab/gitaly_client/remote_service_spec.rb index 2ec5f70be76f499d1058209b811ee57b935e17ee..cdbd48e106a2c6761a6e46f89229538fc5b09957 100644 --- a/spec/lib/gitlab/gitaly_client/remote_service_spec.rb +++ b/spec/lib/gitlab/gitaly_client/remote_service_spec.rb @@ -9,31 +9,6 @@ RSpec.describe Gitlab::GitalyClient::RemoteService do let(:remote_name) { 'my-remote' } let(:client) { described_class.new(project.repository) } - describe '#add_remote' do - let(:url) { 'http://my-repo.git' } - let(:mirror_refmap) { :all_refs } - - it 'sends an add_remote message' do - expect_any_instance_of(Gitaly::RemoteService::Stub) - .to receive(:add_remote) - .with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash)) - .and_return(double(:add_remote_response)) - - client.add_remote(remote_name, url, mirror_refmap) - end - end - - describe '#remove_remote' do - it 'sends an remove_remote message and returns the result value' do - expect_any_instance_of(Gitaly::RemoteService::Stub) - .to receive(:remove_remote) - .with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash)) - .and_return(double(result: true)) - - expect(client.remove_remote(remote_name)).to be(true) - end - end - describe '#find_remote_root_ref' do let(:remote) { 'origin' } let(:url) { 'http://git.example.com/my-repo.git' } diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index e5ee113dea0b4884335aa275e8a3cc40be35afeb..7e68886a0cb7d3f3b02638ef4e4295f4817905ab 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -1099,7 +1099,6 @@ RSpec.describe Repository do let(:remote_name) { "remote-name" } it 'fetches the URL without creating a remote' do - expect(repository).not_to receive(:add_remote) expect(repository) .to receive(:fetch_remote) .with(remote_name, url: url, forced: false, prune: true, refmap: :all_refs)