Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
a83c41f6
Commit
a83c41f6
authored
Dec 24, 2017
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Error 500s with anonymous clones for a project that has moved
Closes #41457
parent
5e6dd15a
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
3 deletions
+22
-3
changelogs/unreleased/sh-handle-anonymous-clones-project-moved.yml
...s/unreleased/sh-handle-anonymous-clones-project-moved.yml
+5
-0
lib/gitlab/checks/project_moved.rb
lib/gitlab/checks/project_moved.rb
+10
-3
spec/lib/gitlab/checks/project_moved_spec.rb
spec/lib/gitlab/checks/project_moved_spec.rb
+7
-0
No files found.
changelogs/unreleased/sh-handle-anonymous-clones-project-moved.yml
0 → 100644
View file @
a83c41f6
---
title
:
Fix Error 500s with anonymous clones for a project that has moved
merge_request
:
author
:
type
:
fixed
lib/gitlab/checks/project_moved.rb
View file @
a83c41f6
...
...
@@ -2,6 +2,7 @@ module Gitlab
module
Checks
class
ProjectMoved
REDIRECT_NAMESPACE
=
"redirect_namespace"
.
freeze
ANONYMOUS_ID_KEY
=
'anonymous'
.
freeze
def
initialize
(
project
,
user
,
redirected_path
,
protocol
)
@project
=
project
...
...
@@ -22,7 +23,7 @@ module Gitlab
def
add_redirect_message
Gitlab
::
Redis
::
SharedState
.
with
do
|
redis
|
key
=
self
.
class
.
redirect_message_key
(
user
.
id
,
project
.
id
)
key
=
self
.
class
.
redirect_message_key
(
user
_identifier
,
project
.
id
)
redis
.
setex
(
key
,
5
.
minutes
,
redirect_message
)
end
end
...
...
@@ -45,8 +46,14 @@ module Gitlab
attr_reader
:project
,
:redirected_path
,
:protocol
,
:user
def
self
.
redirect_message_key
(
user_id
,
project_id
)
"
#{
REDIRECT_NAMESPACE
}
:
#{
user_id
}
:
#{
project_id
}
"
def
self
.
redirect_message_key
(
user_identifier
,
project_id
)
"
#{
REDIRECT_NAMESPACE
}
:
#{
user_identifier
}
:
#{
project_id
}
"
end
def
user_identifier
return
ANONYMOUS_ID_KEY
unless
user
.
present?
user
.
id
end
def
remote_url_message
(
rejected
)
...
...
spec/lib/gitlab/checks/project_moved_spec.rb
View file @
a83c41f6
...
...
@@ -35,6 +35,13 @@ 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
(
"OK"
)
expect
(
Gitlab
::
Redis
::
SharedState
.
with
{
|
redis
|
redis
.
get
(
"redirect_namespace:anonymous:
#{
project
.
id
}
"
)
}).
not_to
be_nil
end
end
describe
'#redirect_message'
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment