pathfilter

package
v0.0.21 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package pathfilter matches repository-relative paths against exclusion patterns, for the governance checks a consuming repository configures (ADR-0179).

It exists because the exclusion set was the last piece of lint policy still living as copied shell. A consumer repository carried it as a `grep -Ev` regex duplicated between its lint script and its editor hook — two copies of one policy, in a language with no way to share them, in the layer this ADR exists to stop copying.

The pattern syntax is deliberately smaller than a regex, because the thing being expressed is small:

CLAUDE.md      a bare name matches that basename anywhere
*.out.md       a bare glob matches the basename anywhere
attic/         a trailing slash matches that directory at any depth
doc/gen/       …including a nested one, e.g. public/x/doc/gen/y.md
doc/adr/*.md   a pattern with a separator matches the whole relative path

Anchoring differs from a regex on purpose: "attic/" excludes an attic directory wherever it sits, which is what a repository means by it, and what the shell versions were approximating with alternation.

Index

Constants

This section is empty.

Variables

View Source
var PackageProps = packageprops.Props{
	WASMWASI:         packageprops.WASMCompiles,
	WASMJS:           packageprops.WASMCompiles,
	WASMFreestanding: packageprops.WASMCompiles,
}

PackageProps records this package's curated properties (ADR-0080).

Functions

This section is empty.

Types

type Matcher

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

Matcher tests paths against a set of exclusion patterns.

The zero value matches nothing, which is the right default: a check with no configured exclusions examines everything.

func NewMatcher

func NewMatcher(patterns []string) (inst *Matcher)

func (*Matcher) IsEmpty

func (inst *Matcher) IsEmpty() (empty bool)

IsEmpty reports whether the matcher carries no patterns, so callers can skip the work of computing a relative path.

func (*Matcher) Match

func (inst *Matcher) Match(rel string) (excluded bool)

Match reports whether rel — a slash-separated path relative to the repository root — is excluded.

Jump to

Keyboard shortcuts

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