reorg interface. it's almost working again

This commit is contained in:
Jeff Carr 2024-02-20 14:44:38 -06:00
parent d84420e443
commit e927975dc8
6 changed files with 197 additions and 242 deletions

View File

@ -86,7 +86,7 @@ func doRelease() bool {
log.Info("EVERYTHING OK. RERELEASED", release.current.Name())
// update the values in the GUI
release.current.Status.UpdateNew()
release.current.NewScan()
// attempt to find another repo to release
if !doReleaseFindNext() {

View File

@ -1,8 +1,6 @@
package main
import (
"strings"
"go.wit.com/gui"
"go.wit.com/lib/debugger"
"go.wit.com/lib/gui/logsettings"
@ -11,12 +9,16 @@ import (
)
func showHideRepos(repo *repolist.Repo) {
if repo.GoPath() == "go.wit.com/dev/alexflint/arg" {
log.Info("found autoHideReleased() =", me.autoHideReleased.Checked())
log.Info("found alexflint/arg IsReleased() =", repo.Status.IsReleased())
}
// always show dirty repos
if repo.IsDirty() {
repo.Show()
return
}
// always show repos that have not been merged to main
// always show repos that have not been merged ?
if repo.GoState() == "merge to devel" {
repo.Show()
return
@ -30,30 +32,8 @@ func showHideRepos(repo *repolist.Repo) {
return
}
}
if me.autoHidePerfect.Checked() {
if repo.State() == "PERFECT" {
repo.Hide()
return
}
}
if me.autoReleased.Checked() {
if repo.GoState() == "RELEASED" {
repo.Hide()
return
}
}
repo.Show()
}
func globalDisplayShow(repo *repolist.Repo) {
if me.autoHideReadOnly.Checked() {
if repo.Status.ReadOnly() {
repo.Hide()
return
}
}
if me.autoHidePerfect.Checked() {
if repo.State() == "PERFECT" {
if me.autoHideReleased.Checked() {
if repo.Status.IsReleased() {
repo.Hide()
return
}
@ -79,191 +59,72 @@ func globalDisplayOptions(box *gui.Node) {
hidegrid.NextRow()
me.autoHideReadOnly = hidegrid.NewCheckbox("Hide read-only repos").SetChecked(true)
me.autoHideReadOnly.Custom = func() {
log.Info("registered hide function to globalDisplayShow()")
me.repos.View.RegisterHideFunction(globalDisplayShow)
}
// me.autoHideReadOnly.Custom = func() {
// log.Info("registered hide function to globalDisplayShow()")
// me.repos.View.RegisterHideFunction(globalDisplayShow)
// }
hidegrid.NextRow()
me.autoHidePerfect = hidegrid.NewCheckbox("Hide Perfectly clean repos").SetChecked(true)
me.autoHidePerfect.Custom = func() {
log.Info("registered hide function to showHideRepos()")
me.repos.View.RegisterHideFunction(showHideRepos)
}
hidegrid.NextRow()
me.autoReleased = hidegrid.NewCheckbox("Hide RELEASED repos").SetChecked(false)
me.autoReleased.Custom = func() {
if me.autoReleased.Checked() {
for _, repo := range me.repos.View.AllRepos() {
if repo.GoState() == "RELEASED" {
repo.Hide()
}
}
} else {
for _, repo := range me.repos.View.AllRepos() {
repo.Show()
}
}
}
me.autoHideReleased = hidegrid.NewCheckbox("Hide Released repos").SetChecked(true)
hidegrid.NextRow()
me.ignoreWhitelist = hidegrid.NewCheckbox("ignore whitelist (are you sure?)").SetChecked(false)
hidegrid.NextRow()
me.scanEveryMinute = hidegrid.NewCheckbox("Scan every minute").SetChecked(false)
me.scanEveryMinute.Custom = func() {
me.repos.View.SetAutoScan(me.scanEveryMinute.Checked())
}
hidegrid.NewButton("scan now", func() {
log.Info("re-scanning repos now")
i, s := me.repos.View.ScanRepositories()
log.Info("re-scanning repos done", i, s)
me.duration.SetText(s)
// me.duration.SetText(s)
})
me.duration = hidegrid.NewLabel("")
me.duration = me.repos.View.MirrorScanDuration()
hidegrid.Append(me.duration)
hidegrid.NextRow()
group1 = vbox.NewGroup("prep for release")
grid := group1.NewGrid("test", 0, 0)
grid.NewButton("git checkout master", func() {
setBranchToMaster()
})
grid.NewButton("find first repo", func() {
// set the target versions
setTargetVersion()
// have to run this twice for now. not sure why
scanForReady()
scanForReady()
findNextDirty("")
})
me.setBranchesToMasterB = grid.NewButton("set all branches to master", func() {
me.Disable()
for _, repo := range me.repos.View.AllRepos() {
if repo.Status.ReadOnly() {
continue
}
if whitelist(repo.GoPath()) {
continue
}
if repo.Status.CheckoutMaster() {
log.Warn("set master branch worked", repo.Name())
repo.Status.UpdateNew()
} else {
repo.Status.UpdateNew()
log.Warn("set master branch failed", repo.Name())
log.Warn("set master branch failed", repo.Name())
log.Warn("set master branch failed", repo.Name())
}
}
me.Enable()
me.setBranchesToMasterB.Disable()
})
var longB *gui.Node
longB = grid.NewButton("redo all go.sum", func() {
longB.Disable()
me.Disable()
for _, repo := range me.repos.View.AllRepos() {
if whitelist(repo.GoPath()) {
continue
}
ok, err := repo.Status.MakeRedomod()
if !ok {
log.Info("redo go.sum failed on", repo.GoPath(), err)
me.Enable()
longB.Enable()
longB.SetLabel("FAILED")
return
}
}
log.Info("redo go.sum finished ok!")
longB.Disable()
me.Enable()
longB.Enable()
})
grid.NewButton("set target version", func() {
setTargetVersion()
})
grid.NextRow()
grid.NewButton("rm -f go.mod go.sum", func() {
var longB *gui.Node
longB = grid.NewButton("redo all go.sum", func() {
me.Disable()
var worked bool = true
for _, repo := range me.repos.View.AllRepos() {
if whitelist(repo.GoPath()) {
continue
}
if repo.Status.ReadOnly() {
continue
ok, err := me.repos.View.CheckValidGoSum(repo)
if !ok {
log.Info("redo go.sum failed on", repo.GoPath(), err)
worked = false
}
repo.Status.RunCmd([]string{"rm", "-f", "go.mod", "go.sum"})
}
log.Info("redo go.sum finished with", worked)
me.Enable()
longB.SetLabel("go.sum files created")
if worked {
longB.Disable()
}
})
grid.NewButton("git reset --hard", func() {
me.setBranchesToMasterB = grid.NewButton("set all branches to master", func() {
me.Disable()
for _, repo := range me.repos.View.AllRepos() {
if whitelist(repo.GoPath()) {
log.Warn("skipping whitelist", repo.Name())
continue
}
log.Warn("running git reset --hard", repo.Name())
repo.Status.RunCmd([]string{"git", "reset", "--hard"})
defer me.Enable()
if setAllBranchesToMaster() {
// if it succeeds, disable this button
me.setBranchesToMasterB.Disable()
}
me.Enable()
})
grid.NewButton("git ls-files |grep go.mod", func() {
// var all []string
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()
grid.NewButton("scanForReady()", func() {
scanForReady()
})
group2 := vbox.NewGroup("Debugger")
dbggrid := group2.NewGrid("gdb", 0, 0)
dbggrid.NewButton("logging Window", func() {

23
main.go
View File

@ -45,9 +45,6 @@ func main() {
me.mainWindow = me.myGui.NewWindow("GUI release manager")
me.mainBox = me.mainWindow.NewBox("bw hbox", true)
// the left side of the window options
globalDisplayOptions(me.mainBox)
// sanity check of things that might be around that mess
// up things later
// if you have a go.work file, you must delete it
@ -73,13 +70,16 @@ func main() {
log.Info("Creating the Release Window")
// scan in the repo map first
// hopefully this is the list of all the golang packages and only the GUI golang packages
// initialize the repo list window
// which should be all the git repositories in ~/go/src & the .config file
me.repos = makeRepoView()
// register a Show/Hide function for the repo list table
me.repos.View.RegisterHideFunction(showHideRepos)
// the left side of the window options
globalDisplayOptions(me.mainBox)
// create the right side of the main window
createReleaseBox(me.mainBox)
@ -91,6 +91,8 @@ func main() {
// so I can't trust even what I see. It's complicated right now still.
release.openrepo.Disable()
log.Sleep(5)
// parse config file and scan for .git repos
me.repos.initRepoList()
@ -110,8 +112,15 @@ func main() {
// start the initail scan and make sure each repo is set
// to the master branch
func setBranchToMaster() {
func setAllBranchesToMaster() bool {
var worked bool = true
for _, repo := range me.repos.View.AllRepos() {
if repo.ReadOnly() {
continue
}
if repo.IsDirty() {
continue
}
if whitelist(repo.GoPath()) {
continue
}
@ -119,9 +128,11 @@ func setBranchToMaster() {
log.Warn("git checkout master branch worked", repo.Name())
} else {
log.Warn("git checkout master branch failed", repo.Name())
worked = false
}
// repo.NewScan()
}
return worked
}
func setTargetVersion() {

View File

@ -5,6 +5,7 @@ import (
"fmt"
"os"
"path/filepath"
"strings"
"go.wit.com/gui"
"go.wit.com/log"
@ -49,44 +50,20 @@ type releaseStruct struct {
}
func (w *autoType) Disable() {
// w.mainWindow.Disable()
release.box.Disable()
// buttonDisable()
me.mainBox.Disable()
}
func (w *autoType) Enable() {
// w.mainWindow.Enable()
release.box.Enable()
// buttonEnable()
me.mainBox.Enable()
}
func createReleaseBox(box *gui.Node) {
initWhitelist()
release.box = box
// release.box = box
release.box = box.NewVerticalBox("vbox")
release.group = release.box.NewGroup("Current Repo")
release.grid = release.group.NewGrid("buildOptions", 0, 0)
// do an initial scan of all the repos
scanGoSum()
release.grid.NewButton("scan for Ready", func() {
me.Disable()
scanForReady()
me.Enable()
})
release.grid.NewButton("findNextDirty()", func() {
me.Disable()
defer me.Enable()
if findNextDirty("PRIMATIVE") {
log.Info("findNextDirty() found a repo")
return
}
if findNextDirty("") {
log.Info("findNextDirty() found a repo")
return
}
})
release.grid.NextRow()
release.releaseVersionB = release.grid.NewButton("release version", func() {
@ -142,35 +119,26 @@ func createReleaseBox(box *gui.Node) {
panic("redo go.sum")
}
release.grid.NewButton("Check Ready", func() {
buttonDisable()
defer buttonEnable()
goSumS := release.current.GoState()
dirtyS := release.current.State()
lastS := release.current.LastTag()
if CheckReady() {
log.Info("repo is ready", release.current.Name(), goSumS, dirtyS, lastS)
return
} else {
log.Info("\trepo is not ready", release.current.Name(), goSumS, dirtyS, lastS)
}
})
group := release.box.NewGroup("Run on Current Repo")
grid := group.NewGrid("buildOptions", 0, 0)
release.grid.NewButton("set ignore", func() {
grid.NewButton("set to IGNORE", func() {
tmp := release.current.GoState()
log.Info("trying to set repo IGNORE is now =", tmp)
release.current.SetGoState("IGNORE")
release.whitelist[release.current.GoPath()] = release.current
})
release.checkGoSumB = release.grid.NewButton("checkValidGoSum()", func() {
release.checkGoSumB = grid.NewButton("checkValidGoSum()", func() {
buttonDisable()
checkValidGoSum(release.current)
buttonEnable()
})
release.grid.NextRow()
grid.NextRow()
release.grid.NewButton("release all", func() {
group = release.box.NewGroup("Process against all repos")
grid = group.NewGrid("buildOptions", 0, 0)
grid.NewButton("release all", func() {
var worked bool = true
buttonDisable()
// rather than loop forever, at least limit this to the number of repos
@ -196,7 +164,124 @@ func createReleaseBox(box *gui.Node) {
log.Info("release returned", worked, "and ran for", s)
buttonEnable()
})
release.grid.NextRow()
grid.NewButton("find first repo", func() {
// set the target versions
setTargetVersion()
// have to run this twice for now. not sure why
// this is old
scanForReady()
scanForReady()
findNextDirty("")
})
grid.NewButton("Check Ready", func() {
buttonDisable()
defer buttonEnable()
goSumS := release.current.GoState()
dirtyS := release.current.State()
lastS := release.current.LastTag()
if CheckReady() {
log.Info("repo is ready", release.current.Name(), goSumS, dirtyS, lastS)
return
} else {
log.Info("\trepo is not ready", release.current.Name(), goSumS, dirtyS, lastS)
}
})
grid.NewButton("scan for Ready", func() {
me.Disable()
scanForReady()
me.Enable()
})
grid.NewButton("findNextDirty()", func() {
me.Disable()
defer me.Enable()
if findNextDirty("PRIMATIVE") {
log.Info("findNextDirty() found a repo")
return
}
if findNextDirty("") {
log.Info("findNextDirty() found a repo")
return
}
})
grid.NextRow()
group = release.box.NewGroup("experimental and dangerous stuff")
grid = group.NewGrid("buildOptions", 0, 0)
grid.NewButton("rm -f go.mod go.sum", func() {
me.Disable()
for _, repo := range me.repos.View.AllRepos() {
if whitelist(repo.GoPath()) {
continue
}
if repo.Status.ReadOnly() {
continue
}
repo.Status.RunCmd([]string{"rm", "-f", "go.mod", "go.sum"})
}
me.Enable()
})
grid.NewButton("git reset --hard", func() {
me.Disable()
for _, repo := range me.repos.View.AllRepos() {
if whitelist(repo.GoPath()) {
log.Warn("skipping whitelist", repo.Name())
continue
}
log.Warn("running git reset --hard", repo.Name())
repo.Status.RunCmd([]string{"git", "reset", "--hard"})
}
me.Enable()
})
grid.NewButton("git ls-files |grep go.mod", func() {
// var all []string
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()
}
func buttonDisable() {
@ -251,7 +336,7 @@ func findNextDirty(onlyKind string) bool {
for _, repo := range me.repos.View.AllRepos() {
goSumS := repo.GoState()
if repo.Status.GetTargetVersion() == repo.Status.GetCurrentVersion() {
if repo.Status.IsReleased() {
continue
}
if goSumS == "WHITELIST" {

View File

@ -44,20 +44,11 @@ func makeRepoView() *repoWindow {
r.win.Make()
r.box = r.win.Box().NewBox("bw vbox", false)
// me.reposwin.Draw()
r.win.Custom = func() {
log.Warn("GOT HERE: main() gadgets.NewBasicWindow() close")
log.Warn("Should I do something special here?")
}
r.repoAllButtons()
r.View = repolist.GuireleaserView(r.box)
return r
}
func (r *repoWindow) repoAllButtons() {
// reposbox.SetExpand(false)
group1 := r.box.NewGroup("Run on all repos:")
@ -70,4 +61,12 @@ func (r *repoWindow) repoAllButtons() {
r.Disable()
r.Enable()
})
r.View = repolist.GuireleaserView(r.box)
showncount := r.View.MirrorShownCount()
box2.Append(showncount)
duration := r.View.MirrorScanDuration()
box2.Append(duration)
return r
}

View File

@ -26,10 +26,9 @@ type autoType struct {
// our view of the repositories
repos *repoWindow
// #### autotypist Global Display Options
autoHidePerfect *gui.Node
// #### guireleaser repolist display options
autoHideReadOnly *gui.Node
autoReleased *gui.Node
autoHideReleased *gui.Node
ignoreWhitelist *gui.Node
// #### autotypist Global Build Options