Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKerri Miller <kerrizor@kerrizor.com>2019-07-03 21:46:31 +0300
committerJacob Vosmaer <jacob@gitlab.com>2019-07-26 15:10:04 +0300
commit072839ce056b6acb8752ff73ac9e4086156ca156 (patch)
tree77b02b6a2578c5e170bcec99157676c761375aad
parent333775253533ae4e9e9e66dc12b636821646551f (diff)
Add http.followRedirects directive to `git fetch` command
WIP
-rw-r--r--ruby/lib/gitlab/git/gitlab_projects.rb8
-rw-r--r--ruby/spec/lib/gitlab/git/gitlab_projects_spec.rb22
2 files changed, 21 insertions, 9 deletions
diff --git a/ruby/lib/gitlab/git/gitlab_projects.rb b/ruby/lib/gitlab/git/gitlab_projects.rb
index b02cdc5ec..f56c7b1d7 100644
--- a/ruby/lib/gitlab/git/gitlab_projects.rb
+++ b/ruby/lib/gitlab/git/gitlab_projects.rb
@@ -57,9 +57,9 @@ module Gitlab
end
end
- def fetch_remote(name, timeout, force:, tags:, env: {}, prune: true)
+ def fetch_remote(name, timeout, force:, tags:, env: {}, prune: true, follow_redirects: false)
logger.info "Fetching remote #{name} for repository #{repository_absolute_path}."
- cmd = fetch_remote_command(name, tags, prune, force)
+ cmd = fetch_remote_command(name, tags, prune, force, follow_redirects)
run_with_timeout(cmd, timeout, repository_absolute_path, env).tap do |success|
logger.error "Fetching remote #{name} for repository #{repository_absolute_path} failed." unless success
@@ -119,8 +119,8 @@ module Gitlab
private
- def fetch_remote_command(name, tags, prune, force)
- %W(#{Gitlab.config.git.bin_path} fetch #{name} --quiet).tap do |cmd|
+ def fetch_remote_command(name, tags, prune, force, follow_redirects)
+ %W(#{Gitlab.config.git.bin_path} -c http.followRedirects=#{follow_redirects} fetch #{name} --quiet).tap do |cmd|
cmd << '--prune' if prune
cmd << '--force' if force
cmd << (tags ? '--tags' : '--no-tags')
diff --git a/ruby/spec/lib/gitlab/git/gitlab_projects_spec.rb b/ruby/spec/lib/gitlab/git/gitlab_projects_spec.rb
index 391a4b76a..211e6533a 100644
--- a/ruby/spec/lib/gitlab/git/gitlab_projects_spec.rb
+++ b/ruby/spec/lib/gitlab/git/gitlab_projects_spec.rb
@@ -94,8 +94,9 @@ describe Gitlab::Git::GitlabProjects do
let(:tags) { true }
let(:env) { { 'GIT_SSH_COMMAND' => 'foo-command bar' } }
let(:prune) { true }
- let(:args) { { force: force, tags: tags, env: env, prune: prune } }
- let(:cmd) { %W(#{Gitlab.config.git.bin_path} fetch #{remote_name} --quiet --prune --tags) }
+ let(:follow_redirects) { false }
+ let(:args) { { force: force, tags: tags, env: env, prune: prune, follow_redirects: follow_redirects } }
+ let(:cmd) { %W(#{Gitlab.config.git.bin_path} -c http.followRedirects=false fetch #{remote_name} --quiet --prune --tags) }
subject { gl_projects.fetch_remote(remote_name, 600, args) }
@@ -115,7 +116,7 @@ describe Gitlab::Git::GitlabProjects do
context 'with --force' do
let(:force) { true }
- let(:cmd) { %W(#{Gitlab.config.git.bin_path} fetch #{remote_name} --quiet --prune --force --tags) }
+ let(:cmd) { %W(#{Gitlab.config.git.bin_path} -c http.followRedirects=false fetch #{remote_name} --quiet --prune --force --tags) }
it 'executes the command with forced option' do
stub_spawn(cmd, 600, tmp_repo_path, env, success: true)
@@ -126,7 +127,7 @@ describe Gitlab::Git::GitlabProjects do
context 'with --no-tags' do
let(:tags) { false }
- let(:cmd) { %W(#{Gitlab.config.git.bin_path} fetch #{remote_name} --quiet --prune --no-tags) }
+ let(:cmd) { %W(#{Gitlab.config.git.bin_path} -c http.followRedirects=false fetch #{remote_name} --quiet --prune --no-tags) }
it 'executes the command' do
stub_spawn(cmd, 600, tmp_repo_path, env, success: true)
@@ -137,7 +138,18 @@ describe Gitlab::Git::GitlabProjects do
context 'with no prune' do
let(:prune) { false }
- let(:cmd) { %W(#{Gitlab.config.git.bin_path} fetch #{remote_name} --quiet --tags) }
+ let(:cmd) { %W(#{Gitlab.config.git.bin_path} -c http.followRedirects=false fetch #{remote_name} --quiet --tags) }
+
+ it 'executes the command' do
+ stub_spawn(cmd, 600, tmp_repo_path, env, success: true)
+
+ is_expected.to be_truthy
+ end
+ end
+
+ context 'with follow_redirects = true' do
+ let(:follow_redirects) { true }
+ let(:cmd) { %W(#{Gitlab.config.git.bin_path} -c http.followRedirects=true fetch #{remote_name} --quiet --prune --tags) }
it 'executes the command' do
stub_spawn(cmd, 600, tmp_repo_path, env, success: true)