Commit a5a0f3f7 authored by Grzegorz Bizon's avatar Grzegorz Bizon

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
parents 29749f92 b6c711fd
---
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
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)
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment