Handy tool for working with file ownership using Githubs CODEOWNERS file
npm install @snyk/github-codeownersA CLI tool for working with GitHub CODEOWNERS.
Things it does:
* Calculate ownership stats
* Find out who owns each and every file (ignoring files listed in .gitignore)
* Find out who owns a single file
* Find out who owns your staged files
* Outputs in a bunch of script friendly handy formats for integrations (CSV and JSONL)
* Validates that your CODEOWNERS file is valid
``shell script`
$ npm i -g github-codeowners
$ github-codeowners --help
Usage: github-codeowners [options] [command]
shell script
$ cd
$ github-codeowners audit
README.md
package.json
src/cli.ts @jjmschofield
...
`Ownership stats:
`shell script
$ github-codeowners audit -s
--- Counts ---
Total: 24 files (1378 lines) 100%
Loved: 10 files (494 lines) 41.6%
Unloved: 14 files (884 lines) 58.4%
--- Owners ---
@jjmschofield: 10 files (494 lines) 41.6%
`Only files in a specific directory:
`shell script
$ github-codeowners audit -r src/
src/cli.ts @jjmschofield
src/commands/audit.ts @jjmschofield
...
`Only unowned files:
`shell script
$ github-codeowners audit -u
.github/CODEOWNERS
.gitignore
`Output in JSONL:
`shell script
$ github-codeowners audit -o jsonl
{"path":"src/commands/audit.ts","owners":["@jjmschofield"],"lines":48}
...
`Output in CSV:
`shell script
$ github-codeowners audit -o csv
src/commands/audit.ts,@jjmschofield
`Full usage information:
`shell script
$ github-codeowners audit --help
Usage: github-codeowners audit [options]list the owners for all files
Options:
-d, --dir path to VCS directory (default: "")
-c, --codeowners path to codeowners file (default: "/.github/CODEOWNERS")
-o, --output how to output format eg: simple, jsonl, csv (default: "simple")
-u, --unloved unowned files only (default: false)
-g, --only-git consider only files tracked by git (default: false)
-s, --stats output stats (default: true)
-r, --root the root path to filter files by (default: "")
-h, --help output usage information
`$3
Tells you who owns a given file or files:
`shell script
$ cd
$ github-codeowners who
@some/team
@some/team
`Full usage:
`shell script
$ github-codeowners who --help
Usage: github-codeowners who [options] lists owners of a specific file or files
Options:
-d, --dir path to VCS directory (default: "/Users/jjmschofield/projects/github/snyk/registry")
-c, --codeowners path to codeowners file (default: "/.github/CODEOWNERS")
-o, --output how to output format eg: simple, jsonl, csv (default: "simple")
-h, --help output usage information
`$3
Provides a list of files with their owners between commits (against the current version of CODEOWNERS).Ownership of all files staged for commit:
`shell script
$ cd
$ github-codeowners git
`Ownership of files existing at a specific commit:
`shell script
$ github-codeowners git
`Ownership of files changed between two commits:
`shell script
$ github-codeowners git
`Output stats:
`shell script
$ github-codeowners git -s
`Full usage:
`shell script
$ github-codeowners git --help
Usage: github-codeowners git [options] [shaA] [shaB]lists owners of files changed between commits, a commit against head or staged against head.
Options:
-d, --dir path to VCS directory (default: "/Users/jjmschofield/projects/github/snyk/registry")
-c, --codeowners path to codeowners file (default: "/.github/CODEOWNERS")
-o, --output how to output format eg: simple, jsonl, csv (default: "simple")
-s, --stats output stats, note line counts are not available for this command (default: false)
-h, --help output usage information
`$3
Validates your CODEOWNERS file to find common mistakes, will throw on errors (such as malformed owners).
`shell script
$ cd
$ github-codeowners validate
Found duplicate rules [ 'some/duplicate/rule @octocat' ]
Found rules which did not match any files [ 'some/non-existent/path @octocat' ]
...
`Full usage information:
`shell script
$ github-codeowners validate --help
Usage: github-codeowners validate [options]Validates a CODOWNER file and files in dir
Options:
-d, --dir path to VCS directory (default: "")
-c, --codeowners path to codeowners file (default: "/.github/CODEOWNERS")
-r, --root the root path to filter files by (default: "")
-h, --help output usage information
`Output Formats
Check github-codeowners for support for a given command, however generally the following outputs are supported:
* simple - tab delimited - terminal friendly output
* jsonl - line separated json - useful for streaming data to another command
* csv` - csv delimited fields - useful to import into a spreadsheet tool of your choiceThis project is a fork of jjmschofield's version.