summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Van Landuyt <bob@vanlanduyt.co>2018-03-08 00:08:52 +0100
committerBob Van Landuyt <bob@vanlanduyt.co>2018-03-08 00:37:59 +0100
commit12e68d621512ea65f110081fc2d8ed1f385e6cfa (patch)
tree47c8813f17db19a18e4924a547c7545bf6207c7c
parentd11fbccc8dda310f6a3530d04f102d6dcf80941c (diff)
downloadgitlab-ce-bvl-port-ee-improvements-from-maintainer-push.tar.gz
Validate `:push_code` before checking protected branchesbvl-port-ee-improvements-from-maintainer-push
-rw-r--r--lib/gitlab/user_access.rb9
1 files changed, 3 insertions, 6 deletions
diff --git a/lib/gitlab/user_access.rb b/lib/gitlab/user_access.rb
index fd68b9f2b48..24393f96d96 100644
--- a/lib/gitlab/user_access.rb
+++ b/lib/gitlab/user_access.rb
@@ -63,15 +63,12 @@ module Gitlab
request_cache def can_push_to_branch?(ref)
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)
- return true if project.user_can_push_to_empty_repo?(user)
-
- protected_branch_accessible_to?(ref, action: :push)
- elsif user.can?(:push_code, project)
- true
+ project.user_can_push_to_empty_repo?(user) || protected_branch_accessible_to?(ref, action: :push)
else
- project.branch_allows_maintainer_push?(user, ref)
+ true
end
end