2024-01-23 22:48:07 -06:00
|
|
|
// This is a simple example
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2024-02-14 16:20:26 -06:00
|
|
|
"fmt"
|
2024-01-25 01:29:00 -06:00
|
|
|
"os"
|
2024-01-30 16:48:40 -06:00
|
|
|
"path/filepath"
|
2024-02-20 14:44:38 -06:00
|
|
|
"strings"
|
2024-01-25 01:29:00 -06:00
|
|
|
|
2024-01-23 22:48:07 -06:00
|
|
|
"go.wit.com/gui"
|
|
|
|
"go.wit.com/log"
|
|
|
|
|
|
|
|
"go.wit.com/lib/gadgets"
|
2024-02-18 15:09:04 -06:00
|
|
|
"go.wit.com/lib/gui/repolist"
|
2024-02-29 21:57:13 -06:00
|
|
|
"go.wit.com/lib/gui/shell"
|
2024-01-23 22:48:07 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
type releaseStruct struct {
|
2024-03-02 20:47:10 -06:00
|
|
|
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-02-01 13:30:26 -06:00
|
|
|
releaseVersionB *gui.Node
|
2024-03-02 20:47:10 -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-26 09:34:42 -06:00
|
|
|
checkSafeB *gui.Node
|
2024-02-23 09:01:58 -06:00
|
|
|
whitelist map[string]*repolist.RepoRow
|
2024-02-01 15:16:15 -06:00
|
|
|
|
|
|
|
// store myself here. use myself to
|
|
|
|
// do garbage go get tests and other potential junk
|
2024-02-23 09:01:58 -06:00
|
|
|
guireleaser *repolist.RepoRow
|
2024-01-23 22:48:07 -06:00
|
|
|
}
|
|
|
|
|
2024-01-30 14:20:54 -06:00
|
|
|
func (w *autoType) Disable() {
|
2024-02-20 14:44:38 -06:00
|
|
|
me.mainBox.Disable()
|
2024-01-30 14:20:54 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func (w *autoType) Enable() {
|
2024-02-20 14:44:38 -06:00
|
|
|
me.mainBox.Enable()
|
2024-01-30 14:20:54 -06:00
|
|
|
}
|
2024-01-23 22:48:07 -06:00
|
|
|
|
2024-01-30 14:20:54 -06:00
|
|
|
func createReleaseBox(box *gui.Node) {
|
2024-01-31 01:14:11 -06:00
|
|
|
initWhitelist()
|
2024-01-30 16:48:40 -06:00
|
|
|
|
2024-02-20 16:11:00 -06:00
|
|
|
me.release.box = box.NewVerticalBox("vbox")
|
|
|
|
me.release.group = me.release.box.NewGroup("Current Repo")
|
|
|
|
me.release.grid = me.release.group.NewGrid("buildOptions", 0, 0)
|
|
|
|
me.release.grid.NextRow()
|
2024-02-09 11:50:16 -06:00
|
|
|
|
2024-02-20 16:11:00 -06:00
|
|
|
me.release.releaseVersionB = me.release.grid.NewButton("release version", func() {
|
2024-01-29 09:38:32 -06:00
|
|
|
buttonDisable()
|
2024-11-07 05:15:54 -06:00
|
|
|
if doRelease() {
|
2024-01-31 16:39:42 -06:00
|
|
|
buttonEnable()
|
2024-02-09 11:50:16 -06:00
|
|
|
log.Info("doRelease() worked")
|
2024-01-31 16:39:42 -06:00
|
|
|
} else {
|
2024-02-09 11:50:16 -06:00
|
|
|
log.Info("doRelease() failed")
|
2024-01-31 16:39:42 -06:00
|
|
|
}
|
2024-01-23 22:48:07 -06:00
|
|
|
})
|
2024-02-20 20:42:54 -06:00
|
|
|
me.release.grid.NewButton("Find Next Releasable", func() {
|
|
|
|
me.Disable()
|
|
|
|
defer me.Enable()
|
|
|
|
if findNext() {
|
|
|
|
log.Info("findNext() found a repo")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
})
|
2024-02-20 16:11:00 -06:00
|
|
|
me.release.grid.NextRow()
|
2024-01-23 22:48:07 -06:00
|
|
|
|
2024-02-20 16:11:00 -06:00
|
|
|
me.release.repo = gadgets.NewOneLiner(me.release.grid, "repo")
|
|
|
|
me.release.openrepo = me.release.grid.NewButton("Configure", func() {
|
|
|
|
me.current.Status.Toggle()
|
2024-01-23 22:48:07 -06:00
|
|
|
})
|
2024-02-20 16:11:00 -06:00
|
|
|
me.release.openrepo.Disable()
|
|
|
|
me.release.grid.NextRow()
|
|
|
|
me.release.status = gadgets.NewOneLiner(me.release.grid, "status")
|
|
|
|
me.release.grid.NextRow()
|
|
|
|
me.release.readOnly = gadgets.NewOneLiner(me.release.grid, "read-only")
|
|
|
|
me.release.grid.NextRow()
|
|
|
|
me.release.notes = gadgets.NewOneLiner(me.release.grid, "notes")
|
|
|
|
me.release.grid.NextRow()
|
|
|
|
|
|
|
|
me.release.version = gadgets.NewOneLiner(me.release.grid, "version")
|
|
|
|
me.release.grid.NextRow()
|
|
|
|
|
|
|
|
me.release.reason = gadgets.NewBasicEntry(me.release.grid, "release reason")
|
|
|
|
me.release.reason.SetText(me.releaseReasonS)
|
|
|
|
me.release.grid.NextRow()
|
|
|
|
|
|
|
|
me.autoWorkingPwd = gadgets.NewOneLiner(me.release.grid, "working directory (pwd)")
|
|
|
|
me.release.grid.NextRow()
|
|
|
|
me.userHomePwd = gadgets.NewOneLiner(me.release.grid, "user home")
|
|
|
|
me.release.grid.NextRow()
|
|
|
|
me.goSrcPwd = gadgets.NewOneLiner(me.release.grid, "go src home")
|
|
|
|
me.release.grid.NextRow()
|
2024-01-30 16:48:40 -06:00
|
|
|
|
|
|
|
homeDir, err := os.UserHomeDir()
|
|
|
|
if err != nil {
|
|
|
|
log.Warn("Error getting home directory:", err)
|
|
|
|
homeDir = "/home/autotypist"
|
|
|
|
}
|
|
|
|
me.userHomePwd.SetText(homeDir)
|
|
|
|
srcDir := filepath.Join(homeDir, "go/src")
|
|
|
|
me.goSrcPwd.SetText(srcDir)
|
|
|
|
|
2024-02-02 16:37:41 -06:00
|
|
|
testf := filepath.Join(srcDir, "go.wit.com/apps/guireleaser", "go.sum")
|
2024-02-29 21:57:13 -06:00
|
|
|
if !shell.Exists(testf) {
|
2024-02-02 16:37:41 -06:00
|
|
|
log.Info("go.sum missing", testf)
|
|
|
|
panic("redo go.sum")
|
|
|
|
}
|
|
|
|
|
2024-02-20 16:11:00 -06:00
|
|
|
group := me.release.box.NewGroup("Run on Current Repo")
|
2024-02-20 14:44:38 -06:00
|
|
|
grid := group.NewGrid("buildOptions", 0, 0)
|
2024-01-30 16:48:40 -06:00
|
|
|
|
2024-02-20 14:44:38 -06:00
|
|
|
grid.NewButton("set to IGNORE", func() {
|
2024-02-29 21:57:13 -06:00
|
|
|
// tmp := me.current.GoState()
|
|
|
|
log.Info("trying to whitelist repo", me.current.GoPath())
|
|
|
|
// me.current.SetGoState("IGNORE")
|
2024-02-20 16:11:00 -06:00
|
|
|
me.release.whitelist[me.current.GoPath()] = me.current
|
2024-01-24 02:41:34 -06:00
|
|
|
})
|
2024-01-30 16:48:40 -06:00
|
|
|
|
2024-02-20 16:11:00 -06:00
|
|
|
me.release.checkGoSumB = grid.NewButton("checkValidGoSum()", func() {
|
2024-01-26 09:34:42 -06:00
|
|
|
buttonDisable()
|
2024-02-20 16:11:00 -06:00
|
|
|
checkValidGoSum(me.current)
|
2024-01-24 16:25:41 -06:00
|
|
|
buttonEnable()
|
|
|
|
})
|
2024-02-20 16:11:00 -06:00
|
|
|
|
2024-02-20 14:44:38 -06:00
|
|
|
grid.NextRow()
|
2024-02-09 11:50:16 -06:00
|
|
|
|
2024-02-20 16:11:00 -06:00
|
|
|
group = me.release.box.NewGroup("Process against all repos")
|
2024-02-20 14:44:38 -06:00
|
|
|
grid = group.NewGrid("buildOptions", 0, 0)
|
2024-02-20 16:11:00 -06:00
|
|
|
grid.NewButton("doRelease() all", func() {
|
2024-02-14 16:20:26 -06:00
|
|
|
var worked bool = true
|
2024-02-09 11:50:16 -06:00
|
|
|
buttonDisable()
|
2024-02-14 15:39:13 -06:00
|
|
|
// rather than loop forever, at least limit this to the number of repos
|
|
|
|
// incase something, somewhere, goes wrong
|
2024-02-18 15:09:04 -06:00
|
|
|
duration := repolist.TimeFunction(func() {
|
|
|
|
for n := 0; n <= len(me.repos.View.AllRepos()); n++ {
|
2024-11-07 05:15:54 -06:00
|
|
|
if doRelease() {
|
2024-02-14 16:20:26 -06:00
|
|
|
log.Info("doRelease() worked")
|
|
|
|
} else {
|
2024-02-20 16:11:00 -06:00
|
|
|
if me.release.status.String() == "ALL DONE?" {
|
2024-02-14 16:20:26 -06:00
|
|
|
log.Info("maybe ALL DONE?")
|
|
|
|
buttonEnable()
|
|
|
|
worked = true
|
|
|
|
break
|
|
|
|
}
|
|
|
|
log.Info("doRelease() failed")
|
|
|
|
worked = false
|
|
|
|
break
|
2024-02-09 11:50:16 -06:00
|
|
|
}
|
|
|
|
}
|
2024-02-14 16:20:26 -06:00
|
|
|
})
|
|
|
|
s := fmt.Sprint(duration)
|
|
|
|
log.Info("release returned", worked, "and ran for", s)
|
2024-02-09 11:50:16 -06:00
|
|
|
buttonEnable()
|
|
|
|
})
|
2024-02-20 14:44:38 -06:00
|
|
|
grid.NextRow()
|
|
|
|
|
2024-02-20 20:42:54 -06:00
|
|
|
group = me.release.box.NewGroup("experimental and potentially dangerous stuff")
|
2024-02-20 14:44:38 -06:00
|
|
|
grid = group.NewGrid("buildOptions", 0, 0)
|
|
|
|
|
|
|
|
grid.NewButton("git ls-files |grep go.mod", func() {
|
|
|
|
for _, repo := range me.repos.View.AllRepos() {
|
|
|
|
log.Info("repo:", repo.Name())
|
|
|
|
if repo.Status.ReadOnly() {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if whitelist(repo.GoPath()) {
|
|
|
|
log.Warn("skipping whitelist", repo.GoPath())
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
good, files := repo.Status.GitLsFiles()
|
|
|
|
if !good {
|
|
|
|
log.Warn("Something went wrong", repo.GoPath())
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
for _, filename := range strings.Split(files, "\n") {
|
|
|
|
log.Info("\tfile", filename)
|
|
|
|
if filename == "go.mod" {
|
|
|
|
log.Info("Found go.mod. does version match release version?")
|
|
|
|
log.Info(repo.Status.GetLastTagVersion(), "vs", repo.Status.GetTargetVersion())
|
|
|
|
if repo.Status.GetLastTagVersion() != repo.Status.GetTargetVersion() {
|
|
|
|
log.Info(repo.Status.GetLastTagVersion(), "vs", repo.Status.GetTargetVersion())
|
|
|
|
log.Info("Found go.sum. version mismatch")
|
|
|
|
setCurrentRepo(repo, "VERY BROKEN", "rewind go.mod commit")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if filename == "go.sum" {
|
|
|
|
log.Info("Found go.sum. does version match release version?")
|
|
|
|
log.Info(repo.Status.GetLastTagVersion(), "vs", repo.Status.GetTargetVersion())
|
|
|
|
if repo.Status.GetLastTagVersion() != repo.Status.GetTargetVersion() {
|
|
|
|
log.Info(repo.Status.GetLastTagVersion(), "vs", repo.Status.GetTargetVersion())
|
|
|
|
log.Info("Found go.sum. version mismatch")
|
|
|
|
setCurrentRepo(repo, "VERY BROKEN", "rewind go.mod commit")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
log.Info("All repos seem okay")
|
|
|
|
})
|
|
|
|
grid.NextRow()
|
|
|
|
|
2024-01-24 16:25:41 -06:00
|
|
|
}
|
2024-02-02 02:42:17 -06:00
|
|
|
|
2024-01-24 16:25:41 -06:00
|
|
|
func buttonDisable() {
|
2024-01-30 14:20:54 -06:00
|
|
|
me.Disable()
|
2024-01-24 16:25:41 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func buttonEnable() {
|
2024-01-30 14:20:54 -06:00
|
|
|
me.Enable()
|
2024-01-24 16:25:41 -06:00
|
|
|
}
|
|
|
|
|
2024-02-23 09:01:58 -06:00
|
|
|
func setCurrentRepo(newcur *repolist.RepoRow, s string, note string) bool {
|
2024-02-18 15:09:04 -06:00
|
|
|
if newcur.ReadOnly() {
|
2024-01-25 01:29:00 -06:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2024-02-20 16:11:00 -06:00
|
|
|
me.release.repo.SetText(newcur.GoPath())
|
|
|
|
me.release.status.SetText(s)
|
|
|
|
me.release.notes.SetText(note)
|
|
|
|
me.current = newcur
|
|
|
|
me.release.version.SetText(me.current.Status.GetTargetVersion())
|
|
|
|
me.release.releaseVersionB.SetText("release version " + me.current.Status.GetTargetVersion())
|
|
|
|
me.release.openrepo.Enable()
|
2024-01-25 01:29:00 -06:00
|
|
|
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2024-02-18 15:09:04 -06:00
|
|
|
// trys to figure out if there is still something to update
|
|
|
|
// todo: redo this logic as it is terrible
|
2024-02-20 06:53:07 -06:00
|
|
|
// rename this findNext()
|
2024-02-20 20:42:54 -06:00
|
|
|
func findNext() bool {
|
2024-02-18 15:09:04 -06:00
|
|
|
for _, repo := range me.repos.View.AllRepos() {
|
2024-02-20 14:44:38 -06:00
|
|
|
if repo.Status.IsReleased() {
|
2024-02-02 02:42:17 -06:00
|
|
|
continue
|
|
|
|
}
|
2024-02-29 21:57:13 -06:00
|
|
|
if whitelist(repo.GoPath()) {
|
2024-01-24 16:25:41 -06:00
|
|
|
continue
|
|
|
|
}
|
2024-11-05 04:46:59 -06:00
|
|
|
if repo.Status.Whitelist {
|
|
|
|
continue
|
|
|
|
}
|
2024-02-20 06:53:07 -06:00
|
|
|
if repo.ReadOnly() {
|
2024-02-20 20:42:54 -06:00
|
|
|
// log.Info("findNext() skipping readonly")
|
2024-02-02 01:42:13 -06:00
|
|
|
continue
|
|
|
|
}
|
2024-02-20 06:53:07 -06:00
|
|
|
if repo.CheckDirty() {
|
2024-02-20 20:42:54 -06:00
|
|
|
log.Info("findNext() skipping dirty")
|
2024-02-20 06:53:07 -06:00
|
|
|
continue
|
|
|
|
}
|
2024-02-20 16:11:00 -06:00
|
|
|
// do makeredomod here
|
|
|
|
// if ! repo.Status.Exists("go.sum") {
|
|
|
|
// }
|
2024-02-20 06:53:07 -06:00
|
|
|
if repo.Status.IsPrimitive() {
|
2024-02-29 21:57:13 -06:00
|
|
|
log.Info("findNext()", repo.GoPath())
|
2024-02-20 06:53:07 -06:00
|
|
|
if setCurrentRepo(repo, "PRIMATIVE", "release new version") {
|
|
|
|
return true
|
|
|
|
}
|
2024-02-02 01:42:13 -06:00
|
|
|
continue
|
|
|
|
}
|
2024-02-20 20:42:54 -06:00
|
|
|
log.Info("findNext()", repo.GoPath(), "is not a primative repo")
|
2024-02-20 16:11:00 -06:00
|
|
|
if checkValidGoSum(repo) {
|
2024-02-20 06:53:07 -06:00
|
|
|
setCurrentRepo(repo, "should be good to release", "pretty sure")
|
2024-02-02 01:42:13 -06:00
|
|
|
return true
|
2024-01-24 16:25:41 -06:00
|
|
|
}
|
|
|
|
}
|
2024-02-20 20:42:54 -06:00
|
|
|
log.Info("tried to findNext() but not sure what to do next")
|
2024-02-20 16:11:00 -06:00
|
|
|
me.release.status.SetText("ALL DONE?")
|
2024-01-24 16:25:41 -06:00
|
|
|
return false
|
2024-01-23 22:48:07 -06:00
|
|
|
}
|