Documentation
¶
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 checks paths against gitignore rules collected from .gitignore files, .git/info/exclude, and any additional patterns. Patterns from subdirectory .gitignore files are scoped to paths within that directory.
Paths passed to Match should use forward slashes. Directory paths must have a trailing slash (e.g. "vendor/") so that directory-only patterns (those written with a trailing slash in .gitignore) match correctly.
func New ¶
New creates a Matcher that reads patterns from the repository's .git/info/exclude and root .gitignore. The root parameter should be the repository working directory (containing .git/).
func (*Matcher) AddFromFile ¶
AddFromFile reads a .gitignore file at the given absolute path and scopes its patterns to the given relative directory.
func (*Matcher) AddPatterns ¶
AddPatterns parses gitignore pattern lines from data and scopes them to the given relative directory. Pass an empty dir for root-level patterns.
func (*Matcher) Match ¶
Match returns true if the given path should be ignored. The path should be slash-separated and relative to the repository root. For directories, append a trailing slash (e.g. "vendor/"). Uses last-match-wins semantics: iterates patterns in reverse and returns on the first match.