guireleaser/globalDisplayOptions.go

280 lines
6.5 KiB
Go
Raw Normal View History

package main
import (
"os"
"strings"
"go.wit.com/gui"
"go.wit.com/lib/debugger"
"go.wit.com/lib/gui/logsettings"
"go.wit.com/log"
)
func showHideRepos() {
2024-02-18 15:09:04 -06:00
for _, repo := range me.repos.View.AllRepos() {
2024-02-19 14:40:21 -06:00
// always show dirty repos
if repo.IsDirty() {
repo.Show()
continue
}
// always show repos that have not been merged to main
if repo.GoState() == "merge to devel" {
repo.Show()
continue
}
// hide read-only repos. These are repos that do not
// match things in the users config file (.config/autotypist)
if me.autoHideReadOnly.Checked() {
2024-02-18 15:09:04 -06:00
if repo.Status.ReadOnly() {
repo.Hide()
continue
}
}
if me.autoHidePerfect.Checked() {
2024-02-18 15:09:04 -06:00
if repo.State() == "PERFECT" {
repo.Hide()
continue
}
}
if me.autoReleased.Checked() {
2024-02-18 17:55:59 -06:00
if repo.GoState() == "RELEASED" {
repo.Hide()
continue
}
}
repo.Show()
}
}
func globalDisplayShow() {
2024-02-18 15:09:04 -06:00
for _, repo := range me.repos.View.AllRepos() {
if me.autoHideReadOnly.Checked() {
2024-02-18 15:09:04 -06:00
if repo.Status.ReadOnly() {
continue
}
}
if me.autoHidePerfect.Checked() {
2024-02-18 15:09:04 -06:00
if repo.State() == "PERFECT" {
continue
}
}
repo.Show()
}
}
func globalDisplayOptions(box *gui.Node) {
vbox := box.NewVerticalBox("DISPLAYVBOX")
group1 := vbox.NewGroup("Global Display Options")
group1.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")
showHideRepos()
// have to run this twice for now
// scanForReady()
// scanForReady()
// findNextDirty("")
// double check the found next repo
// fullDoubleCheckFix()
})
me.autoHideReadOnly = group1.NewCheckbox("Hide read-only repos").SetChecked(true)
me.autoHideReadOnly.Custom = func() {
if me.autoHideReadOnly.Checked() {
showHideRepos()
} else {
globalDisplayShow()
}
}
me.autoHidePerfect = group1.NewCheckbox("Hide Perfectly clean repos").SetChecked(true)
me.autoHidePerfect.Custom = func() {
if me.autoHidePerfect.Checked() {
showHideRepos()
} else {
globalDisplayShow()
}
}
me.autoReleased = group1.NewCheckbox("Hide RELEASED repos").SetChecked(false)
me.autoReleased.Custom = func() {
if me.autoReleased.Checked() {
2024-02-18 15:09:04 -06:00
for _, repo := range me.repos.View.AllRepos() {
2024-02-18 17:55:59 -06:00
if repo.GoState() == "RELEASED" {
repo.Hide()
}
}
} else {
2024-02-18 15:09:04 -06:00
for _, repo := range me.repos.View.AllRepos() {
repo.Show()
}
}
}
me.ignoreWhitelist = group1.NewCheckbox("ignore whitelist (are you sure?)").SetChecked(false)
me.scanEveryMinute = group1.NewCheckbox("Scan every minute").SetChecked(false)
me.setBranchesToMasterB = group1.NewButton("set all branches to master", func() {
me.Disable()
2024-02-18 15:09:04 -06:00
for _, repo := range me.repos.View.AllRepos() {
if repo.Status.ReadOnly() {
continue
}
2024-02-18 15:09:04 -06:00
if whitelist(repo.GoPath()) {
continue
}
2024-02-18 15:09:04 -06:00
if repo.Status.CheckoutMaster() {
log.Warn("set master branch worked", repo.Name())
repo.Status.UpdateNew()
} else {
2024-02-18 15:09:04 -06:00
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 = group1.NewButton("redo go.sum", func() {
os.Unsetenv("GO111MODULE")
longB.Disable()
me.Disable()
2024-02-18 15:09:04 -06:00
for _, repo := range me.repos.View.AllRepos() {
if whitelist(repo.GoPath()) {
continue
}
2024-02-18 15:09:04 -06:00
if repo.Status.ReadOnly() {
continue
}
2024-02-18 15:09:04 -06:00
if repo.Status.MakeRedomod() {
log.Info("redo go.sum failed on", repo.Name())
// me.Enable()
// longB.Enable()
// longB.SetLabel("FAILED")
// return
}
}
log.Info("redo go.sum finished ok!")
longB.Disable()
me.Enable()
longB.Enable()
})
group1.NewButton("rm -f go.mod go.sum", func() {
me.Disable()
2024-02-18 15:09:04 -06:00
for _, repo := range me.repos.View.AllRepos() {
if whitelist(repo.GoPath()) {
continue
}
2024-02-18 15:09:04 -06:00
if repo.Status.ReadOnly() {
continue
}
2024-02-18 15:09:04 -06:00
repo.Status.RunCmd([]string{"rm", "-f", "go.mod", "go.sum"})
}
me.Enable()
})
group1.NewButton("git reset --hard", func() {
me.Disable()
2024-02-18 15:09:04 -06:00
for _, repo := range me.repos.View.AllRepos() {
if whitelist(repo.GoPath()) {
log.Warn("skipping whitelist", repo.Name())
continue
}
2024-02-18 15:09:04 -06:00
log.Warn("running git reset --hard", repo.Name())
repo.Status.RunCmd([]string{"git", "reset", "--hard"})
}
me.Enable()
})
group1.NewButton("git ls-files |grep go.mod", func() {
// var all []string
2024-02-18 15:09:04 -06:00
for _, repo := range me.repos.View.AllRepos() {
log.Info("repo:", repo.Name())
if repo.Status.ReadOnly() {
continue
}
2024-02-18 15:09:04 -06:00
if whitelist(repo.GoPath()) {
log.Warn("skipping whitelist", repo.GoPath())
continue
}
2024-02-18 15:09:04 -06:00
good, files := repo.Status.GitLsFiles()
if !good {
2024-02-18 15:09:04 -06:00
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?")
2024-02-18 15:09:04 -06:00
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?")
2024-02-18 15:09:04 -06:00
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")
})
2024-02-19 14:40:21 -06:00
group1.NewButton("git checkout master", func() {
setBranchToMaster()
})
group1.NewButton("set target version", func() {
setTargetVersion()
})
group1.NewButton("re-scan all repos", func() {
me.repos.View.ScanRepositories()
2024-02-18 17:55:59 -06:00
})
group1.NewButton("scanForReady()", func() {
scanForReady()
})
group2 := vbox.NewGroup("Debugger")
group2.NewButton("logging Window", func() {
logsettings.LogWindow()
})
group2.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
}
}
}