Commit 413cb0af authored by Gabriel Mazetto's avatar Gabriel Mazetto

git fetch --force using gitlab-shell instead

parent baa48794
......@@ -184,7 +184,7 @@ class Repository
def set_remote_as_mirror(name)
remote_config = raw_repository.rugged.config
# This is used by Gitlab Geo to define repository as equivalent as "git clone --mirror"
remote_config["remote.#{name}.fetch"] = 'refs/*:refs/*'
remote_config["remote.#{name}.mirror"] = true
......@@ -196,8 +196,7 @@ class Repository
end
def fetch_remote_forced!(remote)
args = %W(#{Gitlab.config.git.bin_path} fetch #{remote} -f)
Gitlab::Popen.popen(args, path_to_repo)
gitlab_shell.fetch_remote(path_with_namespace, remote, true)
end
def branch_names
......
......@@ -45,12 +45,15 @@ module Gitlab
#
# name - project path with namespace
# remote - remote name
# forced - should we use --force flag?
#
# Ex.
# fetch_remote("gitlab/gitlab-ci", "upstream")
#
def fetch_remote(name, remote)
output, status = Popen::popen([gitlab_shell_projects_path, 'fetch-remote', "#{name}.git", remote, '600'])
def fetch_remote(name, remote, forced=false)
args = [gitlab_shell_projects_path, 'fetch-remote', "#{name}.git", remote, '600']
args << '--force' if forced
output, status = Popen::popen(args)
raise Error, output unless status.zero?
true
end
......
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