git-codeowners
git-codeowners copied to clipboard
feat: Discover current repository
- Use git2's
Repository.discover
to locate the current git repo root, if one exists
git2 is a crate of Rust bindings to libgit2. The git book suggests it's the dominant way to "embed" git-like functionality in apps w/o shelling out to the git
binary.
Cargo.lock changes are the result of running cargo build
on this branch, w/ cargo version 1.39.0.
Manual tests:
# State of this branch:
~/code/git-codeowners/src
$ ../target/debug/git-codeowners src/main.rs
@softprops
# When temporarily deleting CODEOWNERS
~/code/git-codeowners/src
$ ../target/debug/git-codeowners src/main.rs
No CODEOWNERS file found in this repo.
Ensure one exists at any of the locations documented here:
https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners#codeowners-file-location
# When outside of a git repo
~/code
$ ./git-codeowners/target/debug/git-codeowners src/main.rs
Repo discovery failed. Is /Users/ssw/code within a git repository? Error: could not find repository from '/Users/spencer/code'; class=Repository (6); code=NotFound (-3)
Resolves #3.