code cleanup

This commit is contained in:
Jeff Carr 2024-11-13 17:23:33 -06:00
parent 250a96c49f
commit fcd132c109
6 changed files with 199 additions and 163 deletions

View File

@ -1,6 +1,8 @@
VERSION = $(shell git describe --tags) VERSION = $(shell git describe --tags)
all: all:
@echo to test: 'make test'
@echo
@echo run this from the autotypist dir: @echo run this from the autotypist dir:
@echo " GUIRELEASE_REASON=notsure guireleaser" @echo " GUIRELEASE_REASON=notsure guireleaser"
@echo then: @echo then:

View File

@ -1,12 +1,7 @@
package main package main
import ( import (
"os"
"strings"
"go.wit.com/gui" "go.wit.com/gui"
"go.wit.com/lib/debugger"
"go.wit.com/lib/gui/logsettings"
"go.wit.com/log" "go.wit.com/log"
) )
@ -27,44 +22,47 @@ func globalDisplayOptions(box *gui.Node) {
}) })
hidegrid.NextRow() hidegrid.NextRow()
me.autoHideReadOnly = hidegrid.NewCheckbox("Hide read-only repos").SetChecked(true) /*
me.autoHideReadOnly.Custom = func() { me.autoHideReadOnly = hidegrid.NewCheckbox("Hide read-only repos").SetChecked(true)
if me.autoHideReadOnly.Checked() { me.autoHideReadOnly.Custom = func() {
os.Setenv("AUTOTYPIST_READONLY", "hide") if me.autoHideReadOnly.Checked() {
} else { os.Setenv("AUTOTYPIST_READONLY", "hide")
os.Unsetenv("AUTOTYPIST_READONLY") } else {
os.Unsetenv("AUTOTYPIST_READONLY")
}
} }
} os.Setenv("AUTOTYPIST_READONLY", "hide")
os.Setenv("AUTOTYPIST_READONLY", "hide") hidegrid.NextRow()
hidegrid.NextRow()
me.autoHideReleased = hidegrid.NewCheckbox("Hide Released repos").SetChecked(true) me.autoHideReleased = hidegrid.NewCheckbox("Hide Released repos").SetChecked(true)
hidegrid.NextRow() hidegrid.NextRow()
me.ignoreWhitelist = hidegrid.NewCheckbox("ignore whitelist (are you sure?)").SetChecked(false) me.ignoreWhitelist = hidegrid.NewCheckbox("ignore whitelist (are you sure?)").SetChecked(false)
hidegrid.NextRow() hidegrid.NextRow()
me.scanEveryMinute = hidegrid.NewCheckbox("Scan every minute").SetChecked(false) me.scanEveryMinute = hidegrid.NewCheckbox("Scan every minute").SetChecked(false)
me.scanEveryMinute.Custom = func() { me.scanEveryMinute.Custom = func() {
if me.scanEveryMinute.Checked() { if me.scanEveryMinute.Checked() {
os.Setenv("REPO_AUTO_SCAN", "true") os.Setenv("REPO_AUTO_SCAN", "true")
log.Info("env REPO_AUTO_SCAN=", os.Getenv("REPO_AUTO_SCAN")) log.Info("env REPO_AUTO_SCAN=", os.Getenv("REPO_AUTO_SCAN"))
} else { } else {
os.Unsetenv("REPO_AUTO_SCAN") os.Unsetenv("REPO_AUTO_SCAN")
log.Info("env REPO_AUTO_SCAN=", os.Getenv("REPO_AUTO_SCAN")) log.Info("env REPO_AUTO_SCAN=", os.Getenv("REPO_AUTO_SCAN"))
}
} }
} */
hidegrid.NewButton("scan now", func() { /*
log.Info("re-scanning repos now") hidegrid.NewButton("scan now", func() {
i, s := me.repos.View.ScanRepositories() log.Info("re-scanning repos now")
log.Info("re-scanning repos done", i, s) i, s := me.repos.View.ScanRepositories()
// me.duration.SetText(s) log.Info("re-scanning repos done", i, s)
}) // me.duration.SetText(s)
me.duration = me.repos.View.MirrorScanDuration() })
hidegrid.Append(me.duration) me.duration = me.repos.View.MirrorScanDuration()
hidegrid.Append(me.duration)
hidegrid.NextRow() */
group1 = vbox.NewGroup("prep for release") group1 = vbox.NewGroup("prep for release")
grid := group1.RawGrid() grid := group1.RawGrid()
@ -101,125 +99,146 @@ func globalDisplayOptions(box *gui.Node) {
}) })
grid.NextRow() grid.NextRow()
var incrementTags *gui.Node grid.NewButton("make prepare-release", func() {
incrementTags = grid.NewButton("increment tags", func() { loop := me.repos.View.ReposSortByName()
me.Disable() for loop.Scan() {
for _, repo := range me.repos.View.AllRepos() { repo := loop.Repo()
if whitelist(repo.GoPath()) {
continue
}
if repo.ReadOnly() {
continue
}
lasttag := repo.LastTag()
masterv := repo.Status.GetMasterVersion()
targetv := repo.Status.GetTargetVersion()
if lasttag == masterv { master := repo.Status.GetMasterVersion()
// nothing to do if curv == masterv lastTag := repo.Status.LastTag()
// unless go.sum depends on changed repos if master == lastTag {
if targetv != lasttag { repo.Status.SetTargetVersion(master)
log.Info(repo.GoPath(), "trigger a new release?", targetv, lasttag) } else {
// repo.Status.SetVersion("0", "21", "0", me.releaseReasonS) repo.Status.IncrementRevisionVersion("Nov 2024 test")
repo.Status.IncrementMinorVersion(me.releaseReasonS)
}
continue
}
newversion := repo.Status.GetNewVersionTag()
if newversion == targetv {
log.Info(repo.GoPath(), "targetv has been increased already to", targetv)
continue
}
if masterv != targetv {
log.Info(repo.GoPath(), "master and target differ", masterv, targetv)
repo.Status.IncrementVersion()
newversion := repo.Status.GetNewVersionTag()
repo.Status.SetTargetVersion("v" + newversion)
// already incremented
continue
} }
} }
if findNext() {
log.Info("findNext() found a repo")
}
incrementTags.SetText("maybe ready?")
me.Enable()
})
grid.NewButton("increment minor version", func() {
// this is messy still. if the release process fails, it needs to continue
// for now, use the "go.wit.com/log" release minor number as the official
// release. If it hasn't been updated yet, then start there
logrepo := me.repos.View.FindRepo("go.wit.com/log")
if logrepo == nil {
log.Info("couldn't find go.wit.com/log")
return
}
releasev := logrepo.Status.LastTag()
for _, repo := range me.repos.View.AllRepos() {
if whitelist(repo.GoPath()) {
continue
}
if repo.ReadOnly() {
continue
}
if strings.HasPrefix(repo.GoPath(), "go.wit.com/dev") {
continue
}
if strings.HasPrefix(repo.GoPath(), "go.wit.com/widget") {
// widget I versioned early before I knew what the hell this would mean and can
// not be down versioned because that's not how GO versioning works. Once you
// set the version for a path, it's set in stone forever. (smart system!)
// we could rename go.wit.com/widget to go.wit.com/newwidget and restart the versioning
// system, but that's rediculous and this servers to always remind me to never make this mistake again
repo.Status.IncrementRevisionVersion("trying minor")
continue
}
if releasev == repo.Status.LastTag() {
log.Info("skipping already released repo", repo.Status.GoPath())
repo.Status.SetTargetVersion(releasev)
continue
}
// repo.Status.SetVersion("0", "22", "0", "trying increment minor")
repo.Status.IncrementMinorVersion("trying minor")
}
})
grid.NewButton("increment changed repos", func() {
me.Disable()
for _, repo := range me.repos.View.AllRepos() {
if whitelist(repo.GoPath()) {
continue
}
if repo.ReadOnly() {
continue
}
lasttag := repo.Status.LastTag()
if repo.Status.GetCurrentVersion() == lasttag {
log.Info("skipping unchanged repo", repo.Status.GoPath())
repo.Status.SetTargetVersion(lasttag)
continue
}
repo.Status.IncrementRevisionVersion("go-clone")
}
me.repos.View.ScanRepositories()
me.Enable()
}) })
grid.NextRow() grid.NextRow()
group2 := vbox.NewGroup("Debugger") /*
dbggrid := group2.NewGrid("gdb", 0, 0) var incrementTags *gui.Node
dbggrid.NewButton("logging Window", func() { incrementTags = grid.NewButton("increment tags", func() {
logsettings.LogWindow() me.Disable()
}) for _, repo := range me.repos.View.AllRepos() {
dbggrid.NextRow() if whitelist(repo.GoPath()) {
continue
}
if repo.ReadOnly() {
continue
}
lasttag := repo.LastTag()
masterv := repo.Status.GetMasterVersion()
targetv := repo.Status.GetTargetVersion()
dbggrid.NewButton("Debugger Window", func() { if lasttag == masterv {
debugger.DebugWindow() // nothing to do if curv == masterv
}) // unless go.sum depends on changed repos
if targetv != lasttag {
log.Info(repo.GoPath(), "trigger a new release?", targetv, lasttag)
// repo.Status.SetVersion("0", "21", "0", me.releaseReasonS)
repo.Status.IncrementMinorVersion(me.releaseReasonS)
}
continue
}
newversion := repo.Status.GetNewVersionTag()
if newversion == targetv {
log.Info(repo.GoPath(), "targetv has been increased already to", targetv)
continue
}
if masterv != targetv {
log.Info(repo.GoPath(), "master and target differ", masterv, targetv)
repo.Status.IncrementVersion()
newversion := repo.Status.GetNewVersionTag()
repo.Status.SetTargetVersion("v" + newversion)
// already incremented
continue
}
}
if findNext() {
log.Info("findNext() found a repo")
}
incrementTags.SetText("maybe ready?")
me.Enable()
})
grid.NewButton("increment minor version", func() {
// this is messy still. if the release process fails, it needs to continue
// for now, use the "go.wit.com/log" release minor number as the official
// release. If it hasn't been updated yet, then start there
logrepo := me.repos.View.FindRepo("go.wit.com/log")
if logrepo == nil {
log.Info("couldn't find go.wit.com/log")
return
}
releasev := logrepo.Status.LastTag()
for _, repo := range me.repos.View.AllRepos() {
if whitelist(repo.GoPath()) {
continue
}
if repo.ReadOnly() {
continue
}
if strings.HasPrefix(repo.GoPath(), "go.wit.com/dev") {
continue
}
if strings.HasPrefix(repo.GoPath(), "go.wit.com/widget") {
// widget I versioned early before I knew what the hell this would mean and can
// not be down versioned because that's not how GO versioning works. Once you
// set the version for a path, it's set in stone forever. (smart system!)
// we could rename go.wit.com/widget to go.wit.com/newwidget and restart the versioning
// system, but that's rediculous and this servers to always remind me to never make this mistake again
repo.Status.IncrementRevisionVersion("trying minor")
continue
}
if releasev == repo.Status.LastTag() {
log.Info("skipping already released repo", repo.Status.GoPath())
repo.Status.SetTargetVersion(releasev)
continue
}
// repo.Status.SetVersion("0", "22", "0", "trying increment minor")
repo.Status.IncrementMinorVersion("trying minor")
}
})
grid.NewButton("increment changed repos", func() {
me.Disable()
for _, repo := range me.repos.View.AllRepos() {
if whitelist(repo.GoPath()) {
continue
}
if repo.ReadOnly() {
continue
}
lasttag := repo.Status.LastTag()
if repo.Status.GetCurrentVersion() == lasttag {
log.Info("skipping unchanged repo", repo.Status.GoPath())
repo.Status.SetTargetVersion(lasttag)
continue
}
repo.Status.IncrementRevisionVersion("go-clone")
}
me.repos.View.ScanRepositories()
me.Enable()
})
*/
grid.NextRow()
/*
group2 := vbox.NewGroup("Debugger")
dbggrid := group2.NewGrid("gdb", 0, 0)
dbggrid.NewButton("logging Window", func() {
logsettings.LogWindow()
})
dbggrid.NextRow()
dbggrid.NewButton("Debugger Window", func() {
debugger.DebugWindow()
})
*/
} }
/*
func hidePerfect() { func hidePerfect() {
for _, repo := range me.repos.View.AllRepos() { for _, repo := range me.repos.View.AllRepos() {
if repo.State() == "PERFECT" { if repo.State() == "PERFECT" {
@ -231,3 +250,4 @@ func hidePerfect() {
} }
} }
} }
*/

View File

@ -4,15 +4,16 @@ import (
"os" "os"
"go.wit.com/lib/gui/repolist" "go.wit.com/lib/gui/repolist"
"go.wit.com/log"
) )
// like tcl/tk, use ENV variables to set display preferences // like tcl/tk, use ENV variables to set display preferences
func hideFunction(r *repolist.RepoRow) { func hideFunction(r *repolist.RepoRow) {
if r.GoPath() == "go.wit.com/dev/alexflint/arg" { /*
log.Info("found autoHideReleased() =", me.autoHideReleased.Checked()) if r.GoPath() == "go.wit.com/dev/alexflint/arg" {
log.Info("found alexflint/arg IsReleased() =", r.Status.IsReleased()) log.Info("found autoHideReleased() =", me.autoHideReleased.Checked())
} log.Info("found alexflint/arg IsReleased() =", r.Status.IsReleased())
}
*/
// always show dirty repos // always show dirty repos
if r.Status.IsDirty() { if r.Status.IsDirty() {
@ -47,12 +48,14 @@ func hideFunction(r *repolist.RepoRow) {
} }
} }
if me.autoHideReleased.Checked() { /*
if r.Status.IsReleased() { if me.autoHideReleased.Checked() {
r.Hide() if r.Status.IsReleased() {
return r.Hide()
return
}
} }
} */
// show everything else. often this will be "unconforming" repos // show everything else. often this will be "unconforming" repos
// if you what those repos ignored, add these to the config file // if you what those repos ignored, add these to the config file

View File

@ -170,6 +170,16 @@ func createReleaseBox(box *gui.Node) {
group = me.release.box.NewGroup("experimental and potentially dangerous stuff") group = me.release.box.NewGroup("experimental and potentially dangerous stuff")
grid = group.NewGrid("buildOptions", 0, 0) grid = group.NewGrid("buildOptions", 0, 0)
me.setBranchesToMasterB = grid.NewButton("set all branches to master", func() {
me.Disable()
defer me.Enable()
if setAllBranchesToMaster() {
// if it succeeds, disable this button
me.setBranchesToMasterB.Disable()
}
})
grid.NextRow()
grid.NewButton("git ls-files |grep go.mod", func() { grid.NewButton("git ls-files |grep go.mod", func() {
for _, repo := range me.repos.View.AllRepos() { for _, repo := range me.repos.View.AllRepos() {
log.Info("repo:", repo.Name()) log.Info("repo:", repo.Name())

View File

@ -27,9 +27,9 @@ type autoType struct {
repos *repoWindow repos *repoWindow
// #### guireleaser repolist display options // #### guireleaser repolist display options
autoHideReadOnly *gui.Node // autoHideReadOnly *gui.Node
autoHideReleased *gui.Node // autoHideReleased *gui.Node
ignoreWhitelist *gui.Node // ignoreWhitelist *gui.Node
// #### autotypist Global Build Options // #### autotypist Global Build Options
// what to change all the branches to // what to change all the branches to

View File

@ -11,7 +11,8 @@ func initWhitelist() {
me.release.whitelist = make(map[string]*repolist.RepoRow) me.release.whitelist = make(map[string]*repolist.RepoRow)
for _, repo := range me.repos.View.AllRepos() { for _, repo := range me.repos.View.AllRepos() {
if strings.HasPrefix(repo.GoPath(), "go.wit.com/dev/davecgh") { if strings.HasPrefix(repo.GoPath(), "go.wit.com/dev/davecgh") {
me.release.whitelist[repo.GoPath()] = repo repo.Status.Whitelist = true
// me.release.whitelist[repo.GoPath()] = repo
} }
// //
// if repo.String() == "go.wit.com/apps/guireleaser" { // if repo.String() == "go.wit.com/apps/guireleaser" {
@ -27,9 +28,9 @@ func initWhitelist() {
func whitelist(path string) bool { func whitelist(path string) bool {
// log.Info("whitelist START", path) // log.Info("whitelist START", path)
if me.ignoreWhitelist.Checked() { // if me.ignoreWhitelist.Checked() {
return false // return false
} // }
_, ok := me.release.whitelist[path] _, ok := me.release.whitelist[path]
if ok { if ok {