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 IsBareVersion(s string) bool
- func MajorMinor(version string) (major, minor int, err error)
- func RotationPattern(tokens []string, major, minor int) (string, error)
- 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) SetVersionOverride(v string)
- func (r *Resolver) Warnings() []string
- func (r *Resolver) WouldBeVersions() []string
- type TagVersion
- type Version
Constants ¶
This section is empty.
Variables ¶
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.
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 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.
Types ¶
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) 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.