# README
codeowners
A CLI and Go library for GitHub's CODEOWNERS file.
Installation
Install the CLI from the homebrew tap.
$ brew tap hmarr/tap
$ brew install codeowners
Install the library with go get
.
$ go get github.com/hmarr/codeowners@latest
Command line usage
By default, the command line tool will walk the directory tree, printing the code owners of any files that are found.
$ codeowners --help
usage: codeowners <path>...
-f, --file string CODEOWNERS file path
-h, --help show this help message
-o, --owner strings filter results by owner
$ ls
CODEOWNERS DOCUMENTATION.md README.md example.go example_test.go
$ cat CODEOWNERS
*.go @example/go-engineers
*.md @example/docs-writers
README.md [email protected]
$ codeowners
CODEOWNERS (unowned)
README.md [email protected]
example_test.go @example/go-engineers
example.go @example/go-engineers
DOCUMENTATION.md @example/docs-writers
To limit the files the tool looks at, provide one or more paths as arguments.
$ codeowners *.md
README.md [email protected]
DOCUMENTATION.md @example/docs-writers
Pass the --owner
flag to filter results by a specific owner.
$ codeowners -o @example/go-engineers
example_test.go @example/go-engineers
example.go @example/go-engineers
Go library usage
Documentation is available at pkg.go.dev.
package main
import (
"fmt"
"log"
"os"
"github.com/hmarr/codeowners"
)
func main() {
file, err := os.Open("CODEOWNERS")
if err != nil {
log.Fatal(err)
}
ruleset, err := codeowners.ParseFile(file)
if err != nil {
log.Fatal(err)
}
rule, err := ruleset.Match("path/to/file")
if err != nil {
log.Fatal(err)
}
fmt.Printf("Owners: %v\n", rule.Owners)
}
# Packages
No description provided by the author
# Functions
LoadFile loads and parses a CODEOWNERS file at the path specified.
LoadFileFromStandardLocation loads and parses a CODEOWNERS file at one of the standard locations for CODEOWNERS files (./, .github/, docs/).
ParseFile parses a CODEOWNERS file, returning a set of rules.
# Constants
EmailOwner is the owner type for email addresses.
TeamOwner is the owner type for GitHub teams.
UsernameOwner is the owner type for GitHub usernames.
# Type aliases
Ruleset is a collection of CODEOWNERS rules.