Group-level protected branch - controllers
requested to merge gitlab-jh/jh-team/gitlab:feature/group-level-protected-branch-backend-2 into master
What does this MR do and why?
Related to #372816 (closed), this MR is followed up !104355 (merged), solved these points:
- Create
Groups::ProtectedBranchesController
similar toProjects::ProtectedBranchesController
. This will be used by frontend to create new protected branches for a group. - Update
Groups::Settings::RepositoryController
and create an instance variable like@protected_branches = @group.protected_branches.order(:name).page(params[:page])
. This will be used by the frontend to list the protected branches on the group settings page. - Update the
show
method ofProjects::Settings::RepositoryController
to return@protected_branches
as well as@protected_group_branches
where@protected_group_branches = @project.root_namespace.protected_branches.order(:name).page(params[:page])
. Frontend can use the new variable@protected_group_branches
to distinguish the protected branches defined at the group level and mark them as locked as per the UI. This should be behind a feature flag.
There is one last MR left before this issue is fully completed.
How to set up and validate locally
-
Enable the feature flag
Feature.enable(:group_protected_branches)
-
Running the these tests to validate the features:
rspec ee/spec/requests/groups/protected_branches_controller_spec.rb rspec ee/spec/requests/ee/groups/settings/repository_controller_spec.rb rspec spec/controllers/projects/settings/repository_controller_spec.rb
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
/cc EM @daveliu
Edited by Song Huang