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
Boxiang Sun
gitlab-ce
Commits
65e5cf0a
Commit
65e5cf0a
authored
Jul 10, 2018
by
Tiago Botelho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improves remote message when a developer is unable to push in an empty repository
parent
21a511e4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
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
No files found.
changelogs/unreleased/27456-improve-feedback-when-dev-cannot-push-to-empty-repo.yml
0 → 100644
View file @
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
View file @
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
View file @
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'
}
...
...
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