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.