Documentation
¶
Overview ¶
Package fsmatch matches slash-separated paths against glob patterns and .gitignore rules. It is shared by the built-in search tools and the rag file loader.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MatchSegments ¶
MatchSegments matches path segments against pattern segments, where a "**" pattern segment matches any number of path segments and others follow path.Match.
Types ¶
type Glob ¶
type Glob [][]string
Glob matches slash-separated paths against patterns in which "**" matches any number of path segments, other segments follow path.Match and "{a,b}" expands to alternatives.
type Ignorer ¶
type Ignorer struct {
// contains filtered or unexported fields
}
Ignorer evaluates the .gitignore files of a file tree. Files are loaded lazily and cached per directory. It is not safe for concurrent use.
func NewIgnorer ¶
func NewIgnorer(fsys fs.FS, outer ...OuterRules) *Ignorer
NewIgnorer returns an Ignorer for the tree fsys. outer are rules from outside the tree, such as a repository's info/exclude file, lowest precedence first.
func (*Ignorer) Ignored ¶
Ignored reports whether name, a slash-separated path relative to the tree root, is excluded by the ignore files of its ancestors. As in git, the last matching pattern wins, deeper files override shallower ones and outer rules have the lowest precedence.
Like git, it does not check whether a parent directory is excluded; callers walking the tree skip excluded directories instead.
type OuterRules ¶
type OuterRules struct {
// Prefix is the slash-separated path of the tree root relative to the
// ignore file's directory, or "" for the same directory.
Prefix string
Rules []Rule
}
OuterRules are the rules of an ignore file above the root of a tree, which apply to paths relative to that file's directory.
type Rule ¶
type Rule struct {
// Negate re-includes a path ("!pattern").
Negate bool
// contains filtered or unexported fields
}
Rule is one pattern of a .gitignore file.
func ParseIgnore ¶
ParseIgnore parses .gitignore content. It supports comments, negation, directory-only and anchored patterns, "**" and escaped "#", "!" and trailing spaces.