Commit 3448d722 authored by Nick Thomas's avatar Nick Thomas

Merge branch 'sh-allow-system-git-use-env' into 'master'

Allow use of system git for git fetch if USE_SYSTEM_GIT_FOR_FETCH is defined

Closes #5214

See merge request gitlab-org/gitlab-ee!4929
parents 9a1c93fe bbcfc067
---
title: Allow use of system git for git fetch if USE_SYSTEM_GIT_FOR_FETCH is defined
merge_request:
author:
type: other
......@@ -67,7 +67,7 @@ module Gitlab
tags_option = tags ? '--tags' : '--no-tags'
logger.info "Fetching remote #{name} for repository #{repository_absolute_path}."
cmd = %W(git fetch #{name} --quiet)
cmd = %W(#{git_fetch_binary} fetch #{name} --quiet)
cmd << '--prune' if prune
cmd << '--force' if force
cmd << tags_option
......@@ -83,6 +83,14 @@ module Gitlab
end
end
# This is a workaround for Geo until we can ship git 2.16
# See https://gitlab.com/gitlab-org/gitlab-ee/issues/5214
def git_fetch_binary
return 'git' unless ENV['USE_SYSTEM_GIT_FOR_FETCH'] == "1"
'/usr/bin/git'
end
def push_branches(remote_name, timeout, force, branch_names)
logger.info "Pushing branches from #{repository_absolute_path} to remote #{remote_name}: #{branch_names}"
cmd = %w(git push)
......
......@@ -160,6 +160,20 @@ describe Gitlab::Git::GitlabProjects do
expect(key.string).to eq('KNOWN HOSTS')
end
end
context 'with USE_SYSTEM_GIT_FOR_FETCH env' do
let(:cmd) { %W(/usr/bin/git fetch #{remote_name} --quiet --prune --tags) }
before do
stub_env('USE_SYSTEM_GIT_FOR_FETCH', '1')
end
it 'uses system git' do
stub_spawn(cmd, 600, tmp_repo_path, {}, success: true)
is_expected.to be_truthy
end
end
end
describe '#import_project' do
......
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