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.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)

26
draw.go
View File

@ -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()

60
git.go
View File

@ -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()

2
new.go
View File

@ -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
}

View File

@ -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
}

View File

@ -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...)

View File

@ -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)