Skip to content

Group-level protected branch - policy and services

What does this MR do and why?

Related to #372816 (closed), solved these points:

  1. Update ProtectedBranchPolicy to handle both projects as well as groups.
    • When the user can maintainer_access the group, then he can manage protected_branch(This is following the policy of the group-level push rules)
    • Remove the group { nil } in the protected branch factory, now we can create the group-level protected branch:
      # In the specs
      create(:protected_branch, group: group)
  2. Update services of protected branches to handle both projects as well as groups.
    • Add a feature flag group_protected_branches.
    • Add a premium license group_protected_branches.
    • Update the services about protected branches to support group-level.

I split other points to other MRs to reduce the size of the MR, other MRs will be coming soon.

How to set up and validate locally

  1. Enable the invite modal
    Feature.enable(:group_protected_branches)
  2. Running the these tests to validate the features:
    rspec spec/models/group_spec.rb
    rspec ee/spec/policies/protected_branch_policy_spec.rb
    rspec spec/services/protected_branches/
    rspec ee/spec/services/ee/protected_branches/

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