Documentation
¶
Overview ¶
Package pathfilter matches changed file paths against doublestar-style globs with include and ignore lists, for deciding whether a change in a monorepo should trigger a build or deploy.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Match ¶
Match reports whether file matches glob. Supported syntax: `*` (any run of characters within one segment), `?` (one character within a segment), `**` as a whole segment (zero or more segments), `[abc]`, `[a-z]` and `[!a]` classes, and `{a,b}` alternation. A glob ending in "/" matches everything beneath that directory. Wildcards match dotfiles. Both sides are normalized, so backslash separators work.
Example ¶
package main
import (
"fmt"
"github.com/GLINCKER/levelrail/kit/pathfilter"
)
func main() {
fmt.Println(pathfilter.Match("src/**/*.{go,ts}", "src/a/b/c.go"))
fmt.Println(pathfilter.Match("docs/", "docs/guide/intro.md"))
}
Output: true true
Types ¶
type Filter ¶
Filter is a set of include globs and ignore globs. An empty Paths list includes every path; a path matching any Ignore glob is dropped.
func (Filter) Apply ¶
Apply decides whether a change touching files should run. An empty file list means the file set is unknown, so the answer is always to run.
Example ¶
package main
import (
"fmt"
"github.com/GLINCKER/levelrail/kit/pathfilter"
)
func main() {
f := pathfilter.Filter{
Paths: []string{"services/api/**"},
Ignore: []string{"**/*.md"},
}
fmt.Println(f.Apply([]string{"services/api/main.go"}).Run)
fmt.Println(f.Apply([]string{"services/web/index.ts"}).Reason)
fmt.Println(f.Apply([]string{"services/api/README.md"}).Reason)
}
Output: true skipped: no changed path matched paths skipped: every changed path matched paths_ignore