diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2017-03-27 11:43:03 -0300 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2017-04-03 15:50:22 -0300 |
commit | 336ba94a7bbdd52f07d0f1c7f7bced20c37ad307 (patch) | |
tree | 881862060ce559f579ac8d5b31f1b81844678eea /app/models/repository.rb | |
parent | 97c49b8426c62b5b398ed9a2bf863d859a4b7e55 (diff) | |
download | gitlab-ce-336ba94a7bbdd52f07d0f1c7f7bced20c37ad307.tar.gz |
Fetch GitHub project as a mirror to get all refs at once
Diffstat (limited to 'app/models/repository.rb')
-rw-r--r-- | app/models/repository.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb index 596650353fc..a9c1ce6782d 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -2,6 +2,7 @@ require 'securerandom' class Repository include Gitlab::ShellAdapter + include RepositoryMirroring attr_accessor :path_with_namespace, :project @@ -1033,6 +1034,13 @@ class Repository rugged.references.delete(tmp_ref) if tmp_ref end + def fetch_mirror(remote, url) + add_remote(remote, url) + set_remote_as_mirror(remote) + fetch_remote(remote, forced: true) + remove_remote(remote) + end + def fetch_ref(source_path, source_ref, target_ref) args = %W(#{Gitlab.config.git.bin_path} fetch --no-tags -f #{source_path} #{source_ref}:#{target_ref}) Gitlab::Popen.popen(args, path_to_repo) |