Use new json column for default branch protection
What does this MR do and why?
Use new json column for default branch protection
This commit adds the functionality to start using new json column for creating default branch protection instead of using the old integer column
EE: true
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
Before | After |
---|---|
How to set up and validate locally
Use API put groups/:id to update default branch protection settings, when the feature flag is disabled use the below json body:
{
"default_branch_protection": 2
}
When the feature flag is enabled use the below json body:
{
"default_branch_protection_defaults": {
"allowed_to_push": [
{
"access_level": 40
}
],
"allow_force_push": false,
"allowed_to_merge": [
{
"access_level": 40
}
]
}
}
For the json values for each setting, you can refer to class https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/access/branch_protection.rb?ref_type=heads
and call Gitlab::Access::BranchProtection.new(level).to_hash
this will give you converted values from integer to json.
- Enable feature flag: default_branch_protection_defaults
- Change default branch protection setting using group put API
- Create a project and check we have correct protected branches.
setting | feature flag disabled | feature flag enabled |
---|---|---|
Protection None | ||
Protection Partial | ||
Protected Fully | ||
Protected Against Developer Pushes | ||
Developer can initial push |
Related to #408152 (closed)