diff options
author | James Edwards-Jones <jedwardsjones@gitlab.com> | 2017-04-03 20:59:58 +0300 |
---|---|---|
committer | James Edwards-Jones <jedwardsjones@gitlab.com> | 2017-04-03 21:19:54 +0300 |
commit | bf3cc824e4ce6cf49a82210eaaf1cca06f7fd281 (patch) | |
tree | 04d422fe8b68079ef604348ffe96b1f2b72285ff /app/models/protected_branch.rb | |
parent | b8c7bef5c092152ea85d1840e587cfc04293e1d7 (diff) |
Moved Project#protected_branch? to ProtectedBranch, similar for tags
Diffstat (limited to 'app/models/protected_branch.rb')
-rw-r--r-- | app/models/protected_branch.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/app/models/protected_branch.rb b/app/models/protected_branch.rb index a0dbcf80c3d..eca8d5e0f7d 100644 --- a/app/models/protected_branch.rb +++ b/app/models/protected_branch.rb @@ -10,4 +10,12 @@ class ProtectedBranch < ActiveRecord::Base accepts_nested_attributes_for :push_access_levels accepts_nested_attributes_for :merge_access_levels + + # Check if branch name is marked as protected in the system + def self.protected?(project, ref_name) + return true if project.empty_and_default_branch_protected? + + protected_refs = project.protected_branches_array + self.matching(ref_name, protected_refs: protected_refs).present? + end end |