314 lines
7.3 KiB
Go
314 lines
7.3 KiB
Go
package main
|
|
|
|
import (
|
|
"os"
|
|
"strings"
|
|
|
|
"go.wit.com/gui"
|
|
"go.wit.com/lib/debugger"
|
|
"go.wit.com/lib/gui/logsettings"
|
|
"go.wit.com/lib/gui/repolist"
|
|
"go.wit.com/log"
|
|
)
|
|
|
|
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
|
|
}
|
|
|
|
// 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
|
|
}
|
|
}
|
|
if me.autoHidePerfect.Checked() {
|
|
if repo.State() == "PERFECT" {
|
|
repo.Hide()
|
|
return
|
|
}
|
|
}
|
|
if me.autoReleased.Checked() {
|
|
if repo.GoState() == "RELEASED" {
|
|
repo.Hide()
|
|
return
|
|
}
|
|
}
|
|
repo.Show()
|
|
}
|
|
|
|
func globalDisplayShow() {
|
|
for _, repo := range me.repos.View.AllRepos() {
|
|
if me.autoHideReadOnly.Checked() {
|
|
if repo.Status.ReadOnly() {
|
|
continue
|
|
}
|
|
}
|
|
if me.autoHidePerfect.Checked() {
|
|
if repo.State() == "PERFECT" {
|
|
continue
|
|
}
|
|
}
|
|
repo.Show()
|
|
}
|
|
}
|
|
|
|
func globalDisplayOptions(box *gui.Node) {
|
|
vbox := box.NewVerticalBox("DISPLAYVBOX")
|
|
|
|
group1 := vbox.NewGroup("Global Display Options")
|
|
|
|
hidegrid := group1.NewGrid("hidecfg", 0, 0)
|
|
|
|
hidegrid.NewButton("Show Repository Window", func() {
|
|
if me.repos.Hidden() {
|
|
me.repos.Show()
|
|
} else {
|
|
me.repos.Hide()
|
|
}
|
|
log.Info("showing reposwin")
|
|
// showHideRepos()
|
|
|
|
// have to run this twice for now
|
|
// scanForReady()
|
|
// scanForReady()
|
|
// findNextDirty("")
|
|
// double check the found next repo
|
|
// fullDoubleCheckFix()
|
|
})
|
|
hidegrid.NextRow()
|
|
|
|
me.autoHideReadOnly = hidegrid.NewCheckbox("Hide read-only repos").SetChecked(true)
|
|
me.autoHideReadOnly.Custom = func() {
|
|
if me.autoHideReadOnly.Checked() {
|
|
// showHideRepos()
|
|
} else {
|
|
globalDisplayShow()
|
|
}
|
|
}
|
|
hidegrid.NextRow()
|
|
|
|
me.autoHidePerfect = hidegrid.NewCheckbox("Hide Perfectly clean repos").SetChecked(true)
|
|
me.autoHidePerfect.Custom = func() {
|
|
log.Info("registered hide function to showHideRepos()")
|
|
me.repos.View.RegisterHideFunction(showHideRepos)
|
|
/*
|
|
if me.autoHidePerfect.Checked() {
|
|
showHideRepos()
|
|
} else {
|
|
globalDisplayShow()
|
|
}
|
|
*/
|
|
}
|
|
hidegrid.NextRow()
|
|
|
|
me.autoReleased = hidegrid.NewCheckbox("Hide RELEASED repos").SetChecked(false)
|
|
me.autoReleased.Custom = func() {
|
|
if me.autoReleased.Checked() {
|
|
for _, repo := range me.repos.View.AllRepos() {
|
|
if repo.GoState() == "RELEASED" {
|
|
repo.Hide()
|
|
}
|
|
}
|
|
} else {
|
|
for _, repo := range me.repos.View.AllRepos() {
|
|
repo.Show()
|
|
}
|
|
}
|
|
}
|
|
hidegrid.NextRow()
|
|
|
|
me.ignoreWhitelist = hidegrid.NewCheckbox("ignore whitelist (are you sure?)").SetChecked(false)
|
|
hidegrid.NextRow()
|
|
|
|
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()
|
|
|
|
grid := group1.NewGrid("test", 0, 0)
|
|
|
|
grid.NewButton("git checkout master", func() {
|
|
setBranchToMaster()
|
|
})
|
|
|
|
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()
|
|
})
|
|
|
|
me.setBranchesToMasterB = grid.NewButton("set all branches to master", func() {
|
|
me.Disable()
|
|
for _, repo := range me.repos.View.AllRepos() {
|
|
if repo.Status.ReadOnly() {
|
|
continue
|
|
}
|
|
if whitelist(repo.GoPath()) {
|
|
continue
|
|
}
|
|
if repo.Status.CheckoutMaster() {
|
|
log.Warn("set master branch worked", repo.Name())
|
|
repo.Status.UpdateNew()
|
|
} else {
|
|
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 = grid.NewButton("redo go.sum", func() {
|
|
os.Unsetenv("GO111MODULE")
|
|
longB.Disable()
|
|
me.Disable()
|
|
for _, repo := range me.repos.View.AllRepos() {
|
|
if whitelist(repo.GoPath()) {
|
|
continue
|
|
}
|
|
if repo.Status.ReadOnly() {
|
|
continue
|
|
}
|
|
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()
|
|
})
|
|
|
|
grid.NewButton("set target version", func() {
|
|
setTargetVersion()
|
|
})
|
|
grid.NextRow()
|
|
|
|
grid.NewButton("rm -f go.mod go.sum", func() {
|
|
me.Disable()
|
|
for _, repo := range me.repos.View.AllRepos() {
|
|
if whitelist(repo.GoPath()) {
|
|
continue
|
|
}
|
|
if repo.Status.ReadOnly() {
|
|
continue
|
|
}
|
|
repo.Status.RunCmd([]string{"rm", "-f", "go.mod", "go.sum"})
|
|
}
|
|
me.Enable()
|
|
})
|
|
|
|
grid.NewButton("git reset --hard", func() {
|
|
me.Disable()
|
|
for _, repo := range me.repos.View.AllRepos() {
|
|
if whitelist(repo.GoPath()) {
|
|
log.Warn("skipping whitelist", repo.Name())
|
|
continue
|
|
}
|
|
log.Warn("running git reset --hard", repo.Name())
|
|
repo.Status.RunCmd([]string{"git", "reset", "--hard"})
|
|
}
|
|
me.Enable()
|
|
})
|
|
|
|
grid.NewButton("git ls-files |grep go.mod", func() {
|
|
// var all []string
|
|
for _, repo := range me.repos.View.AllRepos() {
|
|
log.Info("repo:", repo.Name())
|
|
if repo.Status.ReadOnly() {
|
|
continue
|
|
}
|
|
if whitelist(repo.GoPath()) {
|
|
log.Warn("skipping whitelist", repo.GoPath())
|
|
continue
|
|
}
|
|
good, files := repo.Status.GitLsFiles()
|
|
if !good {
|
|
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?")
|
|
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?")
|
|
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")
|
|
})
|
|
grid.NextRow()
|
|
|
|
grid.NewButton("scanForReady()", func() {
|
|
scanForReady()
|
|
})
|
|
|
|
group2 := vbox.NewGroup("Debugger")
|
|
dbggrid := group2.NewGrid("gdb", 0, 0)
|
|
dbggrid.NewButton("logging Window", func() {
|
|
logsettings.LogWindow()
|
|
})
|
|
dbggrid.NextRow()
|
|
|
|
dbggrid.NewButton("Debugger Window", func() {
|
|
debugger.DebugWindow()
|
|
})
|
|
}
|
|
|
|
func hidePerfect() {
|
|
for _, repo := range me.repos.View.AllRepos() {
|
|
if repo.State() == "PERFECT" {
|
|
if repo.Hidden() {
|
|
continue
|
|
}
|
|
repo.Hide()
|
|
// return
|
|
}
|
|
}
|
|
}
|