gitignore

package
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 22, 2016 License: GPL-3.0 Imports: 7 Imported by: 0

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

View Source
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 NewChecker

func NewChecker() *Checker

NewChecker returns a new Checker instance.

func NewCheckerWithCache

func NewCheckerWithCache(cache *GitIgnoreCache) *Checker

NewCheckerWithCache returns a new Checker instance that uses the given cache.

func (*Checker) Check

func (c *Checker) Check(path string, fi os.FileInfo) bool

Check returns whether the specified path is excluded by a .gitignore file.

func (*Checker) LoadBasePath

func (c *Checker) LoadBasePath(path string) error

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL