status is almost done

This commit is contained in:
Jeff Carr 2024-01-13 20:30:33 -06:00
parent 86873b296c
commit 966348d534
7 changed files with 92 additions and 29 deletions

View File

@ -22,12 +22,28 @@ func (rs *RepoStatus) Make() {
rs.window.Make() rs.window.Make()
rs.ready = true 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() { func (rs *RepoStatus) Draw() {
if ! rs.Ready() {return} if ! rs.Ready() {return}
log.Log(CHANGE, "Draw() window ready =", rs.ready) log.Log(CHANGE, "Draw() window ready =", rs.ready)
rs.window.Draw() rs.window.Draw()
rs.ready = true rs.ready = true
} }
func (rs *RepoStatus) Draw2() { func (rs *RepoStatus) Draw2() {
if ! rs.Ready() {return} if ! rs.Ready() {return}
log.Log(CHANGE, "draw(rs) ready =", rs.ready) log.Log(CHANGE, "draw(rs) ready =", rs.ready)

26
draw.go
View File

@ -50,7 +50,7 @@ func (rs *RepoStatus) drawGitBranches() {
} }
rs.masterDrop.Set(master) rs.masterDrop.Set(master)
// relabel the various gadgets with the right branch name // relabel the various gadgets with the right branch name
rs.masterBranch.SetLabel(master) rs.masterBranchVersion.SetLabel(master)
rs.major.SetTitle(master) rs.major.SetTitle(master)
rs.develDrop.Set("devel") rs.develDrop.Set("devel")
@ -58,15 +58,15 @@ func (rs *RepoStatus) drawGitBranches() {
var count *gui.Node var count *gui.Node
newgrid.NewButton("show branches", func() { rs.showBranchesButton = newgrid.NewButton("show branches", func() {
all := rs.getBranches() all := rs.getBranches()
i := len(all) i := len(all)
count.Set(strconv.Itoa(i) + " branches") count.Set(strconv.Itoa(i) + " branches")
}) })
count = newgrid.NewLabel("") count = newgrid.NewLabel("")
newgrid.NewButton("check branches", func() { rs.checkBranchesButton = newgrid.NewButton("check branches", func() {
if rs.checkBranches() { if rs.CheckBranches() {
log.Warn("Branches are perfect") log.Warn("Branches are perfect")
} else { } else {
log.Warn("Branches are not perfect") log.Warn("Branches are not perfect")
@ -77,7 +77,7 @@ func (rs *RepoStatus) drawGitBranches() {
func (rs *RepoStatus) drawGitStatus() { func (rs *RepoStatus) drawGitStatus() {
rs.gitStatusGroup = rs.window.Box().NewGroup("What GO Knows It Has") rs.gitStatusGroup = rs.window.Box().NewGroup("What GO Knows It Has")
newgrid := rs.gitStatusGroup.NewGrid("gridnuts", 2, 2) newgrid := rs.gitStatusGroup.NewGrid("gridnuts", 2, 2)
newgrid.SetNext(1,1) // newgrid.SetNext(1,1)
newgrid.Margin() newgrid.Margin()
newgrid.Pad() newgrid.Pad()
@ -86,9 +86,9 @@ func (rs *RepoStatus) drawGitStatus() {
rs.lasttag = gadgets.NewOneLiner(newgrid, "last tag") rs.lasttag = gadgets.NewOneLiner(newgrid, "last tag")
rs.currentVersion = gadgets.NewOneLiner(newgrid, "Version") rs.currentVersion = gadgets.NewOneLiner(newgrid, "Version")
rs.tagsDrop = gadgets.NewBasicDropdown(newgrid, "existing tags") rs.tagsDrop = gadgets.NewBasicDropdown(newgrid, "existing tags")
rs.masterBranch = gadgets.NewOneLiner(newgrid, "master") rs.masterBranchVersion = gadgets.NewOneLiner(newgrid, "master")
rs.develBranch = gadgets.NewOneLiner(newgrid, "devel") rs.develBranchVersion = gadgets.NewOneLiner(newgrid, "devel")
rs.jcarrBranch = gadgets.NewOneLiner(newgrid, "jcarr") rs.jcarrBranchVersion = gadgets.NewOneLiner(newgrid, "jcarr")
rs.dirtyLabel = gadgets.NewOneLiner(newgrid, "dirty") rs.dirtyLabel = gadgets.NewOneLiner(newgrid, "dirty")
@ -247,21 +247,21 @@ func (rs *RepoStatus) recommend() {
log.Warn("list the known tags") log.Warn("list the known tags")
rs.DisableEverything() rs.DisableEverything()
rs.populateTags() rs.populateTags()
log.Warn("Does devel == jcarr?", rs.develBranch.Get(), rs.jcarrBranch.Get()) log.Warn("Does devel == jcarr?", rs.develBranchVersion.Get(), rs.jcarrBranchVersion.Get())
if rs.develBranch.Get() != rs.jcarrBranch.Get() { if rs.develBranchVersion.Get() != rs.jcarrBranchVersion.Get() {
log.Warn("devel does not equal jcarr") log.Warn("devel does not equal jcarr")
log.Warn("merge or squash?") log.Warn("merge or squash?")
return return
} }
log.Warn("Does master == devel? ", rs.masterBranch.Get(), rs.develBranch.Get()) log.Warn("Does master == devel? ", rs.masterBranchVersion.Get(), rs.develBranchVersion.Get())
if rs.masterBranch.Get() != rs.develBranch.Get() { if rs.masterBranchVersion.Get() != rs.develBranchVersion.Get() {
log.Warn("master does not equal devel. merge devel into master") log.Warn("master does not equal devel. merge devel into master")
rs.EnableMergeDevel() rs.EnableMergeDevel()
rs.setMergeDevelCommands() rs.setMergeDevelCommands()
return return
} }
rs.getLastTagVersion() rs.getLastTagVersion()
if rs.lasttag.Get() != rs.masterBranch.Get() { if rs.lasttag.Get() != rs.masterBranchVersion.Get() {
log.Warn("master does not equal last tag") log.Warn("master does not equal last tag")
rs.incrementVersion() rs.incrementVersion()
rs.EnableSelectTag() rs.EnableSelectTag()

60
git.go
View File

@ -8,6 +8,16 @@ import (
"go.wit.com/log" "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 { func (rs *RepoStatus) getCurrentBranchName() string {
out := run(rs.repopath, "git", "branch --show-current") out := run(rs.repopath, "git", "branch --show-current")
log.Warn("getCurrentBranchName() =", out) log.Warn("getCurrentBranchName() =", out)
@ -78,14 +88,14 @@ func (rs *RepoStatus) getBranches() []string {
return all return all
} }
func (rs *RepoStatus) checkDirty() bool { func (rs *RepoStatus) CheckDirty() bool {
out := run(rs.repopath, "git", "diff-index HEAD") out := run(rs.repopath, "git", "diff-index HEAD")
if out == "" { if out == "" {
log.Warn("checkDirty() no", rs.repopath) log.Warn("CheckDirty() no", rs.repopath)
rs.dirtyLabel.Set("no") rs.dirtyLabel.Set("no")
return false return false
} else { } else {
log.Warn("checkDirty() true", rs.repopath) log.Warn("CheckDirty() true", rs.repopath)
rs.dirtyLabel.Set("dirty") rs.dirtyLabel.Set("dirty")
return true return true
} }
@ -93,7 +103,7 @@ func (rs *RepoStatus) checkDirty() bool {
} }
func (rs *RepoStatus) checkoutBranch(level string, branch string) { 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) log.Warn("checkoutBranch() checkDirty() == true for repo", rs.repopath, "looking for branch:", branch)
return return
} }
@ -106,16 +116,50 @@ func (rs *RepoStatus) checkoutBranch(level string, branch string) {
switch level { switch level {
case "master": case "master":
rs.masterBranch.Set(realversion) rs.masterBranchVersion.Set(realversion)
case "devel": case "devel":
rs.develBranch.Set(realversion) rs.develBranchVersion.Set(realversion)
case "user": case "user":
rs.jcarrBranch.Set(realversion) rs.jcarrBranchVersion.Set(realversion)
default: 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 hashCheck string
var perfect bool = true var perfect bool = true
all := rs.getBranches() all := rs.getBranches()

2
new.go
View File

@ -13,7 +13,7 @@ func New(p *gui.Node, path string) *RepoStatus {
repopath: path, repopath: path,
} }
rs.tags = make(map[string]string) 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 rs.ready = true
return rs return rs
} }

View File

@ -29,9 +29,9 @@ type RepoStatus struct {
tagsDrop *gadgets.BasicDropdown tagsDrop *gadgets.BasicDropdown
lasttag *gadgets.OneLiner lasttag *gadgets.OneLiner
masterBranch *gadgets.OneLiner masterBranchVersion *gadgets.OneLiner
develBranch *gadgets.OneLiner develBranchVersion *gadgets.OneLiner
jcarrBranch *gadgets.OneLiner jcarrBranchVersion *gadgets.OneLiner
develMerge *gui.Node develMerge *gui.Node
releaseVersion *gui.Node releaseVersion *gui.Node
@ -55,6 +55,9 @@ type RepoStatus struct {
develDrop *gadgets.BasicDropdown develDrop *gadgets.BasicDropdown
userDrop *gadgets.BasicDropdown userDrop *gadgets.BasicDropdown
showBranchesButton *gui.Node
checkBranchesButton *gui.Node
speed *gadgets.OneLiner speed *gadgets.OneLiner
speedActual *gadgets.OneLiner speedActual *gadgets.OneLiner
} }

View File

@ -127,7 +127,7 @@ func runCmd(path string, parts []string) (error, bool, string) {
thing := parts[0] thing := parts[0]
parts = parts[1:] parts = parts[1:]
log.Info("path =", path, "thing =", thing, "cmdline =", parts) log.Verbose("path =", path, "thing =", thing, "cmdline =", parts)
// Create the command // Create the command
cmd := exec.Command(thing, parts...) cmd := exec.Command(thing, parts...)

View File

@ -29,8 +29,8 @@ func (rs *RepoStatus) Update() {
rs.getLastTagVersion() rs.getLastTagVersion()
log.Warn("populateTags()") log.Warn("populateTags()")
rs.populateTags() rs.populateTags()
log.Warn("checkDirty()") log.Warn("CheckDirty()")
rs.checkDirty() rs.CheckDirty()
if rs.dirtyLabel.Get() != "no" { if rs.dirtyLabel.Get() != "no" {
log.Warn("dirty label != no. actual value:", rs.dirtyLabel.Get()) log.Warn("dirty label != no. actual value:", rs.dirtyLabel.Get())
@ -42,7 +42,7 @@ func (rs *RepoStatus) Update() {
devel := rs.develDrop.Get() devel := rs.develDrop.Get()
user := rs.userDrop.Get() user := rs.userDrop.Get()
// rs.checkDirty() this runs // rs.CheckDirty() this runs
log.Log(WARN, "") log.Log(WARN, "")
log.Log(WARN, "checkoutBranch", master) log.Log(WARN, "checkoutBranch", master)
rs.checkoutBranch("master", master) rs.checkoutBranch("master", master)