summaryrefslogtreecommitdiff
path: root/update.go
diff options
context:
space:
mode:
Diffstat (limited to 'update.go')
-rw-r--r--update.go82
1 files changed, 73 insertions, 9 deletions
diff --git a/update.go b/update.go
index 35bee63..3cafce2 100644
--- a/update.go
+++ b/update.go
@@ -3,12 +3,83 @@ package repostatus
import (
"errors"
"fmt"
+ "strings"
"time"
"go.wit.com/log"
)
-func (rs *RepoStatus) Update() {
+func (rs *RepoStatus) gitBranchAll() {
+ err, out := rs.RunCmd([]string{"git", "branch", "--all"})
+ if err != nil {
+ log.Log(WARN, "git branch failed", rs.String())
+ }
+ all := strings.Split(out, "\n")
+ for _, s := range all {
+ // log.Log(WARN, "found branch", i, s)
+ rs.targetBranch.AddText(s)
+ }
+ // i := len(all)
+ // log.Log(WARN, "branch count =", i)
+}
+
+func (rs *RepoStatus) UpdateNew() {
+ if !rs.Ready() {
+ log.Log(WARN, "can't update yet. ready is false")
+ log.Error(errors.New("Update() is not ready yet"))
+ return
+ }
+ // do things that are safe even if the git tree is dirty
+ // rs.path.SetValue(rs.repopath)
+ rs.getCurrentBranchName()
+ // rs.window.SetTitle(rs.repopath + " GO repo Details")
+ rs.getCurrentBranchVersion()
+ rs.getLastTagVersion()
+ rs.populateTags()
+ rs.CheckDirty()
+
+ // get the master branch version
+ mName := rs.GetMasterBranchName()
+ cmd := []string{"git", "describe", "--tags", mName}
+ err, out := rs.RunCmd(cmd)
+ if err == nil {
+ log.Log(INFO, "git cmd =", cmd, "worked =", out)
+ rs.SetMasterVersion(out)
+ } else {
+ log.Log(WARN, "git cmd =", cmd)
+ log.Log(WARN, "git err =", err)
+ log.Log(WARN, "git master failed", mName, rs.Path())
+ }
+
+ // get the devel branch version
+ dName := rs.GetDevelBranchName()
+ cmd = []string{"git", "describe", "--tags", dName}
+ err, out = rs.RunCmd(cmd)
+ if err == nil {
+ log.Log(INFO, "git cmd =", cmd, "worked =", out)
+ rs.SetDevelVersion(out)
+ } else {
+ log.Log(WARN, "git cmd =", cmd)
+ log.Log(WARN, "git err =", err)
+ log.Log(WARN, "git devel failed", dName, rs.Path())
+ }
+
+ // get the user branch version
+ uName := rs.GetUserBranchName()
+ cmd = []string{"git", "describe", "--tags", uName}
+ err, out = rs.RunCmd(cmd)
+ if err == nil {
+ log.Log(INFO, "git cmd =", cmd, "worked =", out)
+ rs.SetUserVersion(out)
+ } else {
+ log.Log(WARN, "git cmd =", cmd)
+ log.Log(WARN, "git err =", err)
+ log.Log(WARN, "git user failed", uName, rs.Path())
+ }
+}
+
+// deprecate / redo what is left of this
+func (rs *RepoStatus) UpdateOld() {
if !rs.Ready() {
log.Log(WARN, "can't update yet. ready is false")
log.Error(errors.New("Update() is not ready yet"))
@@ -16,14 +87,7 @@ func (rs *RepoStatus) Update() {
}
log.Log(INFO, "Update() START")
duration := timeFunction(func() {
- // do things that are safe even if the git tree is dirty
- // rs.path.SetValue(rs.repopath)
- rs.getCurrentBranchName()
- // rs.window.SetTitle(rs.repopath + " GO repo Details")
- rs.getCurrentBranchVersion()
- rs.getLastTagVersion()
- rs.populateTags()
- rs.CheckDirty()
+ rs.UpdateNew()
if rs.dirtyLabel.String() != "no" {
log.Warn("dirty label != no. actual value:", rs.dirtyLabel.String())