diff options
author | Bob Van Landuyt <bob@vanlanduyt.co> | 2018-04-18 15:52:55 +0200 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2018-04-24 14:06:59 +0200 |
commit | 35a49922e66ed9dc55685163126e1bee0a4e3dec (patch) | |
tree | 57f58e6616deaf38490a45f01f5d6c897364985b /lib | |
parent | aeed6b5a34e2c1c98a374e6c6178d84e07779531 (diff) | |
download | gitlab-ce-35a49922e66ed9dc55685163126e1bee0a4e3dec.tar.gz |
Allow admins to push to empty repos
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/user_access.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/gitlab/user_access.rb b/lib/gitlab/user_access.rb index 69952cbb47c..8cf5d636743 100644 --- a/lib/gitlab/user_access.rb +++ b/lib/gitlab/user_access.rb @@ -63,10 +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) + return false unless project + + return false if !user.can?(:push_code, project) && !project.branch_allows_maintainer_push?(user, ref) if protected?(ProtectedBranch, project, ref) - project.user_can_push_to_empty_repo?(user) || protected_branch_accessible_to?(ref, action: :push) + protected_branch_accessible_to?(ref, action: :push) else true end @@ -101,6 +103,7 @@ module Gitlab def protected_branch_accessible_to?(ref, action:) ProtectedBranch.protected_ref_accessible_to?( ref, user, + project: project, action: action, protected_refs: project.protected_branches) end @@ -108,6 +111,7 @@ module Gitlab def protected_tag_accessible_to?(ref, action:) ProtectedTag.protected_ref_accessible_to?( ref, user, + project: project, action: action, protected_refs: project.protected_tags) end |