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
19edeba8
Commit
19edeba8
authored
Apr 28, 2017
by
Pawel Chojnacki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent people from creating branches if they don't have persmission to push
parent
61046e75
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
5 deletions
+7
-5
changelogs/unreleased/28968-prevent-people-from-creating-branches-if-they-don-have-permission-to-push.yml
...creating-branches-if-they-don-have-permission-to-push.yml
+4
-0
lib/gitlab/user_access.rb
lib/gitlab/user_access.rb
+1
-3
spec/lib/gitlab/user_access_spec.rb
spec/lib/gitlab/user_access_spec.rb
+2
-2
No files found.
changelogs/unreleased/28968-prevent-people-from-creating-branches-if-they-don-have-permission-to-push.yml
0 → 100644
View file @
19edeba8
---
title
:
Prevent people from creating branches if they don't have persmission to push
merge_request
:
author
:
lib/gitlab/user_access.rb
View file @
19edeba8
...
@@ -44,9 +44,7 @@ module Gitlab
...
@@ -44,9 +44,7 @@ module Gitlab
if
ProtectedBranch
.
protected?
(
project
,
ref
)
if
ProtectedBranch
.
protected?
(
project
,
ref
)
return
true
if
project
.
empty_repo?
&&
project
.
user_can_push_to_empty_repo?
(
user
)
return
true
if
project
.
empty_repo?
&&
project
.
user_can_push_to_empty_repo?
(
user
)
has_access
=
project
.
protected_branches
.
protected_ref_accessible_to?
(
ref
,
user
,
action: :push
)
project
.
protected_branches
.
protected_ref_accessible_to?
(
ref
,
user
,
action: :push
)
has_access
||
!
project
.
repository
.
branch_exists?
(
ref
)
&&
can_merge_to_branch?
(
ref
)
else
else
user
.
can?
(
:push_code
,
project
)
user
.
can?
(
:push_code
,
project
)
end
end
...
...
spec/lib/gitlab/user_access_spec.rb
View file @
19edeba8
...
@@ -87,10 +87,10 @@ describe Gitlab::UserAccess, lib: true do
...
@@ -87,10 +87,10 @@ describe Gitlab::UserAccess, lib: true do
expect
(
access
.
can_push_to_branch?
(
branch
.
name
)).
to
be_falsey
expect
(
access
.
can_push_to_branch?
(
branch
.
name
)).
to
be_falsey
end
end
it
'returns
true if branch does not exist and user has permission to merge
'
do
it
'returns
false if branch does not exist
'
do
project
.
team
<<
[
user
,
:developer
]
project
.
team
<<
[
user
,
:developer
]
expect
(
access
.
can_push_to_branch?
(
not_existing_branch
.
name
)).
to
be_
truth
y
expect
(
access
.
can_push_to_branch?
(
not_existing_branch
.
name
)).
to
be_
false
y
end
end
end
end
...
...
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