From 0b4f4d76866ccc500112cfe553240c47961258e2 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Fri, 16 Feb 2024 17:55:13 -0600 Subject: ready to work on creating branches --- update.go | 89 +++++++++++++++++++-------------------------------------------- 1 file changed, 26 insertions(+), 63 deletions(-) (limited to 'update.go') diff --git a/update.go b/update.go index 3cafce2..8e60e8c 100644 --- a/update.go +++ b/update.go @@ -29,55 +29,45 @@ func (rs *RepoStatus) UpdateNew() { 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() + + // store the current checked out branch name and version + rs.checkCurrentBranchName() + rs.checkCurrentBranchVersion() + + // read in the tags rs.populateTags() + + // record if the repo is dirty rs.CheckDirty() - // get the master branch version + // store the last tag version + rs.setLastTagVersion() + + // store 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()) - } + out, _ := rs.gitDescribeByName(mName) + rs.setMasterVersion(out) - // get the devel branch version + // store 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) + if dName == "" { + rs.setDevelVersion("") } else { - log.Log(WARN, "git cmd =", cmd) - log.Log(WARN, "git err =", err) - log.Log(WARN, "git devel failed", dName, rs.Path()) + out, _ = rs.gitDescribeByName(dName) + rs.setDevelVersion(out) } - // get the user branch version + // store 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) + if uName == "" { + rs.setUserVersion("") } else { - log.Log(WARN, "git cmd =", cmd) - log.Log(WARN, "git err =", err) - log.Log(WARN, "git user failed", uName, rs.Path()) + out, _ = rs.gitDescribeByName(uName) + rs.setUserVersion(out) } } +/* // deprecate / redo what is left of this func (rs *RepoStatus) UpdateOld() { if !rs.Ready() { @@ -120,6 +110,7 @@ func (rs *RepoStatus) UpdateOld() { rs.setSpeed(duration) log.Log(INFO, "Update() END") } +*/ func (rs *RepoStatus) setSpeed(duration time.Duration) { s := fmt.Sprint(duration) @@ -194,31 +185,3 @@ func (rs *RepoStatus) EnableSelectTag() { rs.releaseVersion.Enable() } } - -// This doesn't switch branches -func (rs *RepoStatus) UpdateCurrent() { - if !rs.Ready() { - log.Log(WARN, "can't update yet. ready is false") - log.Error(errors.New("Update() is not ready yet")) - return - } - log.Log(INFO, "Update() START") - rs.getCurrentBranchName() - rs.getCurrentBranchVersion() - rs.getLastTagVersion() - rs.populateTags() - rs.CheckDirty() - - // read in the .git/config each update - rs.readGitConfig() - - // this looks into .git somewhat - rs.CheckBranches() - - if rs.dirtyLabel.String() != "no" { - // the repo is dirty - log.Warn("dirty label != no. actual value:", rs.dirtyLabel.String()) - rs.DisableEverything() - return - } -} -- cgit v1.2.3