Documentation
¶
Index ¶
- Variables
- func DeriveHeadingVersionPattern(template string) string
- func DeriveTagPattern(template string, t Tokens) string
- func GlobPattern(template string, t Tokens) (string, error)
- func ParseVersion(template, tag string) (string, error)
- func Render(template string, t Tokens) (string, error)
- func ValidateBuildID(build string) error
- func ValidateVersionOverride(version string) error
- type Tokens
Constants ¶
This section is empty.
Variables ¶
var ErrBuildIDRequired = errors.New("tag format template contains " + buildToken + " but no build ID was provided; " +
"pass --set-build-id <id> (with --set-version <version> if not already given) to " +
"`heraut changelog`, `heraut release` or `heraut version next`")
ErrBuildIDRequired is returned by Render when the template contains {build} but no build ID was supplied. Callers classify it with errors.Is — a missing build ID is a usage problem, not a runtime failure.
Functions ¶
func DeriveHeadingVersionPattern ¶ added in v0.20.0
DeriveHeadingVersionPattern returns a heading-postprocessor regex, consumed by native, that strips every non-{version} token (env prefix/suffix and build) from a changelog version heading, leaving only the version. The replacement is "[$1]". Examples:
{version}_{env} [2026.3.0_prod] → [2026.3.0]
{env}/{version}+{build} [uat/7.4.1+158404] → [7.4.1]
{env}/{version} [prod/1.2.3] → [1.2.3]
Returns "" when there is nothing to strip — no {version}, or neither {env} nor {build} present (a plain or "v"-prefixed version heading is already clean).
All wildcards exclude "]" so a match can never span two headings (postprocessors run against the whole rendered document). The greedy version capture plus the anchored trailing token handle SemVer pre-release segments (e.g. 7.4.1-rc.1) under the "+" build separator without special-casing.
func DeriveTagPattern ¶ added in v0.20.0
DeriveTagPattern returns an anchored regex, consumed by native to scope its tag walk, that matches only the given environment's tags. {env} becomes the literal t.Env, {version} and {build} become wildcards. Returns "" when the template has no {env} token or t.Env is empty — there is nothing to scope in those cases.
func GlobPattern ¶
GlobPattern returns a git tag glob pattern for listing tags under the given env.
func ParseVersion ¶
ParseVersion extracts the version string from a tag using the given template.
func Render ¶
Render substitutes {version}, {env}, and {build} tokens in template. t.Build may be empty when {build} is not present in the template; if {build} is present but t.Build is empty, ErrBuildIDRequired is returned.
func ValidateBuildID ¶ added in v0.19.0
ValidateBuildID checks that a build ID is usable as a tag component: non-empty, no "/" (path separator) and no whitespace (git ref constraints). CI build IDs like "$CI_PIPELINE_ID" and "$GITHUB_RUN_NUMBER" satisfy this.
func ValidateVersionOverride ¶ added in v0.32.0
ValidateVersionOverride checks that a --set-version value is usable as a tag/version override: non-empty and free of whitespace (git ref constraints). Unlike ValidateBuildID, "/" is allowed — a full tag override may legitimately contain one. heraut is strategy-agnostic about the shape of the override (SemVer, CalVer, or any other scheme the user's tag_format expects).
Types ¶
type Tokens ¶ added in v0.62.1
Tokens holds the substitution values for a tag format template. Bundling them as a struct (rather than growing the positional-parameter list of every function below) gives future tokens — e.g. a monorepo {package} token — a seam to land in without re-touching every call site's signature a second time.