From a115ba144b00dc0339a8cf7eae6bdf2aab5fb4b5 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Mon, 16 Dec 2024 03:04:39 -0600 Subject: work on supporting arbitrary paths --- currentVersions.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'currentVersions.go') diff --git a/currentVersions.go b/currentVersions.go index beecc4f..e844831 100644 --- a/currentVersions.go +++ b/currentVersions.go @@ -77,6 +77,7 @@ func (repo *Repo) GetUserVersion() string { return "" } } + func (repo *Repo) GetCurrentBranchName() string { r := repo.RunQuiet([]string{"git", "branch", "--show-current"}) output := strings.Join(r.Stdout, "\n") @@ -87,6 +88,24 @@ func (repo *Repo) GetCurrentBranchName() string { return strings.TrimSpace(output) } +// this is used often. probably move everything to this +// returns things like +// v0.2.2 +// v0.22.39-1-g2141737 +// v0.23-dirty +// mystuff +func (repo *Repo) GetCurrentVersion() string { + if repo == nil { + return "" + } + bver := repo.GetCurrentBranchVersion() + if repo.CheckDirty() { + bver = bver + "-dirty" + } + return bver +} + +// always spawns 'git' and always should spawn 'git' func (repo *Repo) GetCurrentBranchVersion() string { if repo == nil { log.Info("repo.GetCurrentBranchVersion() repo == nil") -- cgit v1.2.3