Documentation
¶
Overview ¶
Package gitignore provides gitignore-aware file filtering using go-git's gitignore package. It implements a native Go stack-based tracker that supports the full Git ignore hierarchy: global gitignore, .git/info/exclude, and per-directory .gitignore.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PatternSource ¶
PatternSource pairs gitignore patterns with the file they were loaded from.
type Tracker ¶
type Tracker struct {
// contains filtered or unexported fields
}
Tracker manages a stack of gitignore pattern sources and provides path matching.
The stack is ordered from the least specific (global ignore) to the most specific (deepest subdirectory .gitignore). The deepest matching rule wins.
func NewTracker ¶
NewTracker creates a Tracker rooted at the given directory.
The Tracker created loads three base layers: global gitignore (core.excludesfile), .git/info/exclude, and the root .gitignore.
Parameters:
- root: Absolute path to the root directory of the git repository
Returns:
- *Tracker: The initialized Tracker
func (*Tracker) IsIgnored ¶
IsIgnored checks whether a relative path (from root) should be ignored.
The most specific (deepest) matching rule wins. Within each layer, the last matching pattern takes precedence.
Parameters:
- path: Relative path to check (e.g. "src/main.cpp")
- isDir: True if the path is a directory (e.g. "src/main.cpp" is a directory, not a file)
Returns: true if the path is ignored, false if the path is not ignored.
func (*Tracker) Push ¶
Push loads the .gitignore from the given directory (relative to root) onto the stack.
It automatically pops entries from sibling or cousin directories that are no longer ancestors of dir.
Parameters:
- dir: Relative path to the directory containing the .gitignore file (e.g. "src/main.cpp")