Skip to content

Extended Repository gql type with CODEOWNERS path

Denys Mishunov requested to merge 389419-link-to-codeowners into master

What does this MR do and why?

The MR extends the GraphQL schema with codeOwnersPath field on the Repository. The field takes one optional argument - branch_name to return correct path to the CODEOWNERS file in a particular branch since the file's location might differ in different branches.

How to set up and validate locally

  1. Go to a project in your local GDK and add (or make sure it exists) the CODEOWNERS file at one of the pre-defined places:
  • project's root,
  • docs/, or
  • .gitlab/
  1. Create a new branch by removing this newly-created file. The new branch should not contain CODEOWNERS
  2. Add the new CODEOWNERS in this new branch, but in a place other than at step 1.
  3. Open graphql-explorer (at /-/graphql-explorer in your local GDK) and add the following data:

Query:

query getCodeOwnersPathInfo($projectPath: ID!, $branchName: String!) {
  project(fullPath: $projectPath) {
    repository {
      codeOwnersPath(branchName: $branchName)
    }
  }
}

Query variables:

{
  "projectPath": YOUR_PROJECT_PATH, // for example, `"flightjs/Flight"`
  "branchName": ONE_OF_THE_TWO      // for example, `master`
}

In the variables, projectPath will be the unchanged,

  1. Run the query with the name of the branch from p.1 assigned to branchName. Make sure the codeOwnersPath is returned with the correct path for that branch
  2. Change branchName to the name of the branch from p.3 and run the query again. Make sure the codeOwnersPath is changed and is returned with the correct path for that second branch

MR acceptance checklist

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

Related to #389419 (closed)

Edited by Denys Mishunov

Merge request reports