220 lines
5.0 KiB
Go
220 lines
5.0 KiB
Go
// This is a simple example
|
|
package main
|
|
|
|
import (
|
|
"os"
|
|
"strings"
|
|
|
|
"go.wit.com/gui"
|
|
"go.wit.com/lib/debugger"
|
|
"go.wit.com/lib/gui/logsettings"
|
|
"go.wit.com/log"
|
|
// "go.wit.com/gui/gadgets"
|
|
)
|
|
|
|
func showHideRepos() {
|
|
for _, repo := range me.allrepos {
|
|
if me.autoHideReadOnly.Checked() {
|
|
if repo.status.ReadOnly() {
|
|
repo.Hide()
|
|
continue
|
|
}
|
|
}
|
|
if me.autoHidePerfect.Checked() {
|
|
if repo.dirtyLabel.String() == "PERFECT" {
|
|
repo.Hide()
|
|
continue
|
|
}
|
|
}
|
|
repo.Show()
|
|
}
|
|
}
|
|
|
|
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()
|
|
}
|
|
}
|
|
|
|
func globalDisplayOptions(box *gui.Node) {
|
|
vbox := box.NewVerticalBox("DISPLAYVBOX")
|
|
|
|
group1 := vbox.NewGroup("Global Display Options")
|
|
|
|
group1.NewButton("Show Repository Window", func() {
|
|
showHideRepos()
|
|
scanForReady()
|
|
scanForReady()
|
|
reposwin.Toggle()
|
|
findNextDirty("")
|
|
})
|
|
|
|
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.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()
|
|
for _, repo := range me.allrepos {
|
|
if whitelist(repo.String()) {
|
|
continue
|
|
}
|
|
if repo.status.CheckoutMaster() {
|
|
log.Warn("set master branch worked", repo.String())
|
|
repo.newScan()
|
|
} else {
|
|
log.Warn("set master branch failed", repo.String())
|
|
repo.newScan()
|
|
me.Enable()
|
|
return
|
|
}
|
|
}
|
|
me.Enable()
|
|
me.setBranchesToMasterB.Disable()
|
|
})
|
|
|
|
var longB *gui.Node
|
|
longB = group1.NewButton("redo go.sum", func() {
|
|
os.Unsetenv("GO111MODULE")
|
|
longB.Disable()
|
|
me.Disable()
|
|
for _, repo := range me.allrepos {
|
|
if whitelist(repo.String()) {
|
|
continue
|
|
}
|
|
if repo.status.ReadOnly() {
|
|
continue
|
|
}
|
|
if repo.status.MakeRedomod() {
|
|
log.Info("redo go.sum failed on", repo.String())
|
|
// me.Enable()
|
|
// longB.Enable()
|
|
// longB.SetLabel("FAILED")
|
|
// return
|
|
}
|
|
}
|
|
log.Info("redo go.sum finished ok!")
|
|
me.Enable()
|
|
longB.Enable()
|
|
})
|
|
|
|
group1.NewButton("rm -f go.mod go.sum", func() {
|
|
me.Disable()
|
|
for _, repo := range me.allrepos {
|
|
if whitelist(repo.String()) {
|
|
continue
|
|
}
|
|
if repo.status.ReadOnly() {
|
|
continue
|
|
}
|
|
repo.status.RunCmd([]string{"rm", "-f", "go.mod", "go.sum"})
|
|
}
|
|
me.Enable()
|
|
})
|
|
|
|
group1.NewButton("git reset --hard", func() {
|
|
me.Disable()
|
|
for _, repo := range me.allrepos {
|
|
if whitelist(repo.String()) {
|
|
log.Warn("skipping whitelist", repo.String())
|
|
continue
|
|
}
|
|
log.Warn("running git reset --hard", repo.String())
|
|
repo.status.RunCmd([]string{"git", "reset", "--hard"})
|
|
}
|
|
me.Enable()
|
|
})
|
|
|
|
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")
|
|
})
|
|
|
|
group2 := vbox.NewGroup("Debugger")
|
|
group2.NewButton("logging Window", func() {
|
|
logsettings.LogWindow()
|
|
})
|
|
|
|
group2.NewButton("Debugger Window", func() {
|
|
debugger.DebugWindow()
|
|
})
|
|
}
|
|
|
|
func hidePerfect() {
|
|
for _, repo := range me.allrepos {
|
|
if repo.dirtyLabel.String() == "PERFECT" {
|
|
if repo.hidden {
|
|
continue
|
|
}
|
|
repo.Hide()
|
|
// return
|
|
}
|
|
}
|
|
}
|