summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-12-16 03:04:39 -0600
committerJeff Carr <[email protected]>2024-12-16 03:04:39 -0600
commita115ba144b00dc0339a8cf7eae6bdf2aab5fb4b5 (patch)
treeadc37ca690c207576dfbcbae3ec9ed421099f813
parentcea5968b0fe717889cd4ae9611933649f48ac7f6 (diff)
work on supporting arbitrary pathsv0.0.33
-rw-r--r--currentVersions.go19
-rw-r--r--repo.proto2
2 files changed, 20 insertions, 1 deletions
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