diff --git a/releaseWindow.go b/releaseWindow.go index b42eb27..3abec34 100644 --- a/releaseWindow.go +++ b/releaseWindow.go @@ -2,10 +2,13 @@ package main import ( + "os" + "go.wit.com/gui" "go.wit.com/log" "go.wit.com/lib/gadgets" + "go.wit.com/lib/gui/repostatus" ) var release releaseStruct @@ -13,15 +16,16 @@ var release releaseStruct type releaseStruct struct { current *repo - win *gadgets.BasicWindow - box *gui.Node - group *gui.Node - grid *gui.Node - repo *gadgets.OneLiner - status *gadgets.OneLiner - notes *gadgets.OneLiner - version *gadgets.OneLiner - reason *gadgets.OneLiner + win *gadgets.BasicWindow + box *gui.Node + group *gui.Node + grid *gui.Node + repo *gadgets.OneLiner + status *gadgets.OneLiner + readOnly *gadgets.OneLiner + notes *gadgets.OneLiner + version *gadgets.OneLiner + reason *gadgets.OneLiner openrepo *gui.Node @@ -77,7 +81,11 @@ func createReleaseWindow() { release.status.SetValue("BAD") release.current.goSumStatus.SetValue("BAD") } - release.current.status.Update() + if release.current.status.ReadOnly() { + release.readOnly.SetValue("true") + } else { + release.readOnly.SetValue("false") + } release.current.newScan() if release.current.dirtyLabel.String() == "PERFECT" { @@ -91,6 +99,7 @@ func createReleaseWindow() { release.repo = gadgets.NewOneLiner(release.grid, "repo") release.status = gadgets.NewOneLiner(release.grid, "status") + release.readOnly = gadgets.NewOneLiner(release.grid, "read-only") release.notes = gadgets.NewOneLiner(release.grid, "notes") release.version = gadgets.NewOneLiner(release.grid, "version") @@ -138,6 +147,22 @@ func createReleaseWindow() { } else { log.Info("BAD VERSION repo has go.sum requirements that are screwed up.", tmp) log.Info("BAD VERSION need to addRepo() the missing repo", missing) + if repostatus.VerifyLocalGoRepo(missing) { + log.Info("BAD VERSION local directory exists", missing) + addRepo(reposgrid, missing, "master", "master", "master") + } else { + log.Info("BAD VERSION local directory does not exist", missing) + log.Info("START download of:", missing) + os.Setenv("GO111MODULE", "off") + err, output := release.current.status.RunCmd([]string{"go", "get", "-v", "-u", missing}) + log.Warn(output) + log.Info("END download of:", missing) + if err == nil { + log.Warn("go get worked. recheck go.sum") + } else { + log.Warn("go get failed") + } + } // addRepo(reposgrid, missing, "master", "master", "master") } } @@ -175,6 +200,11 @@ func createReleaseWindow() { } buttonEnable() }) + release.goGetB = release.grid.NewButton("SetMainWorkingName(guimaster)", func() { + buttonDisable() + release.current.status.SetMainWorkingName("guimaster") + buttonEnable() + }) } func buttonDisable() { @@ -196,6 +226,7 @@ func buttonEnable() { } func findDirty2() bool { + log.Info("findDirty2() START") for _, repo := range me.allrepos { goSumS := repo.goSumStatus.String() dirtyS := repo.dirtyLabel.String() @@ -206,25 +237,43 @@ func findDirty2() bool { if goSumS == "DIRTY 2" { log.Info("repo DIRTY 2", repo.String(), goSumS, dirtyS) - release.repo.SetValue(repo.status.String()) - release.status.SetValue("dirty 2") - release.notes.SetValue("check dirty 2 manually") - release.current = repo - release.openrepo.Enable() + if setCurrentRepo(repo, "dirty 2", "check manually I guess") { + return true + } return true } else { log.Info("repo not DIRTY 2", repo.String(), goSumS, dirtyS) } } + log.Info("findDirty2() END") return false } +func setCurrentRepo(newcur *repo, s string, note string) bool { + if newcur.status.ReadOnly() { + return false + } + + release.repo.SetValue(newcur.status.String()) + release.status.SetValue(s) + release.notes.SetValue(note) + release.current = newcur + release.openrepo.Enable() + + if newcur.status.ReadOnly() { + release.readOnly.SetValue("true ro") + } else { + release.readOnly.SetValue("false ro") + } + return true +} + func findNextDirty() bool { for _, repo := range me.allrepos { goSumS := repo.goSumStatus.String() dirtyS := repo.dirtyLabel.String() - log.Info("repo", repo.String(), goSumS, dirtyS) + log.Info("findNextDirty()", repo.String(), goSumS, dirtyS) if goSumS == "PRIMATIVE" { continue } @@ -239,12 +288,9 @@ func findNextDirty() bool { if dirtyS == "PERFECT" { continue } - release.repo.SetValue(repo.status.String()) - release.status.SetValue("clean") - release.notes.SetValue("check manually") - release.current = repo - release.openrepo.Enable() - return true + if setCurrentRepo(repo, "clean", "check manually") { + return true + } } if goSumS == "DIRTY" { if ok, missing := repo.status.CheckGoSum(); ok { @@ -256,14 +302,9 @@ func findNextDirty() bool { continue } - // release.repo.SetValue(repo.status.String()) - // release.status.SetValue("bad") - release.repo.SetValue(repo.status.String()) - release.status.SetValue("dirty") - release.notes.SetValue("commit changes") - release.current = repo - release.openrepo.Enable() - return true + if setCurrentRepo(repo, "dirty", "commit changes") { + return true + } } } log.Info("tried to findNextDirty() but not sure what to do next") @@ -275,7 +316,7 @@ func findNextRepo() { goSumS := repo.goSumStatus.String() dirtyS := repo.dirtyLabel.String() - log.Info("repo", repo.String(), goSumS, dirtyS) + log.Info("findNextRepo()", repo.String(), goSumS, dirtyS) if goSumS == "IGNORE" { continue } @@ -290,12 +331,9 @@ func findNextRepo() { if dirtyS == "PERFECT" { continue } - release.repo.SetValue(repo.status.String()) - release.status.SetValue("clean") - release.notes.SetValue("check manually") - release.current = repo - release.openrepo.Enable() - return + if setCurrentRepo(repo, "clean round 2", "check manually") { + return + } } if goSumS == "DIRTY" { if ok, missing := repo.status.CheckGoSum(); ok { @@ -307,22 +345,14 @@ func findNextRepo() { continue } - // release.repo.SetValue(repo.status.String()) - // release.status.SetValue("bad") - release.repo.SetValue(repo.status.String()) - release.status.SetValue("dirty") - release.notes.SetValue("commit changes") - release.current = repo - release.openrepo.Enable() - return + if setCurrentRepo(repo, "dirty", "commit changes") { + return + } } if goSumS == "BAD" { - release.repo.SetValue(repo.status.String()) - release.status.SetValue("bad") - release.notes.SetValue("redo go.sum") - release.current = repo - release.openrepo.Enable() - return + if setCurrentRepo(repo, "bad", "redo go.sum") { + return + } } } log.Info("tried to findNextRepo() but not sure what to do next")