Git pathspec selection in pure MoonBit, with magic, attribute predicates, explanations and bounded matching.
| 规则 | 选择结果 |
|---|---|
| doc/*.jpg | 两个路径 |
| :(glob)doc/*.jpg | 仅 doc/a.jpg |
git clone https://github.com/2111950632/MoonPathspec.git
cd MoonPathspec
moon build --target js --release --deny-warn
node cli.mjs --input examples/files.json --json
node cli.mjs explain --input examples/files.json
node cli.mjs --input examples/attributes.json --json
node cli.mjs --input examples/literal.json --jsonnode cli.mjs --path doc/a.jpg --path doc/sub/b.jpg -- ':(glob)doc/*.jpg'
node cli.mjs inspect -- ':(top,icase,glob)**/*.md'
node cli.mjs --helpnode examples/ci-package/run.mjs
node cli.mjs explain --input examples/ci-package/release.jsonlet plan = @moonpathspec.compile([
":(glob)**/*.mbt",
":(exclude)vendor",
]).unwrap()
let result = @moonpathspec.select(plan, [
"main.mbt", "src/a.mbt", "vendor/a.mbt",
]).unwrap()
// result.selected == ["main.mbt", "src/a.mbt"]
let reason = @moonpathspec.explain(plan, "vendor/a.mbt").unwrap()
// reason.selected == false; reason.excluded_by == [1]moon check --target all --deny-warn
moon test --target js --deny-warn
moon test --target wasm-gc --deny-warn
moon fmt --check
moon info
moon build --target js --release --deny-warn
npm test
python tests/git_oracle.pypub(all) struct MagicFlags {
top : Bool
literal : Bool
glob : Bool
icase : Bool
exclude : Bool
attributes : Array[AttributeCondition]
} derive(Eq, Debug)pub(all) struct ParsedPattern {
original : String
pattern : String
magic : MagicFlags
no_pathspec : Bool
} derive(Eq, Debug)pub struct Plan {
// private fields
}fn compile(patterns : Array[String], prefix? : String, limits? : Limits) -> Result[Plan, SelectionError]fn dispatch(source : String) -> Stringfn explain(plan : Plan, path : String, attribute? : (String, String) -> AttributeValue) -> Result[Decision, SelectionError]fn select(plan : Plan, paths : Array[String], attribute? : (String, String) -> AttributeValue) -> Result[Selection, SelectionError]Install
Download zipGit pathspec selection in pure MoonBit, with magic, attribute predicates, explanations and bounded matching.