Documentation
¶
Overview ¶
Package semver provides semantic versioning operations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatTagWithPrefix ¶
FormatTagWithPrefix formats a version as a git tag with the given prefix. prefix="v" → "v1.2.3"; prefix="" → "1.2.3"; prefix="release-" → "release-1.2.3". Use this instead of Version.Tag() when tag-prefix is configurable.
func FormatVersion ¶
FormatVersion formats a version for output (e.g., "1.2.3").
Types ¶
type BumpType ¶
type BumpType int
BumpType indicates what type of version bump is needed.
func DetectBumpType ¶
DetectBumpType analyzes commit types and returns the appropriate bump type. An optional rules map (map[string]string) overrides the built-in mapping. Built-in: "breaking-change"→BumpMajor, "feat"→BumpMinor, "fix"→BumpPatch.
IMPORTANT: "BREAKING CHANGE" (with space) is NOT a trigger in the built-in switch. Callers must inject "breaking-change" (hyphenated) into commitTypes for commits with a "!" suffix or "BREAKING CHANGE:" footer.
The variadic parameter accepts map[string]string (compatible with conventional.BumpRules = map[string]BumpLevel = map[string]string).
type Version ¶
Version represents a semantic version.
func BootstrapVersion ¶
BootstrapVersion returns the initial version when no tags exist. First "feat" commit → v0.1.0 First "fix" commit → v0.0.1 "breaking-change" → v1.0.0 No commits or unrecognized types → v0.0.0
func NextVersion ¶
NextVersion calculates the next version based on bump type. If bump is BumpNone, returns current version unchanged.
func ParseVersion ¶
ParseVersion parses a version string (e.g., "1.2.3" or "v1.2.3"). Returns Version and error if parsing fails.
func ParseVersionFromTag ¶
ParseVersionFromTag strips the given prefix from tagName, then calls ParseVersion. Returns an error if tagName does not start with prefix. Example: ParseVersionFromTag("v1.2.3", "v") → Version{1,2,3}
ParseVersionFromTag("release-2.0.0", "release-") → Version{2,0,0}
ParseVersionFromTag("1.2.3", "") → Version{1,2,3}