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
12e68d62
Commit
12e68d62
authored
Mar 08, 2018
by
Bob Van Landuyt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Validate `:push_code` before checking protected branches
parent
d11fbccc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
6 deletions
+3
-6
lib/gitlab/user_access.rb
lib/gitlab/user_access.rb
+3
-6
No files found.
lib/gitlab/user_access.rb
View file @
12e68d62
...
@@ -63,15 +63,12 @@ module Gitlab
...
@@ -63,15 +63,12 @@ module Gitlab
request_cache
def
can_push_to_branch?
(
ref
)
request_cache
def
can_push_to_branch?
(
ref
)
return
false
unless
can_access_git?
return
false
unless
can_access_git?
return
false
unless
user
.
can?
(
:push_code
,
project
)
||
project
.
branch_allows_maintainer_push?
(
user
,
ref
)
if
protected
?(
ProtectedBranch
,
project
,
ref
)
if
protected
?(
ProtectedBranch
,
project
,
ref
)
return
true
if
project
.
user_can_push_to_empty_repo?
(
user
)
project
.
user_can_push_to_empty_repo?
(
user
)
||
protected_branch_accessible_to?
(
ref
,
action:
:
push
)
protected_branch_accessible_to?
(
ref
,
action:
:
push
)
elsif
user
.
can?
(
:push_code
,
project
)
true
else
else
project
.
branch_allows_maintainer_push?
(
user
,
ref
)
true
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