Documentation ¶
Overview ¶
Package gitignore provides a Checker that can be used to determine whether a specific file is excluded by a .gitignore file.
This package targets to support the full gitignore pattern syntax documented here: https://git-scm.com/docs/gitignore
Multiple .gitignore files with multiple matching patterns are supported. A cache is used to prevent loading the same .gitignore file again when checking different paths.
Index ¶
Constants ¶
const ( GitIgnoreFilename = ".gitignore" GitFoldername = ".git" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Checker ¶
type Checker struct {
// contains filtered or unexported fields
}
Checker allows to check whether a given file is excluded by the relevant .gitignore files for a given base path and holds a cache of already parsed .gitignore files.
func NewCheckerWithCache ¶
func NewCheckerWithCache(cache *GitIgnoreCache) *Checker
NewCheckerWithCache returns a new Checker instance that uses the given cache.
func (*Checker) LoadBasePath ¶
LoadBasePath initializes the Checker instance with a new base path and loads all relevant .gitignore files. Already known .gitignore files are taken from the cache.
This function re-initializes the whole Checker, thus it is not thread-safe to call this function while using the Check() function of the same instance.
type GitIgnoreCache ¶
type GitIgnoreCache struct {
// contains filtered or unexported fields
}
GitIgnoreCache holds already parsed .gitignore files.
func NewGitIgnoreCache ¶
func NewGitIgnoreCache() *GitIgnoreCache
NewGitIgnoreCache creates and returns a new gitignore cache.