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:
authorJacob Vosmaer <jacob@gitlab.com>2019-08-22 13:24:54 +0300
committerJacob Vosmaer <jacob@gitlab.com>2019-08-22 13:24:54 +0300
commit174ccf9e4ff992eb6727fdeeed7fe9c34ec1d614 (patch)
tree73dfa0db8ec84348c63b2f40f2d49a81dbcb5046
parent959a0fc70849d1b7fba59d4f6e21aab78e71902d (diff)
parent635904f1c9d7d67c9d72427acb276d3f9288f09c (diff)
Merge branch '60471-git-fetch-dont-follow-http-redirects' into 'master'
Add http.followRedirects directive to `git fetch` command See merge request gitlab/gitaly!29
-rw-r--r--internal/service/repository/fetch_remote_test.go31
-rw-r--r--ruby/lib/gitlab/git/gitlab_projects.rb2
-rw-r--r--ruby/spec/lib/gitlab/git/gitlab_projects_spec.rb9
3 files changed, 37 insertions, 5 deletions
diff --git a/internal/service/repository/fetch_remote_test.go b/internal/service/repository/fetch_remote_test.go
index 7001a6bba..ecdb066a8 100644
--- a/internal/service/repository/fetch_remote_test.go
+++ b/internal/service/repository/fetch_remote_test.go
@@ -188,6 +188,37 @@ func TestFetchRemoteOverHTTP(t *testing.T) {
}
}
+func TestFetchRemoteOverHTTPWithRedirect(t *testing.T) {
+ server, serverSocketPath := runRepoServer(t)
+ defer server.Stop()
+
+ client, conn := newRepositoryClient(t, serverSocketPath)
+ defer conn.Close()
+
+ ctx, cancel := testhelper.Context()
+ defer cancel()
+
+ testRepo, _, cleanup := testhelper.NewTestRepo(t)
+ defer cleanup()
+
+ s := httptest.NewServer(
+ http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ require.Equal(t, "/info/refs?service=git-upload-pack", r.URL.String())
+ http.Redirect(w, r, "/redirect_url", http.StatusSeeOther)
+ }),
+ )
+
+ req := &gitalypb.FetchRemoteRequest{
+ Repository: testRepo,
+ RemoteParams: &gitalypb.Remote{Url: s.URL, Name: "geo"},
+ Timeout: 1000,
+ }
+
+ _, err := client.FetchRemote(ctx, req)
+ require.Error(t, err)
+ require.Contains(t, err.Error(), "The requested URL returned error: 303")
+}
+
func TestFetchRemoteOverHTTPError(t *testing.T) {
server, serverSocketPath := runRepoServer(t)
defer server.Stop()
diff --git a/ruby/lib/gitlab/git/gitlab_projects.rb b/ruby/lib/gitlab/git/gitlab_projects.rb
index b02cdc5ec..bc3859fb4 100644
--- a/ruby/lib/gitlab/git/gitlab_projects.rb
+++ b/ruby/lib/gitlab/git/gitlab_projects.rb
@@ -120,7 +120,7 @@ module Gitlab
private
def fetch_remote_command(name, tags, prune, force)
- %W(#{Gitlab.config.git.bin_path} fetch #{name} --quiet).tap do |cmd|
+ %W(#{Gitlab.config.git.bin_path} -c http.followRedirects=false 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..85122ede6 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(:follow_redirects) { false }
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(: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,7 @@ 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)