diff --git a/app/models/protected_branch.rb b/app/models/protected_branch.rb index 7e53ae300d5f20bd154bdd4a5f7fee317a7ac963..ba353afe0f00b708aadb247df6b3db6c653d6171 100644 --- a/app/models/protected_branch.rb +++ b/app/models/protected_branch.rb @@ -52,23 +52,7 @@ def self.protected?(project, ref_name) end def self.allow_force_push?(project, ref_name) - if allow_protected_branches_for_group?(project.group) - protected_branches = project.all_protected_branches.matching(ref_name) - - project_protected_branches, group_protected_branches = protected_branches.partition(&:project_id) - - # Group owner can be able to enforce the settings - return group_protected_branches.any?(&:allow_force_push) if group_protected_branches.present? - return project_protected_branches.any?(&:allow_force_push) if project_protected_branches.present? - - false - else - project.protected_branches.allowing_force_push.matching(ref_name).any? - end - end - - def self.allow_protected_branches_for_group?(group) - Feature.enabled?(:group_protected_branches, group) || Feature.enabled?(:allow_protected_branches_for_group, group) + project.all_protected_branches.allowing_force_push.matching(ref_name).any? end def self.any_protected?(project, ref_names) diff --git a/spec/models/protected_branch_spec.rb b/spec/models/protected_branch_spec.rb index 7574f314600016fcda03a563647bf78efa97d926..7e9e1b09369d3bee0a893d33046c27daf960adf2 100644 --- a/spec/models/protected_branch_spec.rb +++ b/spec/models/protected_branch_spec.rb @@ -570,7 +570,7 @@ where(:group_level_value, :project_level_value, :result) do true | false | true - false | true | false + false | true | true true | nil | true false | nil | false nil | nil | false