globpath

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package globpath provides glob matching and pattern utilities for mdsmith config surfaces: ignore:, overrides:, kind-assignment:, and rule settings (allowed:, include:, exclude:, budgets[].glob).

The catalog directive uses SplitIncludeExclude from this package to split !-prefixed exclusion patterns; include resolution and exclude matching in the catalog use doublestar directly with full-path semantics.

CLI argument expansion uses doublestar.FilepathGlob directly and does not route through this package; !-prefix exclusion is not available on the CLI.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainsDotDotSegment added in v0.15.0

func ContainsDotDotSegment(p string) bool

ContainsDotDotSegment reports whether p contains a ".." path element when split on "/". Filenames like "..foo" do not match.

func Match

func Match(pattern, path string) bool

Match reports whether path matches pattern using the doublestar matcher. It checks the raw path, the cleaned path, and the base name so that patterns without path separators (e.g. "slides.md") match files in any directory. Invalid patterns return false.

func MatchAny

func MatchAny(patterns []string, path string) bool

MatchAny reports whether path matches any of the given patterns. A pattern prefixed with "!" is an exclusion pattern. The path matches when at least one non-negated pattern matches and no exclusion pattern matches; an exclusion pattern always wins over an inclusion pattern, regardless of list order. A list containing only exclusion patterns matches nothing.

func ResolveAgainstRoot added in v0.15.0

func ResolveAgainstRoot(baseDir, p2 string) (resolved string, escapes bool)

ResolveAgainstRoot resolves p against baseDir (both slash-separated and relative to a project root) and reports whether the cleaned result escapes the project root via ".." segments.

baseDir == "" or "." is interpreted as the project root. The returned path is also slash-separated and relative to the project root; it is "" for the root itself.

Callers use this to check that ".." segments in a path stay within the project root before resolving the path against a project-rooted fs.FS.

func SplitIncludeExclude

func SplitIncludeExclude(patterns []string) (include, exclude []string)

SplitIncludeExclude separates patterns into include and exclude lists. Patterns prefixed with "!" are exclusion patterns (the prefix is stripped).

Types

This section is empty.

Jump to

Keyboard shortcuts

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