Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
65e5cf0a
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,发现更多精彩内容 >>
提交
65e5cf0a
编写于
7月 10, 2018
作者:
T
Tiago Botelho
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improves remote message when a developer is unable to push in an empty repository
上级
21a511e4
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
39 addition
and
1 deletion
+39
-1
changelogs/unreleased/27456-improve-feedback-when-dev-cannot-push-to-empty-repo.yml
...6-improve-feedback-when-dev-cannot-push-to-empty-repo.yml
+5
-0
lib/gitlab/checks/change_access.rb
lib/gitlab/checks/change_access.rb
+24
-1
spec/lib/gitlab/checks/change_access_spec.rb
spec/lib/gitlab/checks/change_access_spec.rb
+10
-0
未找到文件。
changelogs/unreleased/27456-improve-feedback-when-dev-cannot-push-to-empty-repo.yml
0 → 100644
浏览文件 @
65e5cf0a
---
title
:
Improve feedback when a developer is unable to push to an empty repository
merge_request
:
20519
author
:
type
:
changed
lib/gitlab/checks/change_access.rb
浏览文件 @
65e5cf0a
...
...
@@ -93,7 +93,7 @@ module Gitlab
end
else
unless
user_access
.
can_push_to_branch?
(
branch_name
)
raise
GitAccess
::
UnauthorizedError
,
ERROR_MESSAGES
[
:push_protected_branch
]
raise
GitAccess
::
UnauthorizedError
,
push_to_protected_branch_rejected_message
end
end
end
...
...
@@ -140,6 +140,29 @@ module Gitlab
private
def
push_to_protected_branch_rejected_message
if
project
.
empty_repo?
empty_project_push_message
else
ERROR_MESSAGES
[
:push_protected_branch
]
end
end
def
empty_project_push_message
<<~
MESSAGE
A default branch (e.g. master) does not yet exist for
#{
project
.
full_path
}
Ask a project Owner or Maintainer to create a default branch:
#{
project_members_url
}
MESSAGE
end
def
project_members_url
Gitlab
::
Routing
.
url_helpers
.
project_project_members_url
(
project
)
end
def
should_run_commit_validations?
commit_check
.
validate_lfs_file_locks?
end
...
...
spec/lib/gitlab/checks/change_access_spec.rb
浏览文件 @
65e5cf0a
...
...
@@ -132,6 +132,16 @@ describe Gitlab::Checks::ChangeAccess do
expect
{
subject
.
exec
}.
to
raise_error
(
Gitlab
::
GitAccess
::
UnauthorizedError
,
'You are not allowed to push code to protected branches on this project.'
)
end
context
'when project repository is empty'
do
let
(
:project
)
{
create
(
:project
)
}
it
'raises an error if the user is not allowed to push to protected branches'
do
expect
(
user_access
).
to
receive
(
:can_push_to_branch?
).
and_return
(
false
)
expect
{
subject
.
exec
}.
to
raise_error
(
Gitlab
::
GitAccess
::
UnauthorizedError
,
/Ask a project Owner or Maintainer to create a default branch/
)
end
end
context
'branch deletion'
do
let
(
:newrev
)
{
'0000000000000000000000000000000000000000'
}
let
(
:ref
)
{
'refs/heads/feature'
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录