Documentation
¶
Overview ¶
Package pattern is clover's one matching grammar, shared by every directive that accepts a pattern (include/exclude, verify-branch, checksum, find): a value bracketed by / is a strict RE2 regex; any other value is a glob with *, ?, and <placeholders>. A glob exposes two operations from the same source - Matches (a whole-string filter via gobwas/glob) and capture (the find/replace path, where each <token> becomes a group reachable through Regexp/Tokens). Pure.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Pattern ¶
type Pattern struct {
// contains filtered or unexported fields
}
Pattern is a compiled match expression. The two kinds collapse a would-be "literal" kind: a bare glob with no metacharacters already matches exactly, and a backslash escapes the rest. The raw source is retained so a pattern round-trips back to the text the user wrote.
func Compile ¶
Compile parses a pattern value. A value bracketed by / is compiled as an unanchored RE2 regex; every other value is a whole-string glob that may carry <placeholders>. Glob uses no separators, so * spans every character (including /) - a tag filter matches opaque tokens, not filesystem paths.
func (*Pattern) Matches ¶
Matches reports whether s satisfies the pattern: a whole-string glob match, or an unanchored regex search.
func (*Pattern) Regexp ¶
Regexp returns the unanchored regex used to locate and capture: the /regex/ itself, or the glob's <token>-capturing form.
type Token ¶
type Token string
Token is the name of a <placeholder> the grammar recognizes, e.g. <version>.
const ( TokenCommit Token = "commit" TokenHex Token = "hex" TokenMajor Token = "major" TokenMajorMinor Token = "major.minor" TokenMajorMinorPatch Token = "major.minor.patch" TokenMinor Token = "minor" TokenPatch Token = "patch" TokenSHA256 Token = "sha256" TokenVersion Token = "version" )
Token names the grammar recognizes - the keys of matchRegex, the names a find captures, and the keys Expand substitutes. They are the single source of truth for the vocabulary, shared by the match and checksum packages so a token name is never spelled as a literal.