Documentation
¶
Overview ¶
Package ignore implements .gitignore-style path matching shared by the scan and sast filesystem walkers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Matcher ¶
type Matcher struct {
// contains filtered or unexported fields
}
Matcher evaluates paths against a stack of .gitignore files discovered during a top-down filesystem walk. It implements the subset of gitignore(5) semantics that matters for scan pruning: comments, negation (`!`), anchored patterns (leading or embedded `/`), directory-only patterns (trailing `/`), and `*` / `?` / `**` / `[...]` globs.
Rules are accumulated per directory: call LoadDir on each directory as the walk enters it (parents before children, which filepath.WalkDir guarantees), then Ignored to test each entry. Because ignored directories are pruned with SkipDir, a negation cannot re-include a file whose parent directory is ignored — this matches git's own behaviour.
func Globs ¶
Globs returns a matcher for user-supplied exclusion patterns (--exclude, --ignore), each relative to the walk root. They follow the rules of a root .gitignore, which is what people expect when they type one: a trailing `/` names a directory and everything beneath it, a pattern with no slash matches that name at any depth, and `**` spans directories. A leading `./` anchors the pattern to the root, as a leading `/` does.