gitlab-org--gitlab-foss/app/models/concerns/repository_mirroring.rb

17 lines
494 B
Ruby

module RepositoryMirroring
def set_remote_as_mirror(name)
config = raw_repository.rugged.config
# This is used to define repository as equivalent as "git clone --mirror"
config["remote.#{name}.fetch"] = 'refs/*:refs/*'
config["remote.#{name}.mirror"] = true
config["remote.#{name}.prune"] = true
end
def fetch_mirror(remote, url)
add_remote(remote, url)
set_remote_as_mirror(remote)
fetch_remote(remote, forced: true)
remove_remote(remote)
end
end