filter

package
v1.15.1 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package filter holds the shared parser for the explicit PRE:/SUF:/REG: filter grammar and the "^" exclusion prefix.

It only parses: it does not decide what is being matched (release tag, asset name, file name or search keyword), does not build matchers and does not take over the glob or substring defaults of its callers. Callers keep their own trimming, error wording and matching semantics — see docs/plans/2026-10-17-rule-consolidation-plan.md.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsPattern

func IsPattern(raw string) bool

IsPattern reports whether raw uses an explicit PRE:/SUF:/REG: filter. It does not trim and does not treat "^PRE:" as a pattern.

func ParseRegex

func ParseRegex(expr string) (*regexp.Regexp, error)

ParseRegex compiles a REG: expression and wraps failures in *RegexError.

func StripAnti

func StripAnti(raw string) (bool, string)

StripAnti removes a single leading "^" exclusion marker and reports whether it was present. It does not trim and does not look at the syntax prefixes.

Types

type Kind

type Kind int

Kind is the filter form a raw expression uses.

const (
	KindPlain Kind = iota
	KindPrefix
	KindSuffix
	KindRegex
)

Filter forms.

type RegexError

type RegexError struct {
	Expr string
	Err  error
}

RegexError reports an invalid REG: expression. Callers take Expr to keep their own error wording (e.g. `invalid tag regex %q`).

func RegexErrorOf

func RegexErrorOf(err error) (*RegexError, bool)

RegexErrorOf extracts the *RegexError from err, if any.

func (*RegexError) Error

func (e *RegexError) Error() string

func (*RegexError) Unwrap

func (e *RegexError) Unwrap() error

type Spec

type Spec struct {
	Raw   string
	Anti  bool
	Kind  Kind
	Expr  string
	Regex *regexp.Regexp
}

Spec is the parsed form of a filter expression.

Raw is the input as passed in (not trimmed, "^" not stripped); Expr is the expression without its syntax prefix (for KindPlain it equals Raw); Anti is set by the caller through StripAnti, never by Parse. Regex is filled for KindPrefix/KindSuffix/KindRegex and is nil for KindPlain, whose meaning (substring or anchored prefix) belongs to the caller.

func Parse

func Parse(raw string) (Spec, error)

Parse parses a PRE:/SUF:/REG: expression (a plain value stays KindPlain).

It deliberately does not TrimSpace and does not strip "^": the tag callers trim before calling and treat "^" as literal content, while the asset/search callers strip "^" through StripAnti first.

func (Spec) PrefixRegex

func (s Spec) PrefixRegex() *regexp.Regexp

PrefixRegex returns the case-insensitive, anchored-prefix matcher for the expression — the regex the tag and asset filters built before.

func (Spec) SuffixRegex

func (s Spec) SuffixRegex() *regexp.Regexp

SuffixRegex returns the case-insensitive suffix matcher for the expression.

Jump to

Keyboard shortcuts

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