summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJames Edwards-Jones <jedwardsjones@gitlab.com>2017-04-03 18:59:58 +0100
committerJames Edwards-Jones <jedwardsjones@gitlab.com>2017-04-03 19:19:54 +0100
commitbf3cc824e4ce6cf49a82210eaaf1cca06f7fd281 (patch)
tree04d422fe8b68079ef604348ffe96b1f2b72285ff /lib
parentb8c7bef5c092152ea85d1840e587cfc04293e1d7 (diff)
downloadgitlab-ce-bf3cc824e4ce6cf49a82210eaaf1cca06f7fd281.tar.gz
Moved Project#protected_branch? to ProtectedBranch, similar for tags
Diffstat (limited to 'lib')
-rw-r--r--lib/api/entities.rb2
-rw-r--r--lib/gitlab/checks/change_access.rb4
-rw-r--r--lib/gitlab/user_access.rb6
3 files changed, 6 insertions, 6 deletions
diff --git a/lib/api/entities.rb b/lib/api/entities.rb
index e000e3e33d0..0fe7eb864e4 100644
--- a/lib/api/entities.rb
+++ b/lib/api/entities.rb
@@ -184,7 +184,7 @@ module API
end
expose :protected do |repo_branch, options|
- options[:project].protected_branch?(repo_branch.name)
+ ProtectedBranch.protected?(options[:project], repo_branch.name)
end
expose :developers_can_push do |repo_branch, options|
diff --git a/lib/gitlab/checks/change_access.rb b/lib/gitlab/checks/change_access.rb
index 540d95f2d1f..6f574a41727 100644
--- a/lib/gitlab/checks/change_access.rb
+++ b/lib/gitlab/checks/change_access.rb
@@ -33,7 +33,7 @@ module Gitlab
def protected_branch_checks
return if skip_authorization
return unless @branch_name
- return unless project.protected_branch?(@branch_name)
+ return unless ProtectedBranch.protected?(project, @branch_name)
if forced_push?
return "You are not allowed to force push code to a protected branch on this project."
@@ -85,7 +85,7 @@ module Gitlab
end
def tag_protected?
- project.protected_tag?(@tag_name)
+ ProtectedTag.protected?(project, @tag_name)
end
def push_checks
diff --git a/lib/gitlab/user_access.rb b/lib/gitlab/user_access.rb
index 5a5a4ebd08b..5541a45e948 100644
--- a/lib/gitlab/user_access.rb
+++ b/lib/gitlab/user_access.rb
@@ -34,7 +34,7 @@ module Gitlab
def can_push_tag?(ref)
return false unless can_access_git?
- if project.protected_tag?(ref)
+ if ProtectedTag.protected?(project, ref)
project.protected_tags.matching_refs_accesible_to(ref, user)
else
user.can?(:push_code, project)
@@ -44,7 +44,7 @@ module Gitlab
def can_push_to_branch?(ref)
return false unless can_access_git?
- if project.protected_branch?(ref)
+ if ProtectedBranch.protected?(project, ref)
return true if project.empty_repo? && project.user_can_push_to_empty_repo?(user)
has_access = project.protected_branches.matching_refs_accesible_to(ref, user, action: :push)
@@ -58,7 +58,7 @@ module Gitlab
def can_merge_to_branch?(ref)
return false unless can_access_git?
- if project.protected_branch?(ref)
+ if ProtectedBranch.protected?(project, ref)
project.protected_branches.matching_refs_accesible_to(ref, user, action: :merge)
else
user.can?(:push_code, project)