Documentation
¶
Overview ¶
Package version defines how Angelia parses, orders and classifies upstream versions. Each scheme lives in its own subpackage (semver, pep440, calver, lexical); package schemes picks one per source kind and adds the lexical fallback.
Every function here is pure: no I/O, no shared state, safe for concurrent use.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalid = errors.New("invalid version")
ErrInvalid is wrapped by every parse error.
Functions ¶
func CompareDigits ¶
CompareDigits compares two non-empty strings of ASCII digits by numeric value, without overflow: "007" == "7" < "10".
func Natural ¶
Natural compares two strings in natural order: runs of ASCII digits compare by numeric value ("1.10" > "1.9"), other runs compare bytewise, and a string that is a prefix of the other sorts first. Strings that are equal under these rules (e.g. "1.01" and "1.1") are ordered bytewise, so Natural returns 0 only for identical strings.
Types ¶
type Bump ¶
type Bump string
Bump is the kind of change between two versions, as used by the policy `bump: [major, minor]` filter and the event's bump field.
type ParseError ¶
ParseError describes why a raw string is not a valid version of a scheme.
func (*ParseError) Error ¶
func (e *ParseError) Error() string
func (*ParseError) Unwrap ¶
func (e *ParseError) Unwrap() error
Unwrap makes errors.Is(err, ErrInvalid) true.
type Scheme ¶
type Scheme interface {
// Name is the scheme's identifier as used in configuration, e.g. "pep440".
Name() string
// Parse parses raw. Errors wrap ErrInvalid.
Parse(raw string) (Version, error)
// Compare returns -1 if a < b, 0 if a and b have the same precedence, +1 if a > b.
Compare(a, b Version) int
// IsPrerelease reports whether v is a pre-release (alpha, beta, rc, dev, ...).
IsPrerelease(v Version) bool
// Bump classifies the change from prev to next. It returns BumpOther
// unless next is strictly greater than prev and both belong to the scheme.
//
// prev must be the greatest known version below next, not the latest
// known version: when 2.0.0 is known and the backport 1.9.4 appears, pass
// prev = 1.9.3 to get BumpPatch (with prev = 2.0.0 the result is BumpOther).
Bump(prev, next Version) Bump
}
Scheme parses, orders and classifies the versions of one versioning scheme.
Compare, IsPrerelease and Bump accept any Version, never panic, and keep a total order when a set mixes schemes (which happens when unparseable versions fall back to lexical): versions of the scheme itself rank above versions of any other scheme, and foreign versions are ordered among themselves with Natural on their String form.
type Version ¶
type Version interface {
// String returns the normalized form, e.g. "1.0rc1" for the PEP 440 input "1.0-RC1".
String() string
// Scheme returns the name of the scheme that parsed the version.
Scheme() string
}
Version is a parsed version. Each scheme has its own concrete type.
Never compare two Versions with == or use them as map keys: concrete types hold slices, and equal precedence is not identity. Use Scheme.Compare to order them and String to display them. Compare returning 0 does not mean the same version ("1.0" and "1.0.0" in PEP 440, "1.0.0+a" and "1.0.0+b" in SemVer), so key known-version sets by the raw upstream string.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package calver implements calendar versioning for tags such as "2026.10.1", "2026.10.15", "2026.3", "24.04" and "24.04.1-rc1".
|
Package calver implements calendar versioning for tags such as "2026.10.1", "2026.10.15", "2026.3", "24.04" and "24.04.1-rc1". |
|
Package lexical is the fallback version scheme: any non-blank string is a version, ordered by natural string order (version.Natural), so "1.10" sorts after "1.9".
|
Package lexical is the fallback version scheme: any non-blank string is a version, ordered by natural string order (version.Natural), so "1.10" sorts after "1.9". |
|
Package pep440 implements Python version identifiers as specified by PEP 440 / the PyPA "Version specifiers" specification, including epochs, pre-, post- and dev-releases, local versions and the normalization rules (case, separators, spelling variants such as "alpha", "c", "rev", implicit numbers and implicit post-releases "1.0-1").
|
Package pep440 implements Python version identifiers as specified by PEP 440 / the PyPA "Version specifiers" specification, including epochs, pre-, post- and dev-releases, local versions and the normalization rules (case, separators, spelling variants such as "alpha", "c", "rev", implicit numbers and implicit post-releases "1.0-1"). |
|
Package schemes chooses the version scheme of a watch (by source kind, overridable per watch) and wraps it so that unparseable versions fall back to the lexical scheme instead of failing.
|
Package schemes chooses the version scheme of a watch (by source kind, overridable per watch) and wraps it so that unparseable versions fall back to the lexical scheme instead of failing. |
|
Package semver implements Semantic Versioning 2.0.0 (https://semver.org) with the npm-style loose prefix: surrounding white space, a leading "=" and a leading "v" or "V" are accepted and dropped ("v1.2.3" == "1.2.3").
|
Package semver implements Semantic Versioning 2.0.0 (https://semver.org) with the npm-style loose prefix: surrounding white space, a leading "=" and a leading "v" or "V" are accepted and dropped ("v1.2.3" == "1.2.3"). |