summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2018-06-20 15:08:11 -0500
committerRobert Speicher <rspeicher@gmail.com>2018-06-20 15:08:11 -0500
commitf87e702eceed58d9aacc1f6667c0c95a21c23a5c (patch)
treed6f55d69e98edf182f5e7c9374ac196bf4c1a8ae
parenta8f4f48e4ad0283e4542b36b10a3edebf1e700a0 (diff)
downloadgitlab-ce-rs-lib-gitlab-git-gitlab_projects-parity.tar.gz
CE-EE parity for lib/gitlab/git/gitlab_projects.rbrs-lib-gitlab-git-gitlab_projects-parity
-rw-r--r--lib/gitlab/git/gitlab_projects.rb25
1 files changed, 13 insertions, 12 deletions
diff --git a/lib/gitlab/git/gitlab_projects.rb b/lib/gitlab/git/gitlab_projects.rb
index 8475645971e..5ff15a787f0 100644
--- a/lib/gitlab/git/gitlab_projects.rb
+++ b/lib/gitlab/git/gitlab_projects.rb
@@ -61,22 +61,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(#{Gitlab.config.git.bin_path} 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
@@ -202,6 +195,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)