parseignore

package module
v0.0.0-...-41ebb75 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2015 License: BSD-3-Clause Imports: 8 Imported by: 11

README

parseignore

    import "github.com/facebookgo/parseignore"

Package parseignore implements a subset of the gitignore specification.

It is used by the Parse Command Line Tool, to parse and enforce the .parseignore file.

Documentation

Overview

Package parseignore implements a subset of the gitignore specification.

This implementation does not support the ** special syntax.

More details for gitignore are available at: http://git-scm.com/docs/gitignore

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Decision

type Decision int

Decision is used in tri-state logic Look at the constants defined below for more information

const (
	// Pass indicates the Matcher does not have any specific decision about
	// the given path.
	Pass Decision = iota

	// Include indicates the Matcher decided to explicitly include the path.
	// This is used for negation, or patterns that explicitly want to include
	// files when they were otherwise excluded by an earlier rule.
	Include

	// Exclude indicates a pattern matches file path and wants to explicitly
	// exclude it
	Exclude
)

type Matcher

type Matcher interface {
	Match(path string, fi os.FileInfo) (Decision, error)
}

Matcher matches paths and returns a bool indicating if the path should be ignored or not.

func CompilePatterns

func CompilePatterns(contents []byte) (Matcher, []error)

CompilePatterns compiles the patterns contained in the provided contents (separated by newlines). It follows a subset of the gitignore specification, including rules such as ignoring blank or whitespace only lines. It also ignores line that begin with a `#`. Additionally even when we encounter errors in compiling patterns we return a Matcher that respects the patterns that were successfully compiled.

func ComponentNameMatcher

func ComponentNameMatcher(name string, dirOnly bool) (Matcher, error)

ComponentNameMatcher returns a Matcher that checks if any of the path components match the given name.

func GlobMatcher

func GlobMatcher(glob string, dirOnly bool) (Matcher, error)

GlobMatcher returns a Matcher that checks the path against the provided glob.

func InverseMatcher

func InverseMatcher(m Matcher) Matcher

InverseMatcher returns a Matcher that inverts the decision of the given matcher.

func MultiMatcher

func MultiMatcher(m ...Matcher) Matcher

MultiMatcher returns a single Matcher that runs thru the ordered list of Matchers, where the last decision wins.

Jump to

Keyboard shortcuts

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