2024-01-16 11:14:30 -06:00
|
|
|
package main
|
|
|
|
|
2024-01-18 00:58:14 -06:00
|
|
|
import (
|
2024-02-01 14:48:27 -06:00
|
|
|
"os"
|
2024-02-05 19:27:19 -06:00
|
|
|
"strings"
|
2024-02-01 14:48:27 -06:00
|
|
|
|
2024-01-18 05:03:04 -06:00
|
|
|
"go.wit.com/gui"
|
2024-01-20 17:17:48 -06:00
|
|
|
"go.wit.com/lib/debugger"
|
2024-01-20 16:09:15 -06:00
|
|
|
"go.wit.com/lib/gui/logsettings"
|
2024-02-19 22:00:58 -06:00
|
|
|
"go.wit.com/lib/gui/repolist"
|
2024-01-31 01:36:54 -06:00
|
|
|
"go.wit.com/log"
|
2024-01-16 11:14:30 -06:00
|
|
|
)
|
|
|
|
|
2024-02-19 22:00:58 -06:00
|
|
|
func showHideRepos(repo *repolist.Repo) {
|
|
|
|
// always show dirty repos
|
|
|
|
if repo.IsDirty() {
|
|
|
|
repo.Show()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
// always show repos that have not been merged to main
|
|
|
|
if repo.GoState() == "merge to devel" {
|
|
|
|
repo.Show()
|
|
|
|
return
|
|
|
|
}
|
2024-02-19 14:40:21 -06:00
|
|
|
|
2024-02-19 22:00:58 -06:00
|
|
|
// hide read-only repos. These are repos that do not
|
|
|
|
// match things in the users config file (.config/autotypist)
|
|
|
|
if me.autoHideReadOnly.Checked() {
|
|
|
|
if repo.Status.ReadOnly() {
|
|
|
|
repo.Hide()
|
|
|
|
return
|
2024-01-25 13:09:33 -06:00
|
|
|
}
|
2024-02-19 22:00:58 -06:00
|
|
|
}
|
|
|
|
if me.autoHidePerfect.Checked() {
|
|
|
|
if repo.State() == "PERFECT" {
|
|
|
|
repo.Hide()
|
|
|
|
return
|
2024-01-25 13:09:33 -06:00
|
|
|
}
|
2024-02-19 22:00:58 -06:00
|
|
|
}
|
|
|
|
if me.autoReleased.Checked() {
|
|
|
|
if repo.GoState() == "RELEASED" {
|
|
|
|
repo.Hide()
|
|
|
|
return
|
2024-02-11 19:10:18 -06:00
|
|
|
}
|
2024-01-25 13:09:33 -06:00
|
|
|
}
|
2024-02-19 22:00:58 -06:00
|
|
|
repo.Show()
|
2024-01-25 13:09:33 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func globalDisplayShow() {
|
2024-02-18 15:09:04 -06:00
|
|
|
for _, repo := range me.repos.View.AllRepos() {
|
2024-01-25 13:09:33 -06:00
|
|
|
if me.autoHideReadOnly.Checked() {
|
2024-02-18 15:09:04 -06:00
|
|
|
if repo.Status.ReadOnly() {
|
2024-01-25 13:09:33 -06:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if me.autoHidePerfect.Checked() {
|
2024-02-18 15:09:04 -06:00
|
|
|
if repo.State() == "PERFECT" {
|
2024-01-25 13:09:33 -06:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
repo.Show()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-16 11:14:30 -06:00
|
|
|
func globalDisplayOptions(box *gui.Node) {
|
2024-01-20 17:17:48 -06:00
|
|
|
vbox := box.NewVerticalBox("DISPLAYVBOX")
|
2024-01-16 11:14:30 -06:00
|
|
|
|
2024-01-20 17:17:48 -06:00
|
|
|
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()
|
2024-02-11 18:58:52 -06:00
|
|
|
} else {
|
2024-02-18 15:09:04 -06:00
|
|
|
me.repos.Hide()
|
2024-02-11 18:58:52 -06:00
|
|
|
}
|
2024-02-18 15:09:04 -06:00
|
|
|
log.Info("showing reposwin")
|
2024-02-19 22:00:58 -06:00
|
|
|
// showHideRepos()
|
|
|
|
|
2024-02-18 15:09:04 -06:00
|
|
|
// have to run this twice for now
|
|
|
|
// scanForReady()
|
|
|
|
// scanForReady()
|
|
|
|
// findNextDirty("")
|
|
|
|
// double check the found next repo
|
|
|
|
// fullDoubleCheckFix()
|
2024-01-17 01:55:22 -06:00
|
|
|
})
|
2024-02-19 19:42:14 -06:00
|
|
|
hidegrid.NextRow()
|
2024-01-20 16:09:15 -06:00
|
|
|
|
2024-02-19 19:42:14 -06:00
|
|
|
me.autoHideReadOnly = hidegrid.NewCheckbox("Hide read-only repos").SetChecked(true)
|
2024-01-25 11:11:43 -06:00
|
|
|
me.autoHideReadOnly.Custom = func() {
|
2024-01-25 02:50:16 -06:00
|
|
|
if me.autoHideReadOnly.Checked() {
|
2024-02-19 22:00:58 -06:00
|
|
|
// showHideRepos()
|
2024-01-25 13:09:33 -06:00
|
|
|
} else {
|
|
|
|
globalDisplayShow()
|
2024-01-25 02:50:16 -06:00
|
|
|
}
|
|
|
|
}
|
2024-02-19 19:42:14 -06:00
|
|
|
hidegrid.NextRow()
|
2024-01-25 02:40:59 -06:00
|
|
|
|
2024-02-19 19:42:14 -06:00
|
|
|
me.autoHidePerfect = hidegrid.NewCheckbox("Hide Perfectly clean repos").SetChecked(true)
|
2024-01-20 16:09:15 -06:00
|
|
|
me.autoHidePerfect.Custom = func() {
|
2024-02-19 22:00:58 -06:00
|
|
|
log.Info("registered hide function to showHideRepos()")
|
|
|
|
me.repos.View.RegisterHideFunction(showHideRepos)
|
|
|
|
/*
|
|
|
|
if me.autoHidePerfect.Checked() {
|
|
|
|
showHideRepos()
|
|
|
|
} else {
|
|
|
|
globalDisplayShow()
|
|
|
|
}
|
|
|
|
*/
|
2024-01-20 16:09:15 -06:00
|
|
|
}
|
2024-02-19 19:42:14 -06:00
|
|
|
hidegrid.NextRow()
|
2024-01-16 11:56:55 -06:00
|
|
|
|
2024-02-19 19:42:14 -06:00
|
|
|
me.autoReleased = hidegrid.NewCheckbox("Hide RELEASED repos").SetChecked(false)
|
2024-02-11 19:10:18 -06:00
|
|
|
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" {
|
2024-02-11 19:10:18 -06:00
|
|
|
repo.Hide()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2024-02-18 15:09:04 -06:00
|
|
|
for _, repo := range me.repos.View.AllRepos() {
|
2024-02-11 19:10:18 -06:00
|
|
|
repo.Show()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
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-11 19:10:18 -06:00
|
|
|
|
2024-02-19 19:42:14 -06:00
|
|
|
me.scanEveryMinute = hidegrid.NewCheckbox("Scan every minute").SetChecked(false)
|
|
|
|
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 = hidegrid.NewLabel("")
|
|
|
|
hidegrid.NextRow()
|
2024-01-31 01:36:54 -06:00
|
|
|
|
2024-02-19 19:42:14 -06:00
|
|
|
grid := group1.NewGrid("test", 0, 0)
|
2024-01-16 11:14:30 -06:00
|
|
|
|
2024-02-19 19:42:14 -06:00
|
|
|
grid.NewButton("git checkout master", func() {
|
|
|
|
setBranchToMaster()
|
|
|
|
})
|
|
|
|
|
2024-02-19 22:00:58 -06:00
|
|
|
grid.NewButton("find first repo", func() {
|
|
|
|
// set the target versions
|
|
|
|
setTargetVersion()
|
|
|
|
|
|
|
|
// have to run this twice for now. not sure why
|
|
|
|
scanForReady()
|
|
|
|
scanForReady()
|
|
|
|
|
|
|
|
findNextDirty("")
|
|
|
|
// double check the found next repo
|
|
|
|
fullDoubleCheckFix()
|
|
|
|
})
|
|
|
|
|
2024-02-19 19:42:14 -06:00
|
|
|
me.setBranchesToMasterB = grid.NewButton("set all branches to master", func() {
|
2024-01-31 02:27:17 -06:00
|
|
|
me.Disable()
|
2024-02-18 15:09:04 -06:00
|
|
|
for _, repo := range me.repos.View.AllRepos() {
|
|
|
|
if repo.Status.ReadOnly() {
|
2024-02-07 09:58:29 -06:00
|
|
|
continue
|
|
|
|
}
|
2024-02-18 15:09:04 -06:00
|
|
|
if whitelist(repo.GoPath()) {
|
2024-01-31 01:36:54 -06:00
|
|
|
continue
|
|
|
|
}
|
2024-02-18 15:09:04 -06:00
|
|
|
if repo.Status.CheckoutMaster() {
|
|
|
|
log.Warn("set master branch worked", repo.Name())
|
|
|
|
repo.Status.UpdateNew()
|
2024-01-31 01:14:11 -06:00
|
|
|
} 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())
|
2024-01-31 01:14:11 -06:00
|
|
|
}
|
|
|
|
}
|
2024-01-31 02:27:17 -06:00
|
|
|
me.Enable()
|
2024-02-01 13:51:17 -06:00
|
|
|
me.setBranchesToMasterB.Disable()
|
2024-01-31 02:27:17 -06:00
|
|
|
})
|
|
|
|
|
|
|
|
var longB *gui.Node
|
2024-02-19 19:42:14 -06:00
|
|
|
longB = grid.NewButton("redo go.sum", func() {
|
2024-02-01 14:48:27 -06:00
|
|
|
os.Unsetenv("GO111MODULE")
|
2024-01-31 02:27:17 -06:00
|
|
|
longB.Disable()
|
|
|
|
me.Disable()
|
2024-02-18 15:09:04 -06:00
|
|
|
for _, repo := range me.repos.View.AllRepos() {
|
|
|
|
if whitelist(repo.GoPath()) {
|
2024-01-31 02:27:17 -06:00
|
|
|
continue
|
|
|
|
}
|
2024-02-18 15:09:04 -06:00
|
|
|
if repo.Status.ReadOnly() {
|
2024-02-05 19:27:19 -06:00
|
|
|
continue
|
|
|
|
}
|
2024-02-18 15:09:04 -06:00
|
|
|
if repo.Status.MakeRedomod() {
|
|
|
|
log.Info("redo go.sum failed on", repo.Name())
|
2024-02-01 14:48:27 -06:00
|
|
|
// me.Enable()
|
|
|
|
// longB.Enable()
|
|
|
|
// longB.SetLabel("FAILED")
|
|
|
|
// return
|
2024-02-01 13:30:26 -06:00
|
|
|
}
|
2024-01-31 02:27:17 -06:00
|
|
|
}
|
2024-02-01 13:30:26 -06:00
|
|
|
log.Info("redo go.sum finished ok!")
|
2024-02-14 01:04:31 -06:00
|
|
|
longB.Disable()
|
2024-01-31 02:27:17 -06:00
|
|
|
me.Enable()
|
|
|
|
longB.Enable()
|
2024-01-31 01:14:11 -06:00
|
|
|
})
|
2024-01-20 16:09:15 -06:00
|
|
|
|
2024-02-19 19:42:14 -06:00
|
|
|
grid.NewButton("set target version", func() {
|
|
|
|
setTargetVersion()
|
|
|
|
})
|
|
|
|
grid.NextRow()
|
|
|
|
|
|
|
|
grid.NewButton("rm -f go.mod go.sum", func() {
|
2024-01-31 02:27:17 -06:00
|
|
|
me.Disable()
|
2024-02-18 15:09:04 -06:00
|
|
|
for _, repo := range me.repos.View.AllRepos() {
|
|
|
|
if whitelist(repo.GoPath()) {
|
2024-01-31 01:36:54 -06:00
|
|
|
continue
|
|
|
|
}
|
2024-02-18 15:09:04 -06:00
|
|
|
if repo.Status.ReadOnly() {
|
2024-02-05 19:27:19 -06:00
|
|
|
continue
|
|
|
|
}
|
2024-02-18 15:09:04 -06:00
|
|
|
repo.Status.RunCmd([]string{"rm", "-f", "go.mod", "go.sum"})
|
2024-01-31 01:36:54 -06:00
|
|
|
}
|
2024-01-31 02:27:17 -06:00
|
|
|
me.Enable()
|
2024-01-31 01:36:54 -06:00
|
|
|
})
|
|
|
|
|
2024-02-19 19:42:14 -06:00
|
|
|
grid.NewButton("git reset --hard", func() {
|
2024-01-31 02:27:17 -06:00
|
|
|
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())
|
2024-01-31 01:36:54 -06:00
|
|
|
continue
|
|
|
|
}
|
2024-02-18 15:09:04 -06:00
|
|
|
log.Warn("running git reset --hard", repo.Name())
|
|
|
|
repo.Status.RunCmd([]string{"git", "reset", "--hard"})
|
2024-01-31 01:36:54 -06:00
|
|
|
}
|
2024-01-31 02:27:17 -06:00
|
|
|
me.Enable()
|
2024-01-31 01:36:54 -06:00
|
|
|
})
|
|
|
|
|
2024-02-19 19:42:14 -06:00
|
|
|
grid.NewButton("git ls-files |grep go.mod", func() {
|
2024-02-05 19:27:19 -06:00
|
|
|
// 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() {
|
2024-02-05 19:27:19 -06:00
|
|
|
continue
|
|
|
|
}
|
2024-02-18 15:09:04 -06:00
|
|
|
if whitelist(repo.GoPath()) {
|
|
|
|
log.Warn("skipping whitelist", repo.GoPath())
|
2024-02-05 19:27:19 -06:00
|
|
|
continue
|
|
|
|
}
|
2024-02-18 15:09:04 -06:00
|
|
|
good, files := repo.Status.GitLsFiles()
|
2024-02-05 19:27:19 -06:00
|
|
|
if !good {
|
2024-02-18 15:09:04 -06:00
|
|
|
log.Warn("Something went wrong", repo.GoPath())
|
2024-02-05 19:27:19 -06:00
|
|
|
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())
|
2024-02-05 19:27:19 -06:00
|
|
|
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())
|
2024-02-05 19:27:19 -06:00
|
|
|
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 19:42:14 -06:00
|
|
|
grid.NextRow()
|
2024-02-05 19:27:19 -06:00
|
|
|
|
2024-02-19 19:42:14 -06:00
|
|
|
grid.NewButton("scanForReady()", func() {
|
2024-02-18 17:55:59 -06:00
|
|
|
scanForReady()
|
|
|
|
})
|
|
|
|
|
2024-01-20 17:17:48 -06:00
|
|
|
group2 := vbox.NewGroup("Debugger")
|
2024-02-19 19:42:14 -06:00
|
|
|
dbggrid := group2.NewGrid("gdb", 0, 0)
|
|
|
|
dbggrid.NewButton("logging Window", func() {
|
2024-01-20 16:09:15 -06:00
|
|
|
logsettings.LogWindow()
|
|
|
|
})
|
2024-02-19 19:42:14 -06:00
|
|
|
dbggrid.NextRow()
|
2024-01-20 17:17:48 -06:00
|
|
|
|
2024-02-19 19:42:14 -06:00
|
|
|
dbggrid.NewButton("Debugger Window", func() {
|
2024-01-20 17:17:48 -06:00
|
|
|
debugger.DebugWindow()
|
|
|
|
})
|
2024-01-16 11:14:30 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func hidePerfect() {
|
2024-02-18 15:09:04 -06:00
|
|
|
for _, repo := range me.repos.View.AllRepos() {
|
|
|
|
if repo.State() == "PERFECT" {
|
|
|
|
if repo.Hidden() {
|
2024-01-16 11:14:30 -06:00
|
|
|
continue
|
|
|
|
}
|
2024-01-19 18:37:27 -06:00
|
|
|
repo.Hide()
|
2024-01-16 11:14:30 -06:00
|
|
|
// return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|