diff options
Diffstat (limited to 'app/models/protected_branch.rb')
-rw-r--r-- | app/models/protected_branch.rb | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/app/models/protected_branch.rb b/app/models/protected_branch.rb index c59ef4cd80b..050db3b6870 100644 --- a/app/models/protected_branch.rb +++ b/app/models/protected_branch.rb @@ -8,11 +8,9 @@ class ProtectedBranch < ApplicationRecord validate :validate_either_project_or_top_group - scope :requiring_code_owner_approval, - -> { where(code_owner_approval_required: true) } - - scope :allowing_force_push, - -> { where(allow_force_push: true) } + scope :requiring_code_owner_approval, -> { where(code_owner_approval_required: true) } + scope :allowing_force_push, -> { where(allow_force_push: true) } + scope :sorted_by_name, -> { order(name: :asc) } protected_ref_access_levels :merge, :push @@ -106,6 +104,10 @@ class ProtectedBranch < ApplicationRecord name == project.default_branch end + def entity + group || project + end + private def validate_either_project_or_top_group @@ -113,7 +115,7 @@ class ProtectedBranch < ApplicationRecord errors.add(:base, _('must be associated with a Group or a Project')) elsif project && group errors.add(:base, _('cannot be associated with both a Group and a Project')) - elsif group && group.root_ancestor != group + elsif group && group.subgroup? errors.add(:base, _('cannot be associated with a subgroup')) end end |