ignore

package
v0.2.10 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package ignore matches paths against the ignore files that apply to them, for use as scan's ignore predicate. It is modelled on ripgrep's ignore handling but owned in-repo - no vendored walker or matcher: a configurable set of per-directory ignore files (default .gitignore; a .cloverignore can be added via WithFiles) sharing gitignore syntax. For a path it consults every ignore file from the repository root (via vcs) down to the path's directory, last match winning, so nested ignores and negation behave as git does. Patterns compile to RE2; parsed files are cached per directory.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Matcher

type Matcher struct {
	// contains filtered or unexported fields
}

Matcher decides whether a path is ignored by the ignore files governing it, after the manner of ripgrep's ignore handling but owned in-repo. It is bounded by the repository root (resolved via vcs) and caches each directory's parsed patterns, so it is cheap to consult once per scanned entry.

func New

func New(resolver *vcs.Resolver, opts ...Option) *Matcher

New returns a matcher that resolves repository roots through resolver.

func (*Matcher) Ignore

func (m *Matcher) Ignore(path string, isDir bool) bool

Ignore reports whether the entry at path is ignored, suitable for scan.WithIgnore. Files outside any repository are never ignored. The ignore files from the repository root down to the path's directory are applied in order, the last matching pattern deciding - matching git, including negation.

type Option

type Option func(*Matcher)

Option configures a Matcher.

func WithDisabled

func WithDisabled() Option

WithDisabled turns the matcher into a no-op that ignores nothing, for --no-ignore. VCS directories are pruned by the walker, not here, so they stay excluded regardless.

func WithFiles

func WithFiles(names ...string) Option

WithFiles sets the ignore file names read in each directory, lowest priority first (default: .gitignore). This is the seam for a future .cloverignore.

Jump to

Keyboard shortcuts

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