Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Edwards-Jones <jedwardsjones@gitlab.com>2017-04-03 17:17:24 +0300
committerJames Edwards-Jones <jedwardsjones@gitlab.com>2017-04-03 19:19:53 +0300
commit65f3d5062f081d8f8ebf727a3408650d90ec9711 (patch)
tree0246397bd1a234ce9f34b9145321a1c4e40c1cd4 /lib/gitlab/user_access.rb
parenta7c71c7f292c9cdf892f7d33dfb52d7e16af28e6 (diff)
Extract ProtectedRef Concern
Diffstat (limited to 'lib/gitlab/user_access.rb')
-rw-r--r--lib/gitlab/user_access.rb11
1 files changed, 3 insertions, 8 deletions
diff --git a/lib/gitlab/user_access.rb b/lib/gitlab/user_access.rb
index 921159d91ef..5a5a4ebd08b 100644
--- a/lib/gitlab/user_access.rb
+++ b/lib/gitlab/user_access.rb
@@ -35,10 +35,7 @@ module Gitlab
return false unless can_access_git?
if project.protected_tag?(ref)
- access_levels = project.protected_tags.matching(ref).map(&:push_access_levels).flatten
- has_access = access_levels.any? { |access_level| access_level.check_access(user) }
-
- has_access
+ project.protected_tags.matching_refs_accesible_to(ref, user)
else
user.can?(:push_code, project)
end
@@ -50,8 +47,7 @@ module Gitlab
if project.protected_branch?(ref)
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
- has_access = access_levels.any? { |access_level| access_level.check_access(user) }
+ has_access = project.protected_branches.matching_refs_accesible_to(ref, user, action: :push)
has_access || !project.repository.branch_exists?(ref) && can_merge_to_branch?(ref)
else
@@ -63,8 +59,7 @@ module Gitlab
return false unless can_access_git?
if project.protected_branch?(ref)
- access_levels = project.protected_branches.matching(ref).map(&:merge_access_levels).flatten
- access_levels.any? { |access_level| access_level.check_access(user) }
+ project.protected_branches.matching_refs_accesible_to(ref, user, action: :merge)
else
user.can?(:push_code, project)
end