Commit 47083a7c authored by Dmytro Zaporozhets (DZ)'s avatar Dmytro Zaporozhets (DZ)

Merge branch 'pks-fetch-upstream-inmemory' into 'master'

repository: Convert #fetch_upstream to use in-memory remotes

See merge request gitlab-org/gitlab!63421
parents a65561ba dcc684c4
......@@ -34,6 +34,17 @@ module EE
end
def fetch_upstream(url, forced: false, check_tags_changed: false)
if ::Feature.enabled?(:fetch_remote_params, project, default_enabled: :yaml)
return fetch_remote(
MIRROR_REMOTE,
url: url,
refmap: ["+refs/heads/*:refs/remotes/#{MIRROR_REMOTE}/*"],
ssh_auth: project&.import_data,
forced: forced,
check_tags_changed: check_tags_changed
)
end
add_remote(MIRROR_REMOTE, url)
fetch_remote(MIRROR_REMOTE, ssh_auth: project&.import_data, forced: forced, check_tags_changed: check_tags_changed)
......
......@@ -49,6 +49,41 @@ RSpec.describe Repository do
end
end
describe '#fetch_upstream' do
let(:url) { "http://example.com" }
context 'when :fetch_remote_params is enabled' do
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)
.and_return(nil)
repository.fetch_upstream(url, forced: true, check_tags_changed: true)
end
end
context 'when :fetch_remote_params is disabled' do
before do
stub_feature_flags(fetch_remote_params: false)
end
it 'creates a remote and fetches it' do
expect(repository)
.to receive(:add_remote)
.with(described_class::MIRROR_REMOTE, url)
.and_return(nil)
expect(repository)
.to receive(:fetch_remote)
.with(described_class::MIRROR_REMOTE, ssh_auth: nil, forced: true, check_tags_changed: true)
.and_return(nil)
repository.fetch_upstream(url, forced: true, check_tags_changed: true)
end
end
end
describe '#with_config' do
let(:rugged) { rugged_repo(repository) }
let(:entries) do
......
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