BigW Consortium Gitlab

repository_mirroring.rb 494 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10
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

11 12 13 14 15
  def fetch_mirror(remote, url)
    add_remote(remote, url)
    set_remote_as_mirror(remote)
    fetch_remote(remote, forced: true)
    remove_remote(remote)
16 17
  end
end