• Stars
    star
    105
  • Rank 328,196 (Top 7 %)
  • Language
    Go
  • License
    MIT License
  • Created over 4 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

🔒 Command line tool and Go library for CODEOWNERS files

codeowners

build PkgGoDev

A CLI and Go library for GitHub's CODEOWNERS file.

Command line tool

The codeowners CLI identifies the owners for files in a local repository or directory.

Installation

If you're on macOS, you can install the CLI from the homebrew tap.

$ brew tap hmarr/tap
$ brew install codeowners

Otherwise, grab a binary from the releases page or install from source with go install:

$ go install github.com/hmarr/codeowners/cmd/codeowners@latest

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
  -u, --unowned         only show unowned files (can be combined with -o)

$ 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

Pass the --unowned flag to only show unowned files.

$ codeowners -u
CODEOWNERS                           (unowned)

Go library

A package for parsing CODEOWNERS files and matching files to owners.

Installation

$ go get github.com/hmarr/codeowners

Usage

Full documentation is available at pkg.go.dev.

Here's a quick example to get you started:

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)
}

More Repositories

1

vitals

📊 A tiny macOS process monitor
Swift
414
star
2

auto-approve-action

👍 GitHub Action for automatically approving GitHub pull requests
TypeScript
337
star
3

codecube

Docker-powered runnable code snippets
Go
313
star
4

django-mumblr

Mumblr is a basic Django tumblelog application that uses MongoDB.
Python
255
star
5

debug-action

🛠 Show environment variables and event JSON in the Action logs
JavaScript
105
star
6

django-debug-toolbar-mongo

MongoDB panel for the Django Debug Toolbar
Python
89
star
7

chromesheep

FireSheep for Chrome
CoffeeScript
63
star
8

mongosearch

A proof-of-concept full-text search engine using MongoDB
Python
59
star
9

pick-dom-element

🖱 A JavaScript library for interactively picking DOM elements
TypeScript
29
star
10

chrome-cookie-switcher

Switch between website accounts easily in Chrome
JavaScript
17
star
11

dotfiles

💻 @hmarr's dotfiles - mostly vim and zsh configuration
Shell
17
star
12

grephub

🔍 Search GitHub repositories with regexes
JavaScript
12
star
13

docker-postgresql

Shell
9
star
14

chrome-detect-font

🖋 Easily see which fonts are in use
TypeScript
8
star
15

ircviewer

A web-based IRC viewer, packed with comety goodness
Python
6
star
16

mortgage-calculator-react

A toy built to try out React
JavaScript
6
star
17

vscode-cel

🎨 VS Code syntax highlighting for CEL
6
star
18

debug-tools

🔧 Docker image with useful debugging tools
Dockerfile
5
star
19

pkgextract

Extract a set of Go packages that depend on one another
Go
5
star
20

alfred-workflow-translate

🎩 Quick access to Google Translate via Alfred
JavaScript
5
star
21

barclays_bikes

A Ruby library for retrieving Barclays Bike availability
Ruby
4
star
22

vim-gemfile

A faster way of adding gems to your Gemfiles
Vim Script
4
star
23

skeema

A Scheme-like language interpreter in C
C
3
star
24

canvaschart

Simple canvas-based javascript charting library
JavaScript
3
star
25

mines

💣 A substandard implementation of the best game ever
TypeScript
3
star
26

xlsx-to-csv

💾 Convert XLSX files to CSVs
Go
3
star
27

schemacompare

Simple database schema comparison tool
Python
3
star
28

monkey_hunter

Find out what a Ruby library monkey patches
Ruby
3
star
29

gitbook-plugin-numbered-headings

Numbered headings for GitBook PDFs
CSS
2
star
30

tree-sitter-sqlite

🌳 A work-in-progress SQLite grammar for tree-sitter
JavaScript
2
star
31

dotjs

JavaScript
2
star
32

dependawhat

🤖 See what Dependabot's up to
TypeScript
2
star
33

barista

☕️ Keeps your Mac awake while it's on the clock
Go
2
star
34

hack-stack

💾 Software toolchain for the nand2tetris Hack computer
Rust
2
star
35

codecube-ruby

Ruby API client library for codecube.io
Ruby
2
star
36

advisories-analysis

Analysing the GitHub Advisory Database with sqlite and pandas
Jupyter Notebook
2
star
37

docker-pandoc-latex

2
star
38

auto-approve-test

1
star
39

ch

Like chruby, but supports multiple languages
Shell
1
star
40

codeowners-rs

🔒 A fast Rust library and CLI for GitHub's CODEOWNERS files
Rust
1
star
41

serve

🗂 Serve files from the current directory over HTTP
Go
1
star
42

gemfile-lock-tmlanguage

🎨 A tmLanguage grammar for Bundler's Gemfile.lock files
1
star
43

homebrew-tap

🍺 Homebrew tap for @hmarr's home brewed software
Ruby
1
star
44

yarn-lock-inconsistency

Shell
1
star