Add branchRules to project in graphql endpoint
What does this MR do and why?
This MR add a paginated branchRules node to the projects query. The returned values are actually protected branches. In a future MR we will add additional nodes nested within the branchRules node containing information about the different types of branch rules. This information will be presented in a single location as part of an ongoing effort to improve the UX.
#362706 (closed) -> #372362 (closed)
I have added a new ability to the protected branches policy which currently follows the same rules as the create/update/destroy abilities.
How to set up and validate locally
- Find a project.full_path of a project that has at least one protected branch
project = ProtectedBranch.last.project project.full_path
- 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)
- Visit http://gdk.test:3000/-/graphql-explorer
- Execute the following query, replace the full path value (as guest you should not see any rules)
{ project(fullPath: "FULL_PATH") { branchRules { nodes { name } } } }
- Make yourself a maintainer
project.add_maintainer(user)
- Execute the following query, replace the full path value (as maintainer you should see all the rules)
{ project(fullPath: "FULL_PATH") { branchRules { nodes { name } } } }
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.
Edited by Joe Woodward