Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Version ¶
type Version struct {
*semver.Version // Major(), Minor(), Patch(), Prerelease(), etc.
Commits int // commits ahead of the tagged commit (0 = exact tag)
Hash string // short (7-char) SHA of HEAD
Dirty bool // true if the working tree has uncommitted changes
}
Version wraps a parsed semver tag with additional git state.
func GetVersion ¶
GetVersion opens the git repository at repoPath (pass "." for the current working directory) and returns a Version derived from the most recent semver-compatible tag reachable from HEAD.
DetectDotGit is enabled, so repoPath can be any subdirectory of the repo.
func (Version) IsExact ¶
IsExact returns true when HEAD sits exactly on the tagged commit and the working tree has no uncommitted changes. Useful as a release gate.
func (Version) RCString ¶
RCString returns the version in vM.m.(p+1)+rcN form when commits have been made since the last tag. On an exact clean tag it is identical to String(). On a dirty-only working tree (no new commits) it returns the tag with a +dirty suffix without bumping the patch — there is no meaningful rc count.
func (Version) String ¶
String returns a semver-compatible string. When the repo is exactly on a tag and clean it is identical to the raw tag (e.g. "1.2.3"). Otherwise build metadata is appended:
1.2.3+4.gabcdef0 – 4 commits ahead, clean 1.2.3+4.gabcdef0.dirty – 4 commits ahead, dirty working tree 1.2.3+dirty – exactly on tag but dirty