Skip to content

Group-level protected branch - controllers

What does this MR do and why?

Related to #372816 (closed), this MR is followed up !104355 (merged), solved these points:

  1. Create Groups::ProtectedBranchesController similar to Projects::ProtectedBranchesController. This will be used by frontend to create new protected branches for a group.
  2. 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.
  3. Update the show method of Projects::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

  1. Enable the feature flag

    Feature.enable(:group_protected_branches)
  2. 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.

/cc EM @daveliu

Edited by Song Huang

Merge request reports