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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
55723c22
Commit
55723c22
authored
Dec 20, 2018
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move magic '_any' string to constant
parent
28cffb9f
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
10 deletions
+12
-10
app/controllers/projects/git_http_controller.rb
app/controllers/projects/git_http_controller.rb
+1
-3
lib/gitlab/git_access.rb
lib/gitlab/git_access.rb
+5
-1
spec/lib/gitlab/git_access_spec.rb
spec/lib/gitlab/git_access_spec.rb
+5
-5
spec/lib/gitlab/git_access_wiki_spec.rb
spec/lib/gitlab/git_access_wiki_spec.rb
+1
-1
No files found.
app/controllers/projects/git_http_controller.rb
View file @
55723c22
...
...
@@ -80,9 +80,7 @@ class Projects::GitHttpController < Projects::GitHttpClientController
end
def
access_check
# Use the magic string '_any' to indicate we do not know what the
# changes are. This is also what gitlab-shell does.
access
.
check
(
git_command
,
'_any'
)
access
.
check
(
git_command
,
Gitlab
::
GitAccess
::
ANY
)
@project
||=
access
.
project
end
...
...
lib/gitlab/git_access.rb
View file @
55723c22
...
...
@@ -12,6 +12,10 @@ module Gitlab
TimeoutError
=
Class
.
new
(
StandardError
)
ProjectMovedError
=
Class
.
new
(
NotFoundError
)
# Use the magic string '_any' to indicate we do not know what the
# changes are. This is also what gitlab-shell does.
ANY
=
'_any'
ERROR_MESSAGES
=
{
upload:
'You are not allowed to upload code for this project.'
,
download:
'You are not allowed to download code from this project.'
,
...
...
@@ -199,7 +203,7 @@ module Gitlab
def
ensure_project_on_push!
(
cmd
,
changes
)
return
if
project
||
deploy_key?
return
unless
receive_pack?
(
cmd
)
&&
changes
==
'_any'
&&
authentication_abilities
.
include?
(
:push_code
)
return
unless
receive_pack?
(
cmd
)
&&
changes
==
ANY
&&
authentication_abilities
.
include?
(
:push_code
)
namespace
=
Namespace
.
find_by_full_path
(
namespace_path
)
...
...
spec/lib/gitlab/git_access_spec.rb
View file @
55723c22
...
...
@@ -14,7 +14,7 @@ describe Gitlab::GitAccess do
let
(
:authentication_abilities
)
{
%i[read_project download_code push_code]
}
let
(
:redirected_path
)
{
nil
}
let
(
:auth_result_type
)
{
nil
}
let
(
:changes
)
{
'_any'
}
let
(
:changes
)
{
Gitlab
::
GitAccess
::
ANY
}
let
(
:push_access_check
)
{
access
.
check
(
'git-receive-pack'
,
changes
)
}
let
(
:pull_access_check
)
{
access
.
check
(
'git-upload-pack'
,
changes
)
}
...
...
@@ -437,7 +437,7 @@ describe Gitlab::GitAccess do
let
(
:project
)
{
nil
}
context
'when changes is _any'
do
let
(
:changes
)
{
'_any'
}
let
(
:changes
)
{
Gitlab
::
GitAccess
::
ANY
}
context
'when authentication abilities include push code'
do
let
(
:authentication_abilities
)
{
[
:push_code
]
}
...
...
@@ -483,7 +483,7 @@ describe Gitlab::GitAccess do
end
context
'when project exists'
do
let
(
:changes
)
{
'_any'
}
let
(
:changes
)
{
Gitlab
::
GitAccess
::
ANY
}
let!
(
:project
)
{
create
(
:project
)
}
it
'does not create a new project'
do
...
...
@@ -497,7 +497,7 @@ describe Gitlab::GitAccess do
let
(
:project_path
)
{
"nonexistent"
}
let
(
:project
)
{
nil
}
let
(
:namespace_path
)
{
user
.
namespace
.
path
}
let
(
:changes
)
{
'_any'
}
let
(
:changes
)
{
Gitlab
::
GitAccess
::
ANY
}
it
'does not create a new project'
do
expect
{
access
.
send
(
:ensure_project_on_push!
,
cmd
,
changes
)
}.
not_to
change
{
Project
.
count
}
...
...
@@ -507,7 +507,7 @@ describe Gitlab::GitAccess do
context
'when pull'
do
let
(
:cmd
)
{
'git-upload-pack'
}
let
(
:changes
)
{
'_any'
}
let
(
:changes
)
{
Gitlab
::
GitAccess
::
ANY
}
context
'when project does not exist'
do
let
(
:project_path
)
{
"new-project"
}
...
...
spec/lib/gitlab/git_access_wiki_spec.rb
View file @
55723c22
...
...
@@ -38,7 +38,7 @@ describe Gitlab::GitAccessWiki do
end
describe
'#access_check_download!'
do
subject
{
access
.
check
(
'git-upload-pack'
,
'_any'
)
}
subject
{
access
.
check
(
'git-upload-pack'
,
Gitlab
::
GitAccess
::
ANY
)
}
before
do
project
.
add_developer
(
user
)
...
...
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