2个版本
0.1.1 | 2023年4月1日 |
---|---|
0.1.0 | 2023年4月1日 |
#9 在 #ruleset
50KB
1K SLoC
codeowners-rs
一个快速的Rust库和CLI,用于GitHub的CODEOWNERS文件。
包含一个快速的、手动编写的CODEOWNERS文件解析器。生成的解析树包含所有语法组件的注释和字节偏移量,适用于编写语法高亮器或提供语法感知的诊断信息。
匹配器通过从规则构建NFA来工作,这使得该库在大型规则集和匹配大量路径时性能极高。
示例用法
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);
}
请参阅docs.rs上的完整文档。
CLI用法
$ codeowners --help
Usage: codeowners [OPTIONS] [PATHS]...
Arguments:
[PATHS]...
Options:
-f, --file <CODEOWNERS_FILE>
Path to a CODEOWNERS file. If omitted, the following locations will be tried: ./CODEOWNERS, ./.github/CODEOWNERS
-p, --paths-from <PATHS_FROM_FILE>
Match paths from this file rather than walking the directory tree
-o, --owners <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 <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
依赖项
~2.4–3.5MB
~59K SLoC