Prevent default branch from being changed if setting is present
Why are we doing this work
- if the default branch is included in an enabled policy with
block_unprotecting_branches: true, the branch should not be able to be removed as the default branch
Relevant links
Non-functional requirements
-
Documentation: -
Feature flag: -
Performance: -
Testing:
Implementation plan
-
backend add validation for if a default branch can/cannot be changed -
frontend disable the save button at `/-/settings/repository#default-branch
Verification steps
- Upload a GitLab Ultimate license
- Enable the feature flags
echo "Feature.enable(:scan_result_policies_block_unprotecting_branches)" | rails c
- Go to Project => Settings => Repository => Branch defaults => Make
mainthe default branch - Go to Secure -> Policies -> New policy -> Scan Result Policy
- Go to yaml mode
- Use this policy:
type: scan_result_policy
name: Require approval for vulnerabilities
description: ''
enabled: true
rules:
- type: scan_finding
scanners: []
vulnerabilities_allowed: 0
severity_levels: []
vulnerability_states: []
branch_type: protected
actions:
- type: require_approval
approvals_required: 1
role_approvers:
- maintainer
- developer
approval_settings:
block_unprotecting_branches: true
- Save the policy
- Go the Project => Settings => Repository => Branch defaults
- Verify the default branch cannot be changed and a popover shows up over the button
Edited by Alexander Turinske
