gitignore

package
v3.52.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: MIT, Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package gitignore implements gitignore pattern matching.

This package is vendored from go-git:

github.com/go-git/go-git/v5 v5.19.1, plumbing/format/gitignore

Only the pattern parsing and matching logic (pattern.go and matcher.go) is copied; the file-walking helpers (dir.go) are omitted as they pull in go-billy and other go-git internals. The original code is licensed under the Apache License 2.0; see the LICENSE file in this directory.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MatchResult

type MatchResult int

MatchResult defines outcomes of a match, no match, exclusion or inclusion.

const (
	// NoMatch defines the no match outcome of a match check
	NoMatch MatchResult = iota
	// Exclude defines an exclusion of a file as a result of a match check
	Exclude
	// Include defines an explicit inclusion of a file as a result of a match check
	Include
)

type Matcher

type Matcher interface {
	// Match matches patterns in the order of priorities. As soon as an inclusion or
	// exclusion is found, not further matching is performed.
	Match(path []string, isDir bool) bool
}

Matcher defines a global multi-pattern matcher for gitignore patterns

func NewMatcher

func NewMatcher(ps []Pattern) Matcher

NewMatcher constructs a new global matcher. Patterns must be given in the order of increasing priority. That is most generic settings files first, then the content of the repo .gitignore, then content of .gitignore down the path or the repo and then the content command line arguments.

type Pattern

type Pattern interface {
	// Match matches the given path to the pattern.
	Match(path []string, isDir bool) MatchResult
}

Pattern defines a single gitignore pattern.

func ParsePattern

func ParsePattern(p string, domain []string) Pattern

ParsePattern parses a gitignore pattern string into the Pattern structure.

Jump to

Keyboard shortcuts

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