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
This commit is contained in:
commit
a5a0f3f725
3 changed files with 15 additions and 0 deletions
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
title: Fix Error 500s with anonymous clones for a project that has moved
|
||||||
|
merge_request:
|
||||||
|
author:
|
||||||
|
type: fixed
|
|
@ -21,6 +21,10 @@ module Gitlab
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_redirect_message
|
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|
|
Gitlab::Redis::SharedState.with do |redis|
|
||||||
key = self.class.redirect_message_key(user.id, project.id)
|
key = self.class.redirect_message_key(user.id, project.id)
|
||||||
redis.setex(key, 5.minutes, redirect_message)
|
redis.setex(key, 5.minutes, redirect_message)
|
||||||
|
|
|
@ -35,6 +35,12 @@ describe Gitlab::Checks::ProjectMoved, :clean_gitlab_redis_shared_state do
|
||||||
project_moved = described_class.new(project, user, 'foo/bar', 'http')
|
project_moved = described_class.new(project, user, 'foo/bar', 'http')
|
||||||
expect(project_moved.add_redirect_message).to eq("OK")
|
expect(project_moved.add_redirect_message).to eq("OK")
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
describe '#redirect_message' do
|
describe '#redirect_message' do
|
||||||
|
|
Loading…
Reference in a new issue