Commit 13dba821 authored by Nick Thomas's avatar Nick Thomas

Merge branch '5224-remove-use_system_git_for_fetch' into 'master'

Resolve "Remove USE_SYSTEM_GIT_FOR_FETCH"

Closes #5224

See merge request gitlab-org/gitlab-ee!5525
parents ef44e5cc b76713af
---
title: Use of ENV['USE_SYSTEM_GIT_FOR_FETCH'] is no longer supported
merge_request:
author:
type: removed
......@@ -73,32 +73,15 @@ module Gitlab
end
def fetch_remote(name, timeout, force:, tags:, ssh_key: nil, known_hosts: nil, prune: true)
tags_option = tags ? '--tags' : '--no-tags'
logger.info "Fetching remote #{name} for repository #{repository_absolute_path}."
cmd = %W(#{git_fetch_binary} fetch #{name} --quiet)
cmd << '--prune' if prune
cmd << '--force' if force
cmd << tags_option
cmd = fetch_remote_command(name, tags, prune, force)
setup_ssh_auth(ssh_key, known_hosts) do |env|
success = run_with_timeout(cmd, timeout, repository_absolute_path, env)
unless success
logger.error "Fetching remote #{name} for repository #{repository_absolute_path} failed."
run_with_timeout(cmd, timeout, repository_absolute_path, env).tap do |success|
unless success
logger.error "Fetching remote #{name} for repository #{repository_absolute_path} failed."
end
end
success
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
if ENV['USE_SYSTEM_GIT_FOR_FETCH'] == '1'
'/usr/bin/git'
else
Gitlab.config.git.bin_path
end
end
......@@ -224,6 +207,14 @@ module Gitlab
private
def fetch_remote_command(name, tags, prune, force)
%W(#{Gitlab.config.git.bin_path} fetch #{name} --quiet).tap do |cmd|
cmd << '--prune' if prune
cmd << '--force' if force
cmd << (tags ? '--tags' : '--no-tags')
end
end
def git_import_repository(source, timeout)
# Skip import if repo already exists
return false if File.exist?(repository_absolute_path)
......
......@@ -160,20 +160,6 @@ 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