From 966348d5343a13ca889805d5a46907927d07f4ce Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sat, 13 Jan 2024 20:30:33 -0600 Subject: [PATCH] status is almost done --- common.go | 16 +++++++++++++++ draw.go | 26 +++++++++++------------ git.go | 60 ++++++++++++++++++++++++++++++++++++++++++++++-------- new.go | 2 +- structs.go | 9 +++++--- unix.go | 2 +- update.go | 6 +++--- 7 files changed, 92 insertions(+), 29 deletions(-) diff --git a/common.go b/common.go index 1a8c4e2..fe118c6 100644 --- a/common.go +++ b/common.go @@ -22,12 +22,28 @@ func (rs *RepoStatus) Make() { rs.window.Make() rs.ready = true } + +func (rs *RepoStatus) Make2() { + if ! rs.Ready() {return} + log.Log(CHANGE, "Make() window ready =", rs.ready) + rs.window.Make() + rs.ready = true + draw(rs) +} + +func (rs *RepoStatus) TestDraw() { + if ! rs.Ready() {return} + log.Log(CHANGE, "TestDraw() RUNNING HERE") + rs.window.TestDraw() +} + func (rs *RepoStatus) Draw() { if ! rs.Ready() {return} log.Log(CHANGE, "Draw() window ready =", rs.ready) rs.window.Draw() rs.ready = true } + func (rs *RepoStatus) Draw2() { if ! rs.Ready() {return} log.Log(CHANGE, "draw(rs) ready =", rs.ready) diff --git a/draw.go b/draw.go index e4f1fa4..ea72ea0 100644 --- a/draw.go +++ b/draw.go @@ -50,7 +50,7 @@ func (rs *RepoStatus) drawGitBranches() { } rs.masterDrop.Set(master) // relabel the various gadgets with the right branch name - rs.masterBranch.SetLabel(master) + rs.masterBranchVersion.SetLabel(master) rs.major.SetTitle(master) rs.develDrop.Set("devel") @@ -58,15 +58,15 @@ func (rs *RepoStatus) drawGitBranches() { var count *gui.Node - newgrid.NewButton("show branches", func() { + rs.showBranchesButton = newgrid.NewButton("show branches", func() { all := rs.getBranches() i := len(all) count.Set(strconv.Itoa(i) + " branches") }) count = newgrid.NewLabel("") - newgrid.NewButton("check branches", func() { - if rs.checkBranches() { + rs.checkBranchesButton = newgrid.NewButton("check branches", func() { + if rs.CheckBranches() { log.Warn("Branches are perfect") } else { log.Warn("Branches are not perfect") @@ -77,7 +77,7 @@ func (rs *RepoStatus) drawGitBranches() { func (rs *RepoStatus) drawGitStatus() { rs.gitStatusGroup = rs.window.Box().NewGroup("What GO Knows It Has") newgrid := rs.gitStatusGroup.NewGrid("gridnuts", 2, 2) - newgrid.SetNext(1,1) + // newgrid.SetNext(1,1) newgrid.Margin() newgrid.Pad() @@ -86,9 +86,9 @@ func (rs *RepoStatus) drawGitStatus() { rs.lasttag = gadgets.NewOneLiner(newgrid, "last tag") rs.currentVersion = gadgets.NewOneLiner(newgrid, "Version") rs.tagsDrop = gadgets.NewBasicDropdown(newgrid, "existing tags") - rs.masterBranch = gadgets.NewOneLiner(newgrid, "master") - rs.develBranch = gadgets.NewOneLiner(newgrid, "devel") - rs.jcarrBranch = gadgets.NewOneLiner(newgrid, "jcarr") + rs.masterBranchVersion = gadgets.NewOneLiner(newgrid, "master") + rs.develBranchVersion = gadgets.NewOneLiner(newgrid, "devel") + rs.jcarrBranchVersion = gadgets.NewOneLiner(newgrid, "jcarr") rs.dirtyLabel = gadgets.NewOneLiner(newgrid, "dirty") @@ -247,21 +247,21 @@ func (rs *RepoStatus) recommend() { log.Warn("list the known tags") rs.DisableEverything() rs.populateTags() - log.Warn("Does devel == jcarr?", rs.develBranch.Get(), rs.jcarrBranch.Get()) - if rs.develBranch.Get() != rs.jcarrBranch.Get() { + log.Warn("Does devel == jcarr?", rs.develBranchVersion.Get(), rs.jcarrBranchVersion.Get()) + if rs.develBranchVersion.Get() != rs.jcarrBranchVersion.Get() { log.Warn("devel does not equal jcarr") log.Warn("merge or squash?") return } - log.Warn("Does master == devel? ", rs.masterBranch.Get(), rs.develBranch.Get()) - if rs.masterBranch.Get() != rs.develBranch.Get() { + log.Warn("Does master == devel? ", rs.masterBranchVersion.Get(), rs.develBranchVersion.Get()) + if rs.masterBranchVersion.Get() != rs.develBranchVersion.Get() { log.Warn("master does not equal devel. merge devel into master") rs.EnableMergeDevel() rs.setMergeDevelCommands() return } rs.getLastTagVersion() - if rs.lasttag.Get() != rs.masterBranch.Get() { + if rs.lasttag.Get() != rs.masterBranchVersion.Get() { log.Warn("master does not equal last tag") rs.incrementVersion() rs.EnableSelectTag() diff --git a/git.go b/git.go index 7f36ed8..c240f2b 100644 --- a/git.go +++ b/git.go @@ -8,6 +8,16 @@ import ( "go.wit.com/log" ) +func (rs *RepoStatus) GetCurrentBranchName() string { + return rs.currentBranch.Get() +} +func (rs *RepoStatus) GetCurrentBranchVersion() string { + return rs.currentVersion.Get() +} +func (rs *RepoStatus) GetLastTagVersion() string { + return rs.lasttag.Get() +} + func (rs *RepoStatus) getCurrentBranchName() string { out := run(rs.repopath, "git", "branch --show-current") log.Warn("getCurrentBranchName() =", out) @@ -78,14 +88,14 @@ func (rs *RepoStatus) getBranches() []string { return all } -func (rs *RepoStatus) checkDirty() bool { +func (rs *RepoStatus) CheckDirty() bool { out := run(rs.repopath, "git", "diff-index HEAD") if out == "" { - log.Warn("checkDirty() no", rs.repopath) + log.Warn("CheckDirty() no", rs.repopath) rs.dirtyLabel.Set("no") return false } else { - log.Warn("checkDirty() true", rs.repopath) + log.Warn("CheckDirty() true", rs.repopath) rs.dirtyLabel.Set("dirty") return true } @@ -93,7 +103,7 @@ func (rs *RepoStatus) checkDirty() bool { } func (rs *RepoStatus) checkoutBranch(level string, branch string) { - if rs.checkDirty() { + if rs.CheckDirty() { log.Warn("checkoutBranch() checkDirty() == true for repo", rs.repopath, "looking for branch:", branch) return } @@ -106,16 +116,50 @@ func (rs *RepoStatus) checkoutBranch(level string, branch string) { switch level { case "master": - rs.masterBranch.Set(realversion) + rs.masterBranchVersion.Set(realversion) case "devel": - rs.develBranch.Set(realversion) + rs.develBranchVersion.Set(realversion) case "user": - rs.jcarrBranch.Set(realversion) + rs.jcarrBranchVersion.Set(realversion) default: } } -func (rs *RepoStatus) checkBranches() bool { +// returns "master", "devel", os.Username, etc +func (rs *RepoStatus) GetMasterName() string { + name := rs.masterDrop.Get() + log.Warn("GetMasterName() =", name) + return name +} +func (rs *RepoStatus) GetDevelName() string { + name := rs.develDrop.Get() + log.Warn("GetDevelName() =", name) + return name +} +func (rs *RepoStatus) GetUserName() string { + name := rs.userDrop.Get() + log.Warn("GetUserName() =", name) + return name +} + +// returns the git versions like "1.3-2-laksdjf" or whatever +func (rs *RepoStatus) GetMasterVersion() string { + name := rs.masterBranchVersion.Get() + log.Warn("GetMasterVersion() =", name) + return name +} +func (rs *RepoStatus) GetDevelVersion() string { + name := rs.develBranchVersion.Get() + log.Warn("GetBranchVersion() =", name) + return name +} +func (rs *RepoStatus) GetUserVersion() string { + name := rs.jcarrBranchVersion.Get() + log.Warn("GetUserVersion() =", name) + return name +} + +func (rs *RepoStatus) CheckBranches() bool { var hashCheck string var perfect bool = true all := rs.getBranches() diff --git a/new.go b/new.go index 3142011..00beb4e 100644 --- a/new.go +++ b/new.go @@ -13,7 +13,7 @@ func New(p *gui.Node, path string) *RepoStatus { repopath: path, } rs.tags = make(map[string]string) - rs.window = gadgets.NewBasicWindow(p, "GO Repo Details") + rs.window = gadgets.NewBasicWindow(p, "GO Repo Details " + path) rs.ready = true return rs } diff --git a/structs.go b/structs.go index 8d2c599..b7ddc53 100644 --- a/structs.go +++ b/structs.go @@ -29,9 +29,9 @@ type RepoStatus struct { tagsDrop *gadgets.BasicDropdown lasttag *gadgets.OneLiner - masterBranch *gadgets.OneLiner - develBranch *gadgets.OneLiner - jcarrBranch *gadgets.OneLiner + masterBranchVersion *gadgets.OneLiner + develBranchVersion *gadgets.OneLiner + jcarrBranchVersion *gadgets.OneLiner develMerge *gui.Node releaseVersion *gui.Node @@ -55,6 +55,9 @@ type RepoStatus struct { develDrop *gadgets.BasicDropdown userDrop *gadgets.BasicDropdown + showBranchesButton *gui.Node + checkBranchesButton *gui.Node + speed *gadgets.OneLiner speedActual *gadgets.OneLiner } diff --git a/unix.go b/unix.go index 215a199..e28ce07 100644 --- a/unix.go +++ b/unix.go @@ -127,7 +127,7 @@ func runCmd(path string, parts []string) (error, bool, string) { thing := parts[0] parts = parts[1:] - log.Info("path =", path, "thing =", thing, "cmdline =", parts) + log.Verbose("path =", path, "thing =", thing, "cmdline =", parts) // Create the command cmd := exec.Command(thing, parts...) diff --git a/update.go b/update.go index 429bb47..429920c 100644 --- a/update.go +++ b/update.go @@ -29,8 +29,8 @@ func (rs *RepoStatus) Update() { rs.getLastTagVersion() log.Warn("populateTags()") rs.populateTags() - log.Warn("checkDirty()") - rs.checkDirty() + log.Warn("CheckDirty()") + rs.CheckDirty() if rs.dirtyLabel.Get() != "no" { log.Warn("dirty label != no. actual value:", rs.dirtyLabel.Get()) @@ -42,7 +42,7 @@ func (rs *RepoStatus) Update() { devel := rs.develDrop.Get() user := rs.userDrop.Get() - // rs.checkDirty() this runs + // rs.CheckDirty() this runs log.Log(WARN, "") log.Log(WARN, "checkoutBranch", master) rs.checkoutBranch("master", master)