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-01-31 01:36:54 -06:00
|
|
|
"go.wit.com/log"
|
2024-01-16 11:14:30 -06:00
|
|
|
)
|
|
|
|
|
2024-01-31 05:04:18 -06:00
|
|
|
func showHideRepos() {
|
2024-01-25 13:09:33 -06:00
|
|
|
for _, repo := range me.allrepos {
|
|
|
|
if me.autoHideReadOnly.Checked() {
|
|
|
|
if repo.status.ReadOnly() {
|
|
|
|
repo.Hide()
|
2024-01-26 09:34:42 -06:00
|
|
|
continue
|
2024-01-25 13:09:33 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if me.autoHidePerfect.Checked() {
|
|
|
|
if repo.dirtyLabel.String() == "PERFECT" {
|
|
|
|
repo.Hide()
|
2024-01-26 09:34:42 -06:00
|
|
|
continue
|
2024-01-25 13:09:33 -06:00
|
|
|
}
|
|
|
|
}
|
2024-02-11 19:10:18 -06:00
|
|
|
if me.autoReleased.Checked() {
|
|
|
|
if repo.getGoSumStatus() == "RELEASED" {
|
|
|
|
repo.Hide()
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
}
|
2024-01-26 09:34:42 -06:00
|
|
|
repo.Show()
|
2024-01-25 13:09:33 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func globalDisplayShow() {
|
|
|
|
for _, repo := range me.allrepos {
|
|
|
|
if me.autoHideReadOnly.Checked() {
|
|
|
|
if repo.status.ReadOnly() {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if me.autoHidePerfect.Checked() {
|
|
|
|
if repo.dirtyLabel.String() == "PERFECT" {
|
|
|
|
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")
|
|
|
|
|
|
|
|
group1.NewButton("Show Repository Window", func() {
|
2024-02-11 18:58:52 -06:00
|
|
|
if reposwin.Hidden() {
|
|
|
|
log.Info("showing reposwin")
|
|
|
|
showHideRepos()
|
2024-02-14 12:14:33 -06:00
|
|
|
// have to run this twice for now
|
2024-02-11 18:58:52 -06:00
|
|
|
scanForReady()
|
|
|
|
scanForReady()
|
|
|
|
reposwin.Show()
|
|
|
|
findNextDirty("")
|
|
|
|
// double check the found next repo
|
|
|
|
fullDoubleCheckFix()
|
|
|
|
} else {
|
|
|
|
log.Info("hiding reposwin")
|
|
|
|
reposwin.Hide()
|
|
|
|
}
|
2024-01-17 01:55:22 -06:00
|
|
|
})
|
2024-01-20 16:09:15 -06:00
|
|
|
|
2024-01-25 02:40:59 -06:00
|
|
|
me.autoHideReadOnly = group1.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-01-31 05:04:18 -06:00
|
|
|
showHideRepos()
|
2024-01-25 13:09:33 -06:00
|
|
|
} else {
|
|
|
|
globalDisplayShow()
|
2024-01-25 02:50:16 -06:00
|
|
|
}
|
|
|
|
}
|
2024-01-25 02:40:59 -06:00
|
|
|
|
2024-01-30 13:45:42 -06:00
|
|
|
me.autoHidePerfect = group1.NewCheckbox("Hide Perfectly clean repos").SetChecked(true)
|
2024-01-20 16:09:15 -06:00
|
|
|
me.autoHidePerfect.Custom = func() {
|
|
|
|
if me.autoHidePerfect.Checked() {
|
2024-01-31 05:04:18 -06:00
|
|
|
showHideRepos()
|
2024-01-20 16:09:15 -06:00
|
|
|
} else {
|
2024-01-25 13:09:33 -06:00
|
|
|
globalDisplayShow()
|
2024-01-16 11:14:30 -06:00
|
|
|
}
|
2024-01-20 16:09:15 -06:00
|
|
|
}
|
2024-01-16 11:56:55 -06:00
|
|
|
|
2024-02-11 19:10:18 -06:00
|
|
|
me.autoReleased = group1.NewCheckbox("Hide RELEASED repos").SetChecked(false)
|
|
|
|
me.autoReleased.Custom = func() {
|
|
|
|
if me.autoReleased.Checked() {
|
|
|
|
for _, repo := range me.allrepos {
|
|
|
|
if repo.getGoSumStatus() == "RELEASED" {
|
|
|
|
repo.Hide()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for _, repo := range me.allrepos {
|
|
|
|
repo.Show()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-31 01:36:54 -06:00
|
|
|
me.ignoreWhitelist = group1.NewCheckbox("ignore whitelist (are you sure?)").SetChecked(false)
|
|
|
|
|
|
|
|
me.scanEveryMinute = group1.NewCheckbox("Scan every minute").SetChecked(false)
|
2024-01-16 11:14:30 -06:00
|
|
|
|
2024-02-01 13:51:17 -06:00
|
|
|
me.setBranchesToMasterB = group1.NewButton("set all branches to master", func() {
|
2024-01-31 02:27:17 -06:00
|
|
|
me.Disable()
|
2024-01-31 01:14:11 -06:00
|
|
|
for _, repo := range me.allrepos {
|
2024-02-07 09:58:29 -06:00
|
|
|
if repo.status.ReadOnly() {
|
|
|
|
continue
|
|
|
|
}
|
2024-01-31 01:36:54 -06:00
|
|
|
if whitelist(repo.String()) {
|
|
|
|
continue
|
|
|
|
}
|
2024-01-31 01:14:11 -06:00
|
|
|
if repo.status.CheckoutMaster() {
|
2024-02-01 13:51:17 -06:00
|
|
|
log.Warn("set master branch worked", repo.String())
|
2024-01-31 01:14:11 -06:00
|
|
|
repo.newScan()
|
|
|
|
} else {
|
|
|
|
repo.newScan()
|
2024-02-07 09:58:29 -06:00
|
|
|
log.Warn("set master branch failed", repo.String())
|
|
|
|
log.Warn("set master branch failed", repo.String())
|
|
|
|
log.Warn("set master branch failed", repo.String())
|
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
|
|
|
|
longB = group1.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()
|
|
|
|
for _, repo := range me.allrepos {
|
|
|
|
if whitelist(repo.String()) {
|
|
|
|
continue
|
|
|
|
}
|
2024-02-05 19:27:19 -06:00
|
|
|
if repo.status.ReadOnly() {
|
|
|
|
continue
|
|
|
|
}
|
2024-02-01 13:30:26 -06:00
|
|
|
if repo.status.MakeRedomod() {
|
|
|
|
log.Info("redo go.sum failed on", repo.String())
|
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-01-31 01:36:54 -06:00
|
|
|
group1.NewButton("rm -f go.mod go.sum", func() {
|
2024-01-31 02:27:17 -06:00
|
|
|
me.Disable()
|
2024-01-31 01:36:54 -06:00
|
|
|
for _, repo := range me.allrepos {
|
|
|
|
if whitelist(repo.String()) {
|
|
|
|
continue
|
|
|
|
}
|
2024-02-05 19:27:19 -06:00
|
|
|
if repo.status.ReadOnly() {
|
|
|
|
continue
|
|
|
|
}
|
2024-01-31 01:36:54 -06:00
|
|
|
repo.status.RunCmd([]string{"rm", "-f", "go.mod", "go.sum"})
|
|
|
|
}
|
2024-01-31 02:27:17 -06:00
|
|
|
me.Enable()
|
2024-01-31 01:36:54 -06:00
|
|
|
})
|
|
|
|
|
|
|
|
group1.NewButton("git reset --hard", func() {
|
2024-01-31 02:27:17 -06:00
|
|
|
me.Disable()
|
2024-01-31 01:36:54 -06:00
|
|
|
for _, repo := range me.allrepos {
|
|
|
|
if whitelist(repo.String()) {
|
2024-01-31 01:41:38 -06:00
|
|
|
log.Warn("skipping whitelist", repo.String())
|
2024-01-31 01:36:54 -06:00
|
|
|
continue
|
|
|
|
}
|
2024-01-31 01:41:38 -06:00
|
|
|
log.Warn("running git reset --hard", repo.String())
|
2024-01-31 01:36:54 -06:00
|
|
|
repo.status.RunCmd([]string{"git", "reset", "--hard"})
|
|
|
|
}
|
2024-01-31 02:27:17 -06:00
|
|
|
me.Enable()
|
2024-01-31 01:36:54 -06:00
|
|
|
})
|
|
|
|
|
2024-02-05 19:27:19 -06:00
|
|
|
group1.NewButton("git ls-files |grep go.mod", func() {
|
|
|
|
// var all []string
|
|
|
|
for _, repo := range me.allrepos {
|
|
|
|
log.Info("repo:", repo.String())
|
|
|
|
if repo.status.ReadOnly() {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if whitelist(repo.String()) {
|
|
|
|
log.Warn("skipping whitelist", repo.String())
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
good, files := repo.status.GitLsFiles()
|
|
|
|
if !good {
|
|
|
|
log.Warn("Something went wrong", repo.String())
|
|
|
|
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.lastTag.String(), "vs", repo.targetVersion.String())
|
|
|
|
if repo.lastTag.String() != repo.targetVersion.String() {
|
|
|
|
log.Info(repo.lastTag.String(), "vs", repo.targetVersion.String())
|
|
|
|
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.lastTag.String(), "vs", repo.targetVersion.String())
|
|
|
|
if repo.lastTag.String() != repo.targetVersion.String() {
|
|
|
|
log.Info(repo.lastTag.String(), "vs", repo.targetVersion.String())
|
|
|
|
log.Info("Found go.sum. version mismatch")
|
|
|
|
setCurrentRepo(repo, "VERY BROKEN", "rewind go.mod commit")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
log.Info("All repos seem okay")
|
|
|
|
})
|
|
|
|
|
2024-01-20 17:17:48 -06:00
|
|
|
group2 := vbox.NewGroup("Debugger")
|
|
|
|
group2.NewButton("logging Window", func() {
|
2024-01-20 16:09:15 -06:00
|
|
|
logsettings.LogWindow()
|
|
|
|
})
|
2024-01-20 17:17:48 -06:00
|
|
|
|
|
|
|
group2.NewButton("Debugger Window", func() {
|
|
|
|
debugger.DebugWindow()
|
|
|
|
})
|
2024-01-16 11:14:30 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func hidePerfect() {
|
2024-01-24 22:22:34 -06:00
|
|
|
for _, repo := range me.allrepos {
|
2024-01-17 03:57:17 -06:00
|
|
|
if repo.dirtyLabel.String() == "PERFECT" {
|
2024-01-16 11:14:30 -06:00
|
|
|
if repo.hidden {
|
|
|
|
continue
|
|
|
|
}
|
2024-01-19 18:37:27 -06:00
|
|
|
repo.Hide()
|
2024-01-16 11:14:30 -06:00
|
|
|
// return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|