summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzegorz@gitlab.com>2017-12-26 12:46:07 +0000
committerOswaldo Ferreira <oswaldo@gitlab.com>2017-12-26 14:00:09 +0000
commit97ff3fcdeeac23d9ac2dd9a57b06abe46ace89a9 (patch)
treeac70c231f6142e60341e5271fa7ac91fc2e1ea09
parent3560b93e261efadc46a36512527dadb4d2a1a284 (diff)
downloadgitlab-ce-97ff3fcdeeac23d9ac2dd9a57b06abe46ace89a9.tar.gz
Merge branch 'sh-handle-anonymous-clones-project-moved' into 'master'
Fix Error 500s with anonymous clones for a project that has moved Closes #41457 See merge request gitlab-org/gitlab-ce!16128 (cherry picked from commit a5a0f3f725c4f5c6d11d33e18493d93e07e53183) a83c41f6 Fix Error 500s with anonymous clones for a project that has moved b6c711fd Disable redirect messages for anonymous clones
-rw-r--r--changelogs/unreleased/sh-handle-anonymous-clones-project-moved.yml5
-rw-r--r--lib/gitlab/checks/project_moved.rb4
-rw-r--r--spec/lib/gitlab/checks/project_moved_spec.rb6
3 files changed, 15 insertions, 0 deletions
diff --git a/changelogs/unreleased/sh-handle-anonymous-clones-project-moved.yml b/changelogs/unreleased/sh-handle-anonymous-clones-project-moved.yml
new file mode 100644
index 00000000000..a0860871152
--- /dev/null
+++ b/changelogs/unreleased/sh-handle-anonymous-clones-project-moved.yml
@@ -0,0 +1,5 @@
+---
+title: Fix Error 500s with anonymous clones for a project that has moved
+merge_request:
+author:
+type: fixed
diff --git a/lib/gitlab/checks/project_moved.rb b/lib/gitlab/checks/project_moved.rb
index 3a1c0a3455e..dfb2f4d4054 100644
--- a/lib/gitlab/checks/project_moved.rb
+++ b/lib/gitlab/checks/project_moved.rb
@@ -21,6 +21,10 @@ module Gitlab
end
def add_redirect_message
+ # Don't bother with sending a redirect message for anonymous clones
+ # because they never see it via the `/internal/post_receive` endpoint
+ return unless user.present? && project.present?
+
Gitlab::Redis::SharedState.with do |redis|
key = self.class.redirect_message_key(user.id, project.id)
redis.setex(key, 5.minutes, redirect_message)
diff --git a/spec/lib/gitlab/checks/project_moved_spec.rb b/spec/lib/gitlab/checks/project_moved_spec.rb
index fa1575e2177..f90c2d6aded 100644
--- a/spec/lib/gitlab/checks/project_moved_spec.rb
+++ b/spec/lib/gitlab/checks/project_moved_spec.rb
@@ -35,6 +35,12 @@ describe Gitlab::Checks::ProjectMoved, :clean_gitlab_redis_shared_state do
project_moved = described_class.new(project, user, 'foo/bar', 'http')
expect(project_moved.add_redirect_message).to eq("OK")
end
+
+ it 'should handle anonymous clones' do
+ project_moved = described_class.new(project, nil, 'foo/bar', 'http')
+
+ expect(project_moved.add_redirect_message).to eq(nil)
+ end
end
describe '#redirect_message' do