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") diff --git a/repo.proto b/repo.proto index 62f287f..840804c 100644 --- a/repo.proto +++ b/repo.proto @@ -12,7 +12,7 @@ import "google/protobuf/timestamp.proto"; // Import the well-known type for Time // global settings for autogenpb `autogenpb:mutex` message Repo { // `autogenpb:marshal` - string fullPath = 1; // the actual path to the .git directory: '/home/devel/golang.org/x/tools' + string fullPath = 1; // `autogenpb:unique` // the actual path to the .git directory: '/home/devel/golang.org/x/tools' google.protobuf.Timestamp lastPull = 2; // last time a git pull was done string masterBranchName = 3; // git 'main' or 'master' branch name string develBranchName = 4; // whatever the git 'devel' branch name is