#git-repository #owner #codeowners #subcommand #file #validate #query

app git-owners

A git subcommand to query and validate CODEOWNERS

2 stable releases

1.0.1 Oct 28, 2022
1.0.0 May 23, 2022

#1 in #codeowners

Download history 29/week @ 2023-12-22 59/week @ 2023-12-29 126/week @ 2024-01-05 71/week @ 2024-01-12 31/week @ 2024-01-19 116/week @ 2024-01-26 68/week @ 2024-02-02 82/week @ 2024-02-09 165/week @ 2024-02-16 242/week @ 2024-02-23 234/week @ 2024-03-01 226/week @ 2024-03-08 235/week @ 2024-03-15 198/week @ 2024-03-22 270/week @ 2024-03-29 219/week @ 2024-04-05

984 downloads per month

MIT license

8KB
99 lines

git-owners

A git subcommand to query and validate CODEOWNERS.

List owners of files based on the CODEOWNERS of the current repository.

> git owners src/main.rs
src/main.rs                    @weyland
> git owners `git ls-files`
.gitignore                     (unowned)
Cargo.lock                     @weyland
Cargo.toml                     @weyland
LICENSE                        (unowned)
README.md                      @weyland
src/main.rs                    @weyland
# oops, did the last commit add some unowned files?
> git diff --name-only --diff-filter=A | git owners
.gitignore                     (unowned)
LICENSE                        (unowned)
# I need stats about my big monorepo
> echo `git ls-files | git owners | grep "(unowned)"| wc -l` out of `git ls-files | git owners | wc -l` files in this repository do not have a corresponding CODEOWNERS entry
2 out of 6 files in this repository do not have a corresponding CODEOWNERS entry

Installation

  • Via Cargo: cargo install git-owners

Usage

  • Get owners of a file

    git owners some/file
    
  • Get owners for a list of files

    git owners some/file some/other/file
    
  • Get owners for every tracked file

    git ls-files | git owners
    
  • Get owners for files modified in last five commits

    git diff --name-only HEAD~5 HEAD | git owners
    
  • Congratulate the user if the current changeset does not add files without owner

    git diff --diff-filter=ACR --name-only | git owners && echo "Great job! No unowned files added!"
    
  • Get an overview of your CODEOWNERS coverage

    echo `git ls-files | git owners | grep "(unowned)"| wc -l` out of `git ls-files | git owners | wc -l` files in this repository do not have a corresponding CODEOWNERS entry
    

Features

  • Detects the right CODEOWNERS file of the current git repository
  • Is composable & scripting friendly
  • Works well as a pre-commit hook
  • Is fast & written in Rust

Issues & Contributing

If you have any questions or problems, feel free to communicate using Github Issues.

Dependencies

~6.5MB
~133K SLoC