Documentation
¶
Overview ¶
Package gitignore can be used to parse .gitignore-style files into lists of globs that can be used to test against paths or selectively walk a file tree. Gobwas's glob package is used for matching because it is faster than using regexp, which is overkill, and supports globstars (**), unlike filepath.Match.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IgnoreList ¶ added in v0.2.0
type IgnoreList struct {
// contains filtered or unexported fields
}
func From ¶
func From(path string) (IgnoreList, error)
From creates a new ignore list and populates the first entry with the contents of the specified file.
func FromGit ¶ added in v0.2.1
func FromGit() (IgnoreList, error)
FromGit finds the root directory of the current git repository and creates a new ignore list with the contents of all .gitignore files in that git repository.
func (*IgnoreList) Append ¶ added in v0.2.0
func (ign *IgnoreList) Append(path string) error
Append appends the globs in the specified file to the ignore list. Files are expected to have the same format as .gitignore files.
func (*IgnoreList) AppendGit ¶ added in v0.3.0
func (ign *IgnoreList) AppendGit() error
AppendGit finds the root directory of the current git repository and appends the contents of all .gitignore files in that git repository to the ignore list.
func (*IgnoreList) AppendGlob ¶ added in v0.2.0
func (ign *IgnoreList) AppendGlob(s string) error
AppendGlob appends a single glob as a new entry in the ignore list. The root (relevant for matching patterns that begin with "/") is assumed to be the current working directory.
func (*IgnoreList) Match ¶ added in v0.2.0
func (ign *IgnoreList) Match(path string) bool
Match returns whether any of the globs in the ignore list match the specified path. Uses the same matching rules as .gitignore files.