2017-03-27 10:43:03 -04:00
|
|
|
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
|
|
|
|
|
2017-04-03 13:46:00 -04:00
|
|
|
def fetch_mirror(remote, url)
|
|
|
|
add_remote(remote, url)
|
|
|
|
set_remote_as_mirror(remote)
|
|
|
|
fetch_remote(remote, forced: true)
|
|
|
|
remove_remote(remote)
|
2017-03-27 10:43:03 -04:00
|
|
|
end
|
|
|
|
end
|