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 ...@@ -73,32 +73,15 @@ module Gitlab
end end
def fetch_remote(name, timeout, force:, tags:, ssh_key: nil, known_hosts: nil, prune: true) 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}." logger.info "Fetching remote #{name} for repository #{repository_absolute_path}."
cmd = %W(#{git_fetch_binary} fetch #{name} --quiet) cmd = fetch_remote_command(name, tags, prune, force)
cmd << '--prune' if prune
cmd << '--force' if force
cmd << tags_option
setup_ssh_auth(ssh_key, known_hosts) do |env| setup_ssh_auth(ssh_key, known_hosts) do |env|
success = run_with_timeout(cmd, timeout, repository_absolute_path, env) run_with_timeout(cmd, timeout, repository_absolute_path, env).tap do |success|
unless success
unless success logger.error "Fetching remote #{name} for repository #{repository_absolute_path} failed."
logger.error "Fetching remote #{name} for repository #{repository_absolute_path} failed." end
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
end end
...@@ -224,6 +207,14 @@ module Gitlab ...@@ -224,6 +207,14 @@ module Gitlab
private 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) def git_import_repository(source, timeout)
# Skip import if repo already exists # Skip import if repo already exists
return false if File.exist?(repository_absolute_path) return false if File.exist?(repository_absolute_path)
......
...@@ -160,20 +160,6 @@ describe Gitlab::Git::GitlabProjects do ...@@ -160,20 +160,6 @@ describe Gitlab::Git::GitlabProjects do
expect(key.string).to eq('KNOWN HOSTS') expect(key.string).to eq('KNOWN HOSTS')
end end
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 end
describe '#import_project' do 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