https://github.com/hmarr/codeowners-rs
🔒 A fast Rust library and CLI for GitHub's CODEOWNERS files
https://github.com/hmarr/codeowners-rs
codeowners rust
Last synced: 10 months ago
JSON representation
🔒 A fast Rust library and CLI for GitHub's CODEOWNERS files
- Host: GitHub
- URL: https://github.com/hmarr/codeowners-rs
- Owner: hmarr
- License: apache-2.0
- Created: 2022-10-30T17:08:39.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-10-18T18:43:23.000Z (about 2 years ago)
- Last Synced: 2025-02-26T20:22:32.045Z (10 months ago)
- Topics: codeowners, rust
- Language: Rust
- Homepage:
- Size: 178 KB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: codeowners-cli/Cargo.toml
Awesome Lists containing this project
README
# codeowners-rs
A fast Rust library and CLI for GitHub's [CODEOWNERS file](https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners#codeowners-syntax).
[](https://crates.io/crates/codeowners-rs)
[](https://docs.rs/codeowners-rs)
[](https://github.com/hmarr/codeowners-rs/actions/workflows/ci.yml)
## Highlights
- Processes large, complex CODEOWNERS files quickly by constructing an NFA from the set of rules. Rather than matching each rule against each path, the NFA is traversed once for each path. The CLI tool also parallelizes path matching.
- Includes a fast, hand-written parser for CODEOWNERS files. The resulting parse tree includes comments and byte offsets for all syntax components, making it suitable for writing syntax highlighters or providing syntax-aware diagnostic information.
## Example usage
```rust
use codeowners_rs::{parse, RuleSet};
let ruleset = parse("
*.rs @github/rustaceans
/docs/**/*.md @github/docs-team
").into_ruleset();
for path in &["src/main.rs", "docs/README.md", "README.md"] {
let owners = ruleset.owners(path);
println!("{}: {:?}", path, owners);
}
```
See the full documentation on [docs.rs](https://docs.rs/codeowners-rs).
## CLI usage
```
$ codeowners --help
Usage: codeowners [OPTIONS] [PATHS]...
Arguments:
[PATHS]...
Options:
-f, --file
Path to a CODEOWNERS file. If omitted, the following locations will be tried: ./CODEOWNERS, ./.github/CODEOWNERS
-p, --paths-from
Match paths from this file rather than walking the directory tree
-o, --owners
Filter results to files owned by this owner. May be used multiple times to match multiple owners
-u, --unowned
Filter results to show unowned files. May be used with -o
-t, --threads
Concurrency. If set to 0, a sensible value based on CPU count will be used [default: 0]
-h, --help
Print help information
-V, --version
Print version information
```