diff options
author | Douwe Maan <douwe@gitlab.com> | 2018-04-24 17:49:38 +0300 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2018-04-24 17:49:38 +0300 |
commit | 906fc00c33611ca2e5e3e66892cc990b05071d9f (patch) | |
tree | 47ed9620065c142ce1bc16cf786d88a0c58afaec /lib | |
parent | 17ffd9987310b7f944d0fef7519fc9e22572ebc5 (diff) | |
parent | 35a49922e66ed9dc55685163126e1bee0a4e3dec (diff) |
Merge branch 'bvl-fix-maintainer-push-error' into 'master'
Fix errors on pushing/editing files on empty repositories
Closes #44618 and #42583
See merge request gitlab-org/gitlab-ce!18462
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 |