Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
55723c22
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
55723c22
编写于
12月 20, 2018
作者:
D
Douwe Maan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move magic '_any' string to constant
上级
28cffb9f
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
12 addition
and
10 deletion
+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
未找到文件。
app/controllers/projects/git_http_controller.rb
浏览文件 @
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
浏览文件 @
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
浏览文件 @
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
浏览文件 @
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
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录