Skip to content

Create logic to find branch rules without protected branches

Joe Woodward requested to merge feat/branch-rule-finder into master

What does this MR do and why?

Related issue: #375617 (closed)

Adds All branches to the list of branch rules. Since approval rules and external status checks can be created for All branches, they are not linked to a specific protected branch. This MR compiles an All branches rule from the approval rules and status checks and make it behave as if it's a branch rule. It returned as a general branch rule in GraphQL response, but needs some frontend changes to display it correctly on project-settings page.

To verify it:

query getBranchRulesEE {
  project(fullPath: "gitlab-org/gitlab-shell") {
    id
    branchRules {
      nodes {
        name
        isDefault
        matchingBranchesCount
        branchProtection {
          allowForcePush
          codeOwnerApprovalRequired
          mergeAccessLevels {
            edges {
              node {
                accessLevel
                accessLevelDescription
                group {
                  id
                }
                user {
                  id
                }
              }
            }
          }
          pushAccessLevels {
            edges {
              node {
                accessLevel
                accessLevelDescription
                group {
                  id
                }
                user {
                  id
                }
              }
            }
          }
          unprotectAccessLevels {
            edges {
              node {
                accessLevel
                accessLevelDescription
                group {
                  id
                }
                user {
                  id
                }
              }
            }
          }
        }
        externalStatusChecks {
          nodes {
            id
            name
          }
        }
        approvalRules {
          nodes {
            id
            name
          }
        }
      }
    }
  }
}
Edited by Igor Drozdov

Merge request reports

Loading