Skip to content

Draft: Resolve "Group-level protected branches - Backend create and show"

What does this MR do and why?

Closes #1188 (closed)

  1. Update ProtectedBranchPolicy to handle both projects as well as groups.

  2. Create Groups::ProtectedBranchesController similar to Projects::ProtectedBranchesController. This will be used by frontend to create new protected branches for a group.

  3. 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.

  4. 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.

  5. Add these helper methods to the projects model so that it can be used at other places.

    def group_protected_branches
      root_namespace.protected_branches
    end
    
    def all_protected_branches
      protected_branches + group_protected_branches
    end
  6. Find and update the usage of project.protected_branches with project.all_branches at the required places in the codebase. This should be behind a feature flag.

  7. FF group_protected_branches

  8. GitLab Premium License

Song Huang 编辑于

合并请求报告

加载中