Push rule created without inheritance in repository settings controller
Summary
The EE::Projects::Settings::RepositoryController creates push rules without proper inheritance from group or organization-level predefined push rules. This bypasses the intended inheritance mechanism and creates empty push rules instead of inheriting from parent configurations.
Current Behavior
In ee/app/controllers/ee/projects/settings/repository_controller.rb, the controller directly creates a push rule using:
push_rule = project.create_push_rule
project.project_setting.update(push_rule_id: push_rule.id)
Expected Behavior
The controller should use the PushRules::CreatePredefinedRuleService to properly inherit push rules from:
- Group-level predefined push rules (when available)
- Organization-level predefined push rules (when available)
This service handles the inheritance logic and ensures that projects inherit the appropriate push rule configuration from their parent group or organization.
Proposed Solution
Replace the direct project.create_push_rule call with:
PushRules::CreatePredefinedRuleService
.new(container: project)
.execute
This approach is already used correctly in the EE::Projects::CreateService for new projects and should be consistent across the codebase.
Impact
- Projects may not inherit group or organization-level push rule configurations when accessing repository settings
- Inconsistent behavior between project creation and repository settings access
- Users may need to manually configure push rules that should be inherited automatically
Additional Context
The PushRules::CreatePredefinedRuleService properly handles:
- Feature flag checks (
read_and_write_group_push_rules,read_organization_push_rules) - Inheritance from group predefined push rules
- Inheritance from organization predefined push rules
- Setting
is_sampleto false for inherited rules - Proper association with
project.project_setting
This is a bug that affects push rule inheritance consistency across GitLab.