Commit c98c3f1d authored by Gabriel Mazetto's avatar Gabriel Mazetto

Add mirror flag to `import_repository`

parent 32ea462c
...@@ -942,7 +942,7 @@ class Repository ...@@ -942,7 +942,7 @@ class Repository
end end
def clone_as_mirror(url, http_authorization_header: "") def clone_as_mirror(url, http_authorization_header: "")
import_repository(url, http_authorization_header: http_authorization_header) import_repository(url, http_authorization_header: http_authorization_header, mirror: true)
end end
def fetch_as_mirror(url, forced: false, refmap: :all_refs, prune: true, http_authorization_header: "") def fetch_as_mirror(url, forced: false, refmap: :all_refs, prune: true, http_authorization_header: "")
......
...@@ -841,11 +841,11 @@ module Gitlab ...@@ -841,11 +841,11 @@ module Gitlab
end end
end end
def import_repository(url, http_authorization_header: '') def import_repository(url, http_authorization_header: '', mirror: false)
raise ArgumentError, "don't use disk paths with import_repository: #{url.inspect}" if url.start_with?('.', '/') raise ArgumentError, "don't use disk paths with import_repository: #{url.inspect}" if url.start_with?('.', '/')
wrapped_gitaly_errors do wrapped_gitaly_errors do
gitaly_repository_client.import_repository(url, http_authorization_header: http_authorization_header) gitaly_repository_client.import_repository(url, http_authorization_header: http_authorization_header, mirror: mirror)
end end
end end
......
...@@ -145,11 +145,12 @@ module Gitlab ...@@ -145,11 +145,12 @@ module Gitlab
) )
end end
def import_repository(source, http_authorization_header: '') def import_repository(source, http_authorization_header: '', mirror: false)
request = Gitaly::CreateRepositoryFromURLRequest.new( request = Gitaly::CreateRepositoryFromURLRequest.new(
repository: @gitaly_repo, repository: @gitaly_repo,
url: source, url: source,
http_authorization_header: http_authorization_header http_authorization_header: http_authorization_header,
mirror: mirror
) )
GitalyClient.call( GitalyClient.call(
......
...@@ -2448,7 +2448,7 @@ RSpec.describe Gitlab::Git::Repository, :seed_helper do ...@@ -2448,7 +2448,7 @@ RSpec.describe Gitlab::Git::Repository, :seed_helper do
it 'delegates to Gitaly' do it 'delegates to Gitaly' do
expect_next_instance_of(Gitlab::GitalyClient::RepositoryService) do |svc| expect_next_instance_of(Gitlab::GitalyClient::RepositoryService) do |svc|
expect(svc).to receive(:import_repository).with(url, http_authorization_header: '').and_return(nil) expect(svc).to receive(:import_repository).with(url, http_authorization_header: '', mirror: false).and_return(nil)
end end
repository.import_repository(url) repository.import_repository(url)
......
...@@ -22,7 +22,7 @@ RSpec.describe ProjectImportState, type: :model do ...@@ -22,7 +22,7 @@ RSpec.describe ProjectImportState, type: :model do
before do before do
allow_any_instance_of(Gitlab::GitalyClient::RepositoryService).to receive(:import_repository) allow_any_instance_of(Gitlab::GitalyClient::RepositoryService).to receive(:import_repository)
.with(project.import_url, http_authorization_header: '').and_return(true) .with(project.import_url, http_authorization_header: '', mirror: false).and_return(true)
# Works around https://github.com/rspec/rspec-mocks/issues/910 # Works around https://github.com/rspec/rspec-mocks/issues/910
allow(Project).to receive(:find).with(project.id).and_return(project) allow(Project).to receive(:find).with(project.id).and_return(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