guireleaser/globalDisplayOptions.go

234 lines
6.3 KiB
Go
Raw Permalink Normal View History

package main
import (
"os"
2024-03-02 20:47:10 -06:00
"strings"
"go.wit.com/gui"
"go.wit.com/lib/debugger"
"go.wit.com/lib/gui/logsettings"
"go.wit.com/log"
)
func globalDisplayOptions(box *gui.Node) {
vbox := box.NewVerticalBox("DISPLAYVBOX")
group1 := vbox.NewGroup("Global Display Options")
2024-02-19 19:42:14 -06:00
hidegrid := group1.NewGrid("hidecfg", 0, 0)
hidegrid.NewButton("Show Repository Window", func() {
2024-02-18 15:09:04 -06:00
if me.repos.Hidden() {
me.repos.Show()
} else {
2024-02-18 15:09:04 -06:00
me.repos.Hide()
}
2024-02-18 15:09:04 -06:00
log.Info("showing reposwin")
})
2024-02-19 19:42:14 -06:00
hidegrid.NextRow()
2024-02-19 19:42:14 -06:00
me.autoHideReadOnly = hidegrid.NewCheckbox("Hide read-only repos").SetChecked(true)
2024-02-29 19:51:28 -06:00
me.autoHideReadOnly.Custom = func() {
if me.autoHideReadOnly.Checked() {
os.Setenv("AUTOTYPIST_READONLY", "hide")
} else {
os.Unsetenv("AUTOTYPIST_READONLY")
}
}
os.Setenv("AUTOTYPIST_READONLY", "hide")
2024-02-19 19:42:14 -06:00
hidegrid.NextRow()
me.autoHideReleased = hidegrid.NewCheckbox("Hide Released repos").SetChecked(true)
2024-02-19 19:42:14 -06:00
hidegrid.NextRow()
me.ignoreWhitelist = hidegrid.NewCheckbox("ignore whitelist (are you sure?)").SetChecked(false)
hidegrid.NextRow()
2024-02-19 19:42:14 -06:00
me.scanEveryMinute = hidegrid.NewCheckbox("Scan every minute").SetChecked(false)
me.scanEveryMinute.Custom = func() {
if me.scanEveryMinute.Checked() {
os.Setenv("REPO_AUTO_SCAN", "true")
log.Info("env REPO_AUTO_SCAN=", os.Getenv("REPO_AUTO_SCAN"))
} else {
os.Unsetenv("REPO_AUTO_SCAN")
log.Info("env REPO_AUTO_SCAN=", os.Getenv("REPO_AUTO_SCAN"))
}
}
2024-02-19 19:42:14 -06:00
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)
2024-02-19 19:42:14 -06:00
})
me.duration = me.repos.View.MirrorScanDuration()
hidegrid.Append(me.duration)
2024-02-19 19:42:14 -06:00
hidegrid.NextRow()
group1 = vbox.NewGroup("prep for release")
2024-02-23 01:22:46 -06:00
grid := group1.RawGrid()
var longB *gui.Node
2024-02-20 20:42:54 -06:00
longB = grid.NewButton("generate go.sum files", func() {
me.Disable()
var worked bool = true
2024-02-18 15:09:04 -06:00
for _, repo := range me.repos.View.AllRepos() {
if whitelist(repo.GoPath()) {
continue
}
ok, err := me.repos.View.CheckValidGoSum(repo)
2024-02-20 06:53:07 -06:00
if !ok {
log.Info("redo go.sum failed on", repo.GoPath(), err)
worked = false
}
}
log.Info("redo go.sum finished with", worked)
me.Enable()
longB.SetLabel("go.sum files created")
if worked {
longB.Disable()
}
})
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()
2024-02-23 07:47:37 -06:00
var incrementTags *gui.Node
incrementTags = grid.NewButton("increment tags", func() {
2024-02-23 12:46:39 -06:00
me.Disable()
2024-02-23 01:22:46 -06:00
for _, repo := range me.repos.View.AllRepos() {
if whitelist(repo.GoPath()) {
continue
}
if repo.ReadOnly() {
continue
}
lasttag := repo.LastTag()
masterv := repo.Status.GetMasterVersion()
targetv := repo.Status.GetTargetVersion()
if lasttag == masterv {
// nothing to do if curv == masterv
// unless go.sum depends on changed repos
2024-02-23 12:46:39 -06:00
if targetv != lasttag {
log.Info(repo.GoPath(), "trigger a new release?", targetv, lasttag)
2024-03-02 20:47:10 -06:00
// repo.Status.SetVersion("0", "21", "0", me.releaseReasonS)
repo.Status.IncrementMinorVersion(me.releaseReasonS)
2024-02-23 12:46:39 -06:00
}
2024-02-23 01:22:46 -06:00
continue
}
2024-02-23 07:25:57 -06:00
newversion := repo.Status.GetNewVersionTag()
if newversion == targetv {
log.Info(repo.GoPath(), "targetv has been increased already to", targetv)
continue
}
2024-02-23 01:22:46 -06:00
if masterv != targetv {
2024-02-23 07:25:57 -06:00
log.Info(repo.GoPath(), "master and target differ", masterv, targetv)
repo.Status.IncrementVersion()
newversion := repo.Status.GetNewVersionTag()
2024-02-23 09:01:58 -06:00
repo.Status.SetTargetVersion("v" + newversion)
2024-02-23 01:22:46 -06:00
// already incremented
continue
}
}
2024-02-23 12:46:39 -06:00
if findNext() {
log.Info("findNext() found a repo")
}
incrementTags.SetText("maybe ready?")
me.Enable()
})
2024-03-02 20:47:10 -06:00
grid.NewButton("increment minor version", func() {
2024-03-03 11:53:33 -06:00
// 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()
2024-03-02 20:47:10 -06:00
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
}
2024-03-03 11:53:33 -06:00
if releasev == repo.Status.LastTag() {
log.Info("skipping already released repo", repo.Status.GoPath())
repo.Status.SetTargetVersion(releasev)
continue
}
2024-03-02 20:47:10 -06:00
// repo.Status.SetVersion("0", "22", "0", "trying increment minor")
repo.Status.IncrementMinorVersion("trying minor")
}
})
2024-03-09 22:02:32 -06:00
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()
})
2024-02-19 19:42:14 -06:00
grid.NextRow()
group2 := vbox.NewGroup("Debugger")
2024-02-19 19:42:14 -06:00
dbggrid := group2.NewGrid("gdb", 0, 0)
dbggrid.NewButton("logging Window", func() {
logsettings.LogWindow()
})
2024-02-19 19:42:14 -06:00
dbggrid.NextRow()
2024-02-19 19:42:14 -06:00
dbggrid.NewButton("Debugger Window", func() {
debugger.DebugWindow()
})
}
func hidePerfect() {
2024-02-18 15:09:04 -06:00
for _, repo := range me.repos.View.AllRepos() {
if repo.State() == "PERFECT" {
if repo.Hidden() {
continue
}
repo.Hide()
// return
}
}
}