gitignore

package module
Version: v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2018 License: BSD-3-Clause Imports: 7 Imported by: 1

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 New

func New() (IgnoreList, error)

New creates a new ignore list.

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.

func (*IgnoreList) Walk added in v0.2.0

func (ign *IgnoreList) Walk(root string, fn filepath.WalkFunc) error

Walk walks the file tree with the specified root and calls fn on each file or directory. Files and directories that match any of the globs in the ignore list are skipped.

Source Files

Jump to

Keyboard shortcuts

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