Skip to content

Add branchProtection under project.branchRules in graphql endpoint

What does this MR do and why?

#362706 (closed) -> #372362 (closed)

Adds branchProtection node under project.branchRules to display information about the protections for a given branch

We're attempting to re-use the current architecture for the Branch Rule MVP which is why the resolver returns the parent object (ProtectedBranch served as project.branchRules e.g. project.branchRules[0] and project.branchRules[0].branchProtection are the same object). We do this to display the information in logically grouped datasets (later we will add approvalRules, securityPolicies, statusChecks as separate nodes under branchRules)

How to set up and validate locally

  1. Find a project.full_path of a project that has at least one protected branch
       project = ProtectedBranch.last.project
       project.full_path
  2. Test permissions by assigning yourself as a guest to the project
      # user = User.find_by(email: "YOUR_EMAIL") # Use this if you do not use the default admin user in GDK
      user = User.find_by(email: "admin@example.com")
      project.add_guest(user)
  3. Visit http://gdk.test:3000/-/graphql-explorer
  4. Execute the following query, replace the full path value (as guest you should not see any rules)
     {
       project(fullPath: "FULL_PATH") {
         branchRules {
           nodes {
             name
             branchProtection {
               allowForcePush
               codeOwnerApprovalRequired
             }
           }
         }
       }
     }
  5. Make yourself a maintainer
      project.add_maintainer(user)
  6. Execute the following query, replace the full path value (as maintainer you should see all the rules)
     {
       project(fullPath: "FULL_PATH") {
         branchRules {
           nodes {
             name
             branchProtection {
               allowForcePush
               codeOwnerApprovalRequired
             }
           }
         }
       }
     }

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Joe Woodward

Merge request reports

Loading