Commit af514115 authored by Patrick Steinhardt's avatar Patrick Steinhardt

gitaly_client: Drop AddRemote and RemoveRemote RPCs

We do not use on-disk remotes anymore, and Gitaly has deprecated both of
those RPCs such that they'll be removed soon. Drop these now-unused RPC
wrappers in favor of in-memory remotes.
parent dea39b37
......@@ -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)
......
......@@ -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?
......
......@@ -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,
......
......@@ -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") }
......
......@@ -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' }
......
......@@ -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)
......
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