Documentation
¶
Index ¶
- Variables
- func BumpVersion(current string, bump versioning.BumpType) (string, error)
- func Compare(a, b Version) int
- func DetermineBump(commits []string, overrides []config.BumpRule) versioning.BumpType
- func ExistingRelease(runner port.Runner, tag string) (string, error)
- func IsBareVersion(s string) bool
- func MajorMinor(version string) (major, minor int, err error)
- func RotationPattern(tokens []string, major, minor int) (string, error)
- func ValidatePreReleaseLabel(label string) error
- type Range
- type Resolver
- func (r *Resolver) BumpAuto(tags []string, commits []string) (string, error)
- func (r *Resolver) BumpFromDate(_ []string) (string, error)
- func (r *Resolver) Resolve() (versioning.Result, error)
- func (r *Resolver) SetAllowMajor(allow bool)
- func (r *Resolver) SetAllowReleased(allow bool)
- func (r *Resolver) SetFixedVersion(core string)
- func (r *Resolver) SetMaintenanceRange(rg *Range)
- func (r *Resolver) SetPreRelease(label string)
- func (r *Resolver) SetVersionOverride(v string)
- func (r *Resolver) Warnings() []string
- func (r *Resolver) WouldBeVersions() []string
- type TagVersion
- type Version
Constants ¶
This section is empty.
Variables ¶
var ( ErrOutOfRange = errors.New("next version is outside the maintenance range") ErrTagExists = errors.New("tag already exists") ErrNoInRangeRelease = errors.New("no release in the maintenance range is reachable from HEAD") )
var ErrInvalidVersion = errors.New("invalid SemVer version")
ErrInvalidVersion is returned (wrapped) by Parse for any string that is not a SemVer 2.0.0 version.
var ErrMajorEscalation = errors.New("pre-release series major escalation")
ErrMajorEscalation is matched (errors.Is) by the error returned when a pre-release run would move an open series to a new major without --allow-major.
var ErrPreReleaseRegression = errors.New("pre-release would not sort above existing tags of its core")
ErrPreReleaseRegression is matched (errors.Is) by the error returned when the candidate pre-release would not sort above every existing tag of its core.
Functions ¶
func BumpVersion ¶
func BumpVersion(current string, bump versioning.BumpType) (string, error)
BumpVersion increments the appropriate SemVer component. current must be a bare version string without prefix (e.g. "1.2.3").
func Compare ¶ added in v0.72.0
Compare orders a and b by SemVer §11 precedence: -1 if a < b, 0 if equal, +1 if a > b. Build metadata is ignored, so versions differing only in it compare equal.
func DetermineBump ¶
func DetermineBump(commits []string, overrides []config.BumpRule) versioning.BumpType
DetermineBump scans commits and returns the highest bump level any of them contributes (T261). Per commit, in order: the first matching rule in overrides wins (a rule matches when every condition it sets — type, regex against the subject, breaking — holds); otherwise the built-in defaults apply (breaking → major, feat → minor, any other conventional commit → patch); a non-conventional commit matched by nothing contributes nothing. A release with nothing to contribute (everything ignored or explicitly "none") resolves to BumpNone — callers decide whether that's an error.
func ExistingRelease ¶ added in v0.75.0
ExistingRelease returns a tag that already releases tag's version, or "" when there is none. Without build metadata in tag, a <tag>+<build> tag counts too: build metadata does not make a different release (ADR-0064), so v1.3.2+7 cut elsewhere is the release of 1.3.2. Pre-releases such as v1.3.2-rc.1 match neither pattern.
func IsBareVersion ¶ added in v0.32.0
IsBareVersion reports whether s is a dotted MAJOR.MINOR.PATCH of integers with no pre-release or build suffix. It is deliberately lenient (it accepts leading zeros), because calver-per-env's zero-padded versions (2026.05.3) go through it — SemVer strategies use Parse instead (ADR-0064).
func MajorMinor ¶ added in v0.59.0
MajorMinor extracts the MAJOR and MINOR components from a bare SemVer version string, for substitution into a rotating changelog output pattern's {MAJOR}/{MINOR} tokens. version must have at least MAJOR.MINOR.PATCH shape; PATCH may carry a pre-release/build-metadata suffix (e.g. "1.4.2-rc.1", "1.4.2+build.5") since heraut's --set-version override is strategy-agnostic about shape (see tagfmt.ValidateVersionOverride) — MAJOR and MINOR are unaffected either way.
func RotationPattern ¶ added in v0.59.0
RotationPattern returns a regular expression matching any bare version string in the same rotation bucket as major/minor, given the tokens a rotating changelog output/tag pattern groups by ("MAJOR" alone, or "MAJOR" and "MINOR" together — order doesn't matter). "MINOR" alone is rejected: MAJOR is always the leading, required dimension, mirroring calver.BucketPattern's prefix-order rule for the CalVer strategy family. The pattern is anchored at the start (^) only — callers compose their own tag_prefix quoting.
func ValidatePreReleaseLabel ¶ added in v0.74.0
ValidatePreReleaseLabel checks that label is a single SemVer pre-release identifier that is not purely numeric: [0-9A-Za-z-]+, no dots. heraut appends ".N", so a numeric label would collide with the counter's own identifier type.
Types ¶
type Range ¶ added in v0.75.0
Range is a maintenance line [Lo, Hi) (ADR-0065).
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
Resolver resolves the next SemVer version.
func (*Resolver) BumpAuto ¶ added in v0.4.0
BumpAuto computes the next SemVer from pre-fetched bare versions and commits. tags is sorted newest-first with the prefix already stripped; commits are the full commit messages since the latest tag. Implements the VersionCalculator interface consumed by internal/versioning/perenv.
func (*Resolver) BumpFromDate ¶ added in v0.4.0
BumpFromDate is not used by the SemVer calculator; it satisfies the VersionCalculator interface for internal/versioning/perenv.
func (*Resolver) Resolve ¶
func (r *Resolver) Resolve() (versioning.Result, error)
Resolve returns the next version result. An explicit versionOverride (set via SetVersionOverride) always takes precedence over the configured bump mode — this allows --set-version to short-circuit auto resolution.
func (*Resolver) SetAllowMajor ¶ added in v0.69.0
SetAllowMajor lifts versioning.bump.stay_at_v0's hold-back for this resolver (--allow-major).
func (*Resolver) SetAllowReleased ¶ added in v0.78.0
SetAllowReleased lets a final whose version is already tagged resolve to that version again, for runs that never create the tag (changelog without --tag).
func (*Resolver) SetFixedVersion ¶ added in v0.78.0
SetFixedVersion pins resolution to core (MAJOR.MINOR.PATCH), the version a version branch carries in its name (ADR-0065): commits never bump it, only the pre-release label or the final decides the tag. "" restores normal resolution. --set-version and manual bump mode still win; Resolve never reaches this path for them.
func (*Resolver) SetMaintenanceRange ¶ added in v0.75.0
SetMaintenanceRange confines auto resolution to rg's line; nil restores global resolution.
func (*Resolver) SetPreRelease ¶ added in v0.74.0
SetPreRelease switches Resolve into pre-release mode for label; "" restores final-release resolution. The label is not validated here — see ValidatePreReleaseLabel.
func (*Resolver) SetVersionOverride ¶
SetVersionOverride pins the resolved version, bypassing both auto and manual bump logic. The caller passes the bare version (e.g. "1.0.0"); the prefix is still applied.
func (*Resolver) Warnings ¶ added in v0.69.0
Warnings returns the warnings produced by the most recent Resolve or BumpAuto call — nil when nothing was held back. The resolver never prints them; the caller decides how to surface them.
func (*Resolver) WouldBeVersions ¶ added in v0.69.0
WouldBeVersions returns the bare "would-be" major version for each entry in Warnings, in the same order — nil when Warnings is empty. See holdMajorAtZero's doc comment for why this exists.
type TagVersion ¶ added in v0.72.0
TagVersion pairs a git tag with the SemVer version parsed from it.
func Latest ¶ added in v0.72.0
func Latest(sorted []TagVersion, includePreRelease bool) (TagVersion, bool)
Latest returns the first entry of sorted (as returned by SortTags) that is a release — or, with includePreRelease, the first entry of any kind. ok is false when none qualifies.
func SortTags ¶ added in v0.72.0
func SortTags(tags []string, extract func(tag string) (string, bool)) []TagVersion
SortTags parses every tag through extract — which returns the tag's bare version string and whether the tag belongs to this scheme at all — and returns the valid SemVer ones, highest §11 precedence first. Tags that don't extract or don't parse are dropped. The sort is stable, so tags of equal precedence (differing only in build metadata) keep their input order.
type Version ¶ added in v0.72.0
type Version struct {
Major, Minor, Patch uint64
// Pre holds the pre-release identifiers (§9); empty for a release.
Pre []string
// Build holds the build-metadata identifiers (§10); Compare ignores it.
Build []string
}
Version is a parsed SemVer 2.0.0 version (https://semver.org/spec/v2.0.0.html).
func Parse ¶ added in v0.72.0
Parse parses s strictly per the SemVer 2.0.0 grammar. s must not carry a tag prefix.
func (Version) Core ¶ added in v0.72.0
Core returns MAJOR.MINOR.PATCH without pre-release or build metadata.
func (Version) IsPreRelease ¶ added in v0.72.0
IsPreRelease reports whether v carries pre-release identifiers. Build metadata alone does not make a pre-release: 1.4.0+5 is the 1.4.0 release.