summaryrefslogtreecommitdiff
path: root/currentVersions.go
diff options
context:
space:
mode:
Diffstat (limited to 'currentVersions.go')
-rw-r--r--currentVersions.go48
1 files changed, 27 insertions, 21 deletions
diff --git a/currentVersions.go b/currentVersions.go
index 8b9d16f..d93df8d 100644
--- a/currentVersions.go
+++ b/currentVersions.go
@@ -14,44 +14,50 @@ import (
"go.wit.com/log"
)
-func (repo *Repo) GetMasterVersion() string {
+func (repo *Repo) InitVersions() {
+ repo.setMasterVersion()
+ repo.setDevelVersion()
+ repo.setUserVersion()
+}
+
+func (repo *Repo) setMasterVersion() {
bname := repo.GetMasterBranchName()
v, err := repo.gitVersionByName(bname)
/*
count := repo.LenGitTags()
- log.Info(repo.GoPath, "tag count", count)
+ log.Info(repo.GetGoPath(), "tag count", count)
repo.UpdateGitTags()
count = repo.LenGitTags()
- log.Info(repo.GoPath, "tag count", count)
+ log.Info(repo.GetGoPath(), "tag count", count)
*/
if err == nil {
- return v
+ repo.MasterVersion = v
} else {
log.Log(GITPBWARN, "gitpb.GitMasterVersion() error:", err)
- return ""
+ repo.MasterVersion = "giterr"
}
}
-func (repo *Repo) GetDevelVersion() string {
+func (repo *Repo) setDevelVersion() {
bname := repo.GetDevelBranchName()
v, err := repo.gitVersionByName(bname)
if err == nil {
- return v
+ repo.DevelVersion = v
} else {
log.Log(GITPBWARN, "gitpb.GitDevelVersion() error:", err)
- return ""
+ repo.DevelVersion = "deverr"
}
}
-func (repo *Repo) GetUserVersion() string {
+func (repo *Repo) setUserVersion() {
bname := repo.GetUserBranchName()
v, err := repo.gitVersionByName(bname)
if err == nil {
- return v
+ repo.UserVersion = v
} else {
log.Log(GITPBWARN, "gitpb.GitUserVersion() error:", err)
- return ""
+ repo.UserVersion = "uerr"
}
}
@@ -61,7 +67,7 @@ func (repo *Repo) GetCurrentBranchName() string {
r := repo.RunQuiet([]string{"git", "branch", "--show-current"})
output := strings.Join(r.Stdout, "\n")
if r.Error != nil {
- log.Log(GITPBWARN, "GetCurrentBranchName() not in a git repo?", r.Error, repo.GoPath)
+ log.Log(GITPBWARN, "GetCurrentBranchName() not in a git repo?", r.Error, repo.GetGoPath())
log.Log(GITPBWARN, "GetCurrentBranchName() output might have worked anyway:", output)
}
return strings.TrimSpace(output)
@@ -92,7 +98,7 @@ func (repo *Repo) gitDescribeByHash(hash string) (string, error) {
r := repo.RunQuiet([]string{"git", "describe", "--tags", "--always", hash})
out := strings.Join(r.Stdout, "\n")
if r.Error != nil {
- log.Warn("not in a git repo or bad hash?", r.Error, repo.GoPath)
+ log.Warn("not in a git repo or bad hash?", r.Error, repo.GetGoPath())
return out, r.Error
}
return out, r.Error
@@ -137,7 +143,7 @@ func (repo *Repo) gitVersionByName(name string) (string, error) {
output := strings.Join(r.Stdout, "\n")
if r.Error != nil {
log.Log(GITPBWARN, "gitDescribeByName() output might have worked anyway:", output)
- log.Log(GITPBWARN, "gitDescribeByName() not in a git repo?", r.Error, repo.GoPath)
+ log.Log(GITPBWARN, "gitDescribeByName() not in a git repo?", r.Error, repo.GetGoPath())
return "", r.Error
}
return strings.TrimSpace(output), nil
@@ -154,7 +160,7 @@ func (repo *Repo) gitVersionByName(name string) (string, error) {
log.Log(GITPBWARN, "cmd =", cmd)
log.Log(GITPBWARN, "err =", result.Error)
log.Log(GITPBWARN, "output (might have worked with error?) =", output)
- log.Log(GITPBWARN, "not in a git repo or bad tag?", repo.GoPath)
+ log.Log(GITPBWARN, "not in a git repo or bad tag?", repo.GetGoPath())
return "", result.Error
}
@@ -179,13 +185,13 @@ func (repo *Repo) IsBranch(findname string) bool {
continue
}
path, filename := filepath.Split(tagname)
- log.Log(GITPB, "gitpb.IsBranch() tag:", path, filename, "from", repo.GoPath)
+ log.Log(GITPB, "gitpb.IsBranch() tag:", path, filename, "from", repo.GetGoPath())
if filename == findname {
- log.Log(GITPB, "gitpb.IsBranch() found tag:", path, filename, "from", repo.GoPath)
+ log.Log(GITPB, "gitpb.IsBranch() found tag:", path, filename, "from", repo.GetGoPath())
return true
}
}
- log.Log(GITPB, "did not find tag:", findname, "in", repo.GoPath)
+ log.Log(GITPB, "did not find tag:", findname, "in", repo.GetGoPath())
return false
}
@@ -201,13 +207,13 @@ func (repo *Repo) IsLocalBranch(findname string) bool {
continue
}
path, filename := filepath.Split(tagname)
- log.Log(GITPB, "gitpb.IsBranch() tag:", path, filename, "from", repo.GoPath)
+ log.Log(GITPB, "gitpb.IsBranch() tag:", path, filename, "from", repo.GetGoPath())
if filename == findname {
- log.Log(GITPB, "gitpb.IsBranch() found tag:", path, filename, "from", repo.GoPath)
+ log.Log(GITPB, "gitpb.IsBranch() found tag:", path, filename, "from", repo.GetGoPath())
return true
}
}
- log.Log(GITPB, "did not find tag:", findname, "in", repo.GoPath)
+ log.Log(GITPB, "did not find tag:", findname, "in", repo.GetGoPath())
return false
}