Commit 12e68d62 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Validate `:push_code` before checking protected branches

parent d11fbccc
...@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment