Lint your CODEOWNERS file.
Make sure you have version 2.0 or newer of the GitHub CLI installed.
gh extension install heaths/gh-codeowners
The gh extension list
command shows if updates are available for extensions. To upgrade, you can use the gh extension upgrade
command:
gh extension upgrade heaths/gh-codeowners
# Or upgrade all extensions:
gh extension upgrade --all
When used in Continuous Integration, starting with gh
version 2.25.0, you can install or upgrade the extension with a single command:
gh extension install --force heaths/gh-codeowners
Render a list of errors based on the current branch's CODEOWNERS errors reported by GitHub:
gh codeowners lint
You can also get a sorted list of unknown owners or just return the raw JSON:
gh codeowners lint --json
gh codeowners lint --unknown-owners
To see the codeowners for each file in a pull request:
gh codeowners pr 123
The output is rendered as colorful, formatted JSON in terminals but will be compact JSON when piped to another program like jq
:
# Check for added files.
gh codeowners pr 123 | jq '.[] | select(.changeType=="ADDED")'
To render your CODEOWNERS file with errors reported by GitHub:
gh codeowners view
This extension will render colors whenever possible and, in some scenarios like when printing a list of errors, maybe change the format to prefer colors over markers that may work better only for non-colored text.
You can override these colors on the command line (pass --help
for details) or permanently with a configuration file
located under your home directory on all platforms: ~/.config/gh-codeowners/config.yml
color:
comment: "#6A9955"
error: "#F44747"
Licensed under the MIT license.