2024-01-23 22:48:07 -06:00
|
|
|
// This is a simple example
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2024-01-25 01:29:00 -06:00
|
|
|
"os"
|
|
|
|
|
2024-01-23 22:48:07 -06:00
|
|
|
"go.wit.com/gui"
|
|
|
|
"go.wit.com/log"
|
|
|
|
|
|
|
|
"go.wit.com/lib/gadgets"
|
2024-01-25 01:29:00 -06:00
|
|
|
"go.wit.com/lib/gui/repostatus"
|
2024-01-23 22:48:07 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
var release releaseStruct
|
|
|
|
|
|
|
|
type releaseStruct struct {
|
|
|
|
current *repo
|
|
|
|
|
2024-01-25 01:29:00 -06:00
|
|
|
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
|
2024-01-25 22:47:05 -06:00
|
|
|
reason *gadgets.BasicEntry
|
2024-01-23 22:48:07 -06:00
|
|
|
|
|
|
|
openrepo *gui.Node
|
2024-01-24 16:25:41 -06:00
|
|
|
|
2024-01-24 22:22:34 -06:00
|
|
|
goGetB *gui.Node
|
|
|
|
checkGoSumB *gui.Node
|
|
|
|
checkDirtyB *gui.Node
|
2024-01-24 16:25:41 -06:00
|
|
|
makeRedomodB *gui.Node
|
|
|
|
sendVersionB *gui.Node
|
2024-01-23 22:48:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func createReleaseWindow() {
|
|
|
|
if release.win != nil {
|
|
|
|
release.win.Toggle()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
release.win = gadgets.NewBasicWindow(me.myGui, "Make a new release")
|
|
|
|
release.win.Custom = func() {
|
|
|
|
log.Info("Release Window close")
|
|
|
|
}
|
|
|
|
|
|
|
|
release.win.Make()
|
|
|
|
release.win.StandardClose()
|
|
|
|
release.win.Draw()
|
|
|
|
release.box = release.win.Box()
|
|
|
|
release.group = release.box.NewGroup("things")
|
|
|
|
release.grid = release.group.NewGrid("buildOptions", 2, 1)
|
|
|
|
|
2024-01-24 02:41:34 -06:00
|
|
|
// do an initial scan of all the repos
|
|
|
|
scanGoSum()
|
|
|
|
|
2024-01-23 22:48:07 -06:00
|
|
|
release.grid.NewButton("next repo", func() {
|
|
|
|
log.Info("find the next repo to release here")
|
2024-01-24 16:25:41 -06:00
|
|
|
if findNextDirty() {
|
|
|
|
log.Info("found a dirty repo")
|
|
|
|
} else {
|
|
|
|
findNextRepo()
|
|
|
|
}
|
2024-01-24 22:22:34 -06:00
|
|
|
findDirty2()
|
2024-01-23 22:48:07 -06:00
|
|
|
})
|
|
|
|
|
|
|
|
release.openrepo = release.grid.NewButton("open repo", func() {
|
|
|
|
if release.current == nil {
|
|
|
|
log.Info("find the next repo first")
|
|
|
|
return
|
|
|
|
}
|
2024-01-24 22:22:34 -06:00
|
|
|
if ok, missing := release.current.status.CheckGoSum(); ok {
|
2024-01-23 22:48:07 -06:00
|
|
|
log.Info("repo has go.sum requirements that are clean")
|
|
|
|
release.status.SetValue("CLEAN")
|
2024-01-24 02:41:34 -06:00
|
|
|
release.current.goSumStatus.SetValue("CLEAN")
|
2024-01-23 22:48:07 -06:00
|
|
|
} else {
|
2024-01-24 22:22:34 -06:00
|
|
|
log.Info("BAD repo has go.sum requirements that are screwed up. missing:", missing)
|
2024-01-23 22:48:07 -06:00
|
|
|
release.status.SetValue("BAD")
|
2024-01-24 02:41:34 -06:00
|
|
|
release.current.goSumStatus.SetValue("BAD")
|
|
|
|
}
|
2024-01-25 01:29:00 -06:00
|
|
|
if release.current.status.ReadOnly() {
|
|
|
|
release.readOnly.SetValue("true")
|
|
|
|
} else {
|
|
|
|
release.readOnly.SetValue("false")
|
|
|
|
}
|
2024-01-24 02:41:34 -06:00
|
|
|
release.current.newScan()
|
|
|
|
|
|
|
|
if release.current.dirtyLabel.String() == "PERFECT" {
|
|
|
|
return
|
2024-01-23 22:48:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// log.Info("find the next repo to release here")
|
2024-01-24 02:41:34 -06:00
|
|
|
release.current.status.Toggle()
|
2024-01-25 22:47:05 -06:00
|
|
|
release.current.status.SetVersion("0", "13", "11", release.reason.String())
|
2024-01-25 23:10:12 -06:00
|
|
|
release.current.status.Update()
|
2024-01-23 22:48:07 -06:00
|
|
|
})
|
|
|
|
release.openrepo.Disable()
|
|
|
|
|
|
|
|
release.repo = gadgets.NewOneLiner(release.grid, "repo")
|
|
|
|
release.status = gadgets.NewOneLiner(release.grid, "status")
|
2024-01-25 01:29:00 -06:00
|
|
|
release.readOnly = gadgets.NewOneLiner(release.grid, "read-only")
|
2024-01-23 22:48:07 -06:00
|
|
|
release.notes = gadgets.NewOneLiner(release.grid, "notes")
|
2024-01-24 02:41:34 -06:00
|
|
|
|
|
|
|
release.version = gadgets.NewOneLiner(release.grid, "version")
|
2024-01-25 22:47:05 -06:00
|
|
|
release.version.SetText("0.13.11")
|
2024-01-24 02:41:34 -06:00
|
|
|
|
2024-01-25 22:47:05 -06:00
|
|
|
release.reason = gadgets.NewBasicEntry(release.grid, "release reason")
|
|
|
|
release.reason.SetText("hide works")
|
2024-01-24 02:41:34 -06:00
|
|
|
|
2024-01-24 16:25:41 -06:00
|
|
|
release.sendVersionB = release.grid.NewButton("send version", func() {
|
2024-01-24 02:41:34 -06:00
|
|
|
log.Info("set version()")
|
2024-01-25 22:47:05 -06:00
|
|
|
release.current.status.SetVersion("0", "13", "12", release.reason.String())
|
2024-01-24 02:41:34 -06:00
|
|
|
})
|
|
|
|
release.grid.NewButton("set ignore", func() {
|
|
|
|
tmp := release.current.goSumStatus.String()
|
|
|
|
log.Info("trying to set repo IGNORE is now =", tmp)
|
|
|
|
release.current.goSumStatus.SetValue("IGNORE")
|
|
|
|
release.current.goSumStatus.SetLabel("IGNORE")
|
|
|
|
release.current.goSumStatus.SetText("IGNORE")
|
|
|
|
})
|
2024-01-24 16:25:41 -06:00
|
|
|
release.checkDirtyB = release.grid.NewButton("CheckDirty()", func() {
|
|
|
|
buttonDisable()
|
|
|
|
if release.current.status.CheckDirty() {
|
|
|
|
log.Info("repo is dirty")
|
|
|
|
} else {
|
|
|
|
log.Info("repo is not dirty")
|
|
|
|
}
|
|
|
|
buttonEnable()
|
|
|
|
})
|
|
|
|
release.checkGoSumB = release.grid.NewButton("CheckGoSum()", func() {
|
|
|
|
buttonDisable()
|
|
|
|
tmp := release.current.String()
|
|
|
|
log.Info("Run CheckGoSum on repo:", tmp)
|
2024-01-24 22:22:34 -06:00
|
|
|
if ok, missing := release.current.status.CheckGoSum(); ok {
|
2024-01-24 16:25:41 -06:00
|
|
|
log.Info("repo has go.sum requirements that are clean")
|
|
|
|
release.current.goSumStatus.SetValue("CLEAN")
|
|
|
|
release.current.goSumStatus.SetLabel("CLEAN")
|
|
|
|
release.current.goSumStatus.SetText("CLEAN")
|
|
|
|
} else {
|
2024-01-24 22:22:34 -06:00
|
|
|
if missing == "" {
|
|
|
|
log.Info("BAD VERSION repo has go.sum requirements that are screwed up.", tmp)
|
|
|
|
if release.current.goSumStatus.String() == "BAD" {
|
|
|
|
release.current.goSumStatus.SetLabel("BAD VERSION")
|
|
|
|
release.current.goSumStatus.SetText("BAD VERSION")
|
|
|
|
}
|
|
|
|
} 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)
|
2024-01-25 01:29:00 -06:00
|
|
|
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")
|
|
|
|
}
|
|
|
|
}
|
2024-01-24 22:22:34 -06:00
|
|
|
// addRepo(reposgrid, missing, "master", "master", "master")
|
2024-01-24 16:25:41 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
buttonEnable()
|
|
|
|
})
|
|
|
|
release.grid.NewButton("CheckPrimativeGoMod()", func() {
|
|
|
|
tmp := release.current.String()
|
|
|
|
log.Info("Run CheckGoSum on repo:", tmp)
|
|
|
|
if release.current.status.CheckPrimativeGoMod() {
|
|
|
|
log.Info("repo has PRIMATIVE go.mod")
|
|
|
|
} else {
|
|
|
|
log.Info("repo go.mod requies checking for a go.sum")
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
release.grid.NewButton("reset with scanGoSum()", func() {
|
|
|
|
buttonDisable()
|
|
|
|
// do an initial scan of all the repos
|
|
|
|
scanGoSum()
|
|
|
|
buttonEnable()
|
|
|
|
})
|
|
|
|
release.makeRedomodB = release.grid.NewButton("make redomod", func() {
|
|
|
|
buttonDisable()
|
|
|
|
release.current.status.MakeRedomod()
|
|
|
|
buttonEnable()
|
|
|
|
})
|
|
|
|
release.goGetB = release.grid.NewButton("go get -v -u .", func() {
|
|
|
|
buttonDisable()
|
|
|
|
err, output := release.current.status.RunCmd([]string{"go", "get", "-v", "-u", "."})
|
|
|
|
log.Warn(output)
|
|
|
|
if err == nil {
|
|
|
|
log.Warn("go get worked. recheck go.sum")
|
|
|
|
} else {
|
|
|
|
log.Warn("go get failed")
|
|
|
|
}
|
|
|
|
buttonEnable()
|
|
|
|
})
|
2024-01-25 01:29:00 -06:00
|
|
|
release.goGetB = release.grid.NewButton("SetMainWorkingName(guimaster)", func() {
|
|
|
|
buttonDisable()
|
|
|
|
release.current.status.SetMainWorkingName("guimaster")
|
|
|
|
buttonEnable()
|
|
|
|
})
|
2024-01-24 16:25:41 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func buttonDisable() {
|
|
|
|
release.goGetB.Disable()
|
|
|
|
release.makeRedomodB.Disable()
|
|
|
|
release.checkGoSumB.Disable()
|
|
|
|
release.openrepo.Disable()
|
|
|
|
release.checkDirtyB.Disable()
|
|
|
|
release.sendVersionB.Disable()
|
|
|
|
}
|
|
|
|
|
|
|
|
func buttonEnable() {
|
|
|
|
release.goGetB.Enable()
|
|
|
|
release.makeRedomodB.Enable()
|
|
|
|
release.checkGoSumB.Enable()
|
|
|
|
release.openrepo.Enable()
|
|
|
|
release.checkDirtyB.Enable()
|
|
|
|
release.sendVersionB.Enable()
|
|
|
|
}
|
|
|
|
|
2024-01-24 22:22:34 -06:00
|
|
|
func findDirty2() bool {
|
2024-01-25 01:29:00 -06:00
|
|
|
log.Info("findDirty2() START")
|
2024-01-24 22:22:34 -06:00
|
|
|
for _, repo := range me.allrepos {
|
|
|
|
goSumS := repo.goSumStatus.String()
|
|
|
|
dirtyS := repo.dirtyLabel.String()
|
|
|
|
|
|
|
|
if goSumS == "IGNORE" {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
if goSumS == "DIRTY 2" {
|
|
|
|
log.Info("repo DIRTY 2", repo.String(), goSumS, dirtyS)
|
2024-01-25 01:29:00 -06:00
|
|
|
if setCurrentRepo(repo, "dirty 2", "check manually I guess") {
|
|
|
|
return true
|
|
|
|
}
|
2024-01-24 22:22:34 -06:00
|
|
|
return true
|
|
|
|
} else {
|
|
|
|
log.Info("repo not DIRTY 2", repo.String(), goSumS, dirtyS)
|
|
|
|
}
|
|
|
|
}
|
2024-01-25 01:29:00 -06:00
|
|
|
log.Info("findDirty2() END")
|
2024-01-24 22:22:34 -06:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2024-01-25 01:29:00 -06:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2024-01-24 16:25:41 -06:00
|
|
|
func findNextDirty() bool {
|
2024-01-24 22:22:34 -06:00
|
|
|
for _, repo := range me.allrepos {
|
2024-01-24 16:25:41 -06:00
|
|
|
goSumS := repo.goSumStatus.String()
|
|
|
|
dirtyS := repo.dirtyLabel.String()
|
|
|
|
|
2024-01-25 01:29:00 -06:00
|
|
|
log.Info("findNextDirty()", repo.String(), goSumS, dirtyS)
|
2024-01-24 16:25:41 -06:00
|
|
|
if goSumS == "PRIMATIVE" {
|
2024-01-25 22:47:05 -06:00
|
|
|
if dirtyS != "PERFECT" {
|
|
|
|
if setCurrentRepo(repo, "primative not committed", "release new version") {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
continue
|
|
|
|
}
|
2024-01-24 16:25:41 -06:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
if goSumS == "IGNORE" {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if goSumS == "DIRTY 2" {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
// latestversion := repo.status.GetLastTagVersion()
|
|
|
|
if goSumS == "CLEAN" {
|
|
|
|
if dirtyS == "PERFECT" {
|
|
|
|
continue
|
|
|
|
}
|
2024-01-25 01:29:00 -06:00
|
|
|
if setCurrentRepo(repo, "clean", "check manually") {
|
|
|
|
return true
|
|
|
|
}
|
2024-01-24 16:25:41 -06:00
|
|
|
}
|
|
|
|
if goSumS == "DIRTY" {
|
2024-01-24 22:22:34 -06:00
|
|
|
if ok, missing := repo.status.CheckGoSum(); ok {
|
2024-01-24 16:25:41 -06:00
|
|
|
log.Info("repo has go.sum requirements that are clean")
|
|
|
|
// repo.goSumStatus.SetLabel("CLEAN")
|
|
|
|
} else {
|
2024-01-24 22:22:34 -06:00
|
|
|
log.Info("DIRTY 2 repo has go.sum requirements that are screwed up. missing:", missing)
|
2024-01-24 16:25:41 -06:00
|
|
|
repo.goSumStatus.SetLabel("DIRTY 2")
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2024-01-25 01:29:00 -06:00
|
|
|
if setCurrentRepo(repo, "dirty", "commit changes") {
|
|
|
|
return true
|
|
|
|
}
|
2024-01-24 16:25:41 -06:00
|
|
|
}
|
|
|
|
}
|
2024-01-24 22:22:34 -06:00
|
|
|
log.Info("tried to findNextDirty() but not sure what to do next")
|
2024-01-24 16:25:41 -06:00
|
|
|
return false
|
2024-01-23 22:48:07 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func findNextRepo() {
|
2024-01-24 22:22:34 -06:00
|
|
|
for _, repo := range me.allrepos {
|
2024-01-24 02:41:34 -06:00
|
|
|
goSumS := repo.goSumStatus.String()
|
|
|
|
dirtyS := repo.dirtyLabel.String()
|
|
|
|
|
2024-01-25 01:29:00 -06:00
|
|
|
log.Info("findNextRepo()", repo.String(), goSumS, dirtyS)
|
2024-01-24 02:41:34 -06:00
|
|
|
if goSumS == "IGNORE" {
|
2024-01-23 22:48:07 -06:00
|
|
|
continue
|
|
|
|
}
|
2024-01-24 16:25:41 -06:00
|
|
|
if goSumS == "DIRTY 2" {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if goSumS == "BAD VERSION" {
|
|
|
|
continue
|
|
|
|
}
|
2024-01-24 02:41:34 -06:00
|
|
|
// latestversion := repo.status.GetLastTagVersion()
|
|
|
|
if goSumS == "CLEAN" {
|
|
|
|
if dirtyS == "PERFECT" {
|
|
|
|
continue
|
|
|
|
}
|
2024-01-25 01:29:00 -06:00
|
|
|
if setCurrentRepo(repo, "clean round 2", "check manually") {
|
|
|
|
return
|
|
|
|
}
|
2024-01-24 02:41:34 -06:00
|
|
|
}
|
|
|
|
if goSumS == "DIRTY" {
|
2024-01-24 22:22:34 -06:00
|
|
|
if ok, missing := repo.status.CheckGoSum(); ok {
|
2024-01-24 16:25:41 -06:00
|
|
|
log.Info("repo has go.sum requirements that are clean")
|
|
|
|
// repo.goSumStatus.SetLabel("CLEAN")
|
|
|
|
} else {
|
2024-01-24 22:22:34 -06:00
|
|
|
log.Info("DIRTY 3 repo has go.sum requirements that are screwed up. missing:", missing)
|
|
|
|
repo.goSumStatus.SetLabel("DIRTY 3")
|
2024-01-24 16:25:41 -06:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2024-01-25 01:29:00 -06:00
|
|
|
if setCurrentRepo(repo, "dirty", "commit changes") {
|
|
|
|
return
|
|
|
|
}
|
2024-01-23 22:48:07 -06:00
|
|
|
}
|
2024-01-24 16:25:41 -06:00
|
|
|
if goSumS == "BAD" {
|
2024-01-25 01:29:00 -06:00
|
|
|
if setCurrentRepo(repo, "bad", "redo go.sum") {
|
|
|
|
return
|
|
|
|
}
|
2024-01-24 16:25:41 -06:00
|
|
|
}
|
2024-01-23 22:48:07 -06:00
|
|
|
}
|
2024-01-24 22:22:34 -06:00
|
|
|
log.Info("tried to findNextRepo() but not sure what to do next")
|
2024-01-23 22:48:07 -06:00
|
|
|
}
|