Documentation
¶
Overview ¶
Package version provides gale's version comparison rules, shared by `gale update` and `gale outdated` so they agree on what counts as an upgrade.
gale versions look like `<major>.<minor>.<patch>[-<revision>]`. Unlike semver, a `-<N>` suffix on the patch (with N all-digit) is a Debian-style revision — newer than the bare triple, not a pre-release. Any other suffix (e.g. `1.2.3-dev.2+abc`) is treated as a conventional semver pre-release and delegated to golang.org/x/mod/semver so dev → stable ordering keeps working. Non-semver strings (git hashes, "dev") are optimistic: IsNewer returns true so the update proceeds.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Base ¶ added in v0.21.0
Base strips the numeric revision suffix from v, returning the bare version triple. "1.8.1-4" → "1.8.1"; "1.0-rc1" → "1.0-rc1"; "1.2-0" → "1.2-0".
func HasRevisionSuffix ¶ added in v0.20.0
HasRevisionSuffix reports whether v ends with "-<digits>".
func IsNewer ¶
IsNewer reports whether candidate is strictly newer than current. See the package comment for the ordering rules.
func KeyNewer ¶ added in v0.19.0
KeyNewer reports whether version key a orders strictly after key b under gale's total order. Bases compare by semver when both parse as semver, by natural (digit-run-aware) ordering otherwise; equal bases break the tie on the numeric "-<N>" revision suffix (absent means 1), then on the raw string so the order is total.
Unlike IsNewer, this never returns optimistically true for non-semver strings — a max-selection loop over map keys needs a deterministic order or it degenerates to last-key-wins (gh#58).
func Latest ¶ added in v0.19.0
Latest returns the newest key in keys under KeyNewer, and false when keys is empty.
func Pick ¶ added in v0.19.0
Pick resolves a user-supplied version string against the set of available version keys. Exact match wins; a bare base (no "-<digits>" suffix) resolves to its highest available revision; a "-1" request falls back to a bare legacy entry. Returns ("", false) when nothing matches.
func SplitRevision ¶ added in v0.20.0
SplitRevision parses a version key into (base, revision). A missing or non-numeric "-N" suffix leaves revision at 1.
Types ¶
This section is empty.