summaryrefslogtreecommitdiff
path: root/lib/gitlab/user_access.rb
diff options
context:
space:
mode:
authorPawel Chojnacki <pawel@chojnacki.ws>2017-01-05 12:40:54 +0100
committerPawel Chojnacki <pawel@chojnacki.ws>2017-01-13 10:53:59 -0500
commiteb9b96405498e37b25aa32876b0e101d1880f4e9 (patch)
tree007d1372f4b2b9429bdc9f32c54e2e72ed994658 /lib/gitlab/user_access.rb
parentc3c053def2e59300211d33834701e6519659b0c6 (diff)
downloadgitlab-ce-eb9b96405498e37b25aa32876b0e101d1880f4e9.tar.gz
Allow creating protected branch when it doesn't exist
if user has either push or merge permissions + Change log entry for fix to creating a branch matching a wildcard fails
Diffstat (limited to 'lib/gitlab/user_access.rb')
-rw-r--r--lib/gitlab/user_access.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/gitlab/user_access.rb b/lib/gitlab/user_access.rb
index 6c7e673fb9f..6ce9b229294 100644
--- a/lib/gitlab/user_access.rb
+++ b/lib/gitlab/user_access.rb
@@ -35,7 +35,9 @@ module Gitlab
return true if project.empty_repo? && project.user_can_push_to_empty_repo?(user)
access_levels = project.protected_branches.matching(ref).map(&:push_access_levels).flatten
- access_levels.any? { |access_level| access_level.check_access(user) }
+ has_access = access_levels.any? { |access_level| access_level.check_access(user) }
+
+ has_access || !project.repository.branch_exists?(ref) && can_merge_to_branch?(ref)
else
user.can?(:push_code, project)
end