From 1c3263638364b85eb023cabad8efda9f5f6cae1f Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Wed, 31 Jan 2024 01:36:54 -0600 Subject: [PATCH] add the dangerous things Signed-off-by: Jeff Carr --- checkReady.go | 2 +- globalDisplayOptions.go | 38 +++++++++++++++++++++++++------------- releaseWindow.go | 38 ++++++-------------------------------- structs.go | 1 + whitelist.go | 36 ++++++++++++++++++++++++++++++++++++ 5 files changed, 69 insertions(+), 46 deletions(-) create mode 100644 whitelist.go diff --git a/checkReady.go b/checkReady.go index b97dce8..a70da6a 100644 --- a/checkReady.go +++ b/checkReady.go @@ -56,7 +56,7 @@ func CheckReady() bool { } testf = filepath.Join(fullpath, "LICENSE") - if ! Exists(testf) { + if !Exists(testf) { log.Info("\trepo is not ready. missing LICENSE") return false } diff --git a/globalDisplayOptions.go b/globalDisplayOptions.go index a73cee2..730e6e6 100644 --- a/globalDisplayOptions.go +++ b/globalDisplayOptions.go @@ -5,6 +5,7 @@ import ( "go.wit.com/gui" "go.wit.com/lib/debugger" "go.wit.com/lib/gui/logsettings" + "go.wit.com/log" // "go.wit.com/gui/gadgets" ) @@ -69,23 +70,16 @@ func globalDisplayOptions(box *gui.Node) { globalDisplayShow() } } + + me.ignoreWhitelist = group1.NewCheckbox("ignore whitelist (are you sure?)").SetChecked(false) + me.scanEveryMinute = group1.NewCheckbox("Scan every minute").SetChecked(false) - /* - group1.NewButton("status.Update() all", func() { - for _, repo := range me.allrepos { - repo.status.Update() - } - }) - - group1.NewButton("rescan all", func() { - for _, repo := range me.allrepos { - repo.newScan() - } - }) - */ group1.NewButton("set all branches to master", func() { for _, repo := range me.allrepos { + if whitelist(repo.String()) { + continue + } if repo.status.CheckoutMaster() { log.Warn("set master branch worked", repo.String) repo.newScan() @@ -96,6 +90,24 @@ func globalDisplayOptions(box *gui.Node) { } }) + group1.NewButton("rm -f go.mod go.sum", func() { + for _, repo := range me.allrepos { + if whitelist(repo.String()) { + continue + } + repo.status.RunCmd([]string{"rm", "-f", "go.mod", "go.sum"}) + } + }) + + group1.NewButton("git reset --hard", func() { + for _, repo := range me.allrepos { + if whitelist(repo.String()) { + continue + } + repo.status.RunCmd([]string{"git", "reset", "--hard"}) + } + }) + group2 := vbox.NewGroup("Debugger") group2.NewButton("logging Window", func() { logsettings.LogWindow() diff --git a/releaseWindow.go b/releaseWindow.go index 0fe2ad8..25ce976 100644 --- a/releaseWindow.go +++ b/releaseWindow.go @@ -40,7 +40,7 @@ type releaseStruct struct { makeRedomodB *gui.Node sendVersionB *gui.Node checkSafeB *gui.Node - whitelist map[string]*repo + whitelist map[string]*repo } func (w *autoType) Disable() { @@ -51,17 +51,6 @@ func (w *autoType) Enable() { w.mainWindow.Enable() } -func whitelist(path string) bool { - // log.Info("whitelist START", path) - _, ok := release.whitelist[path] - if ok { - // log.Info("whitelist ok == true", path) - return true - } - // log.Info("whitelist ok == false", path) - return false -} - func createReleaseBox(box *gui.Node) { release.versionS = "0.17.0" release.reasonS = "gocui" @@ -361,30 +350,15 @@ func setCurrentRepo(newcur *repo, s string, note string) bool { release.openrepo.Enable() /* - if newcur.status.ReadOnly() { - release.readOnly.SetValue("true ro") - } else { - release.readOnly.SetValue("false ro") - } + if newcur.status.ReadOnly() { + release.readOnly.SetValue("true ro") + } else { + release.readOnly.SetValue("false ro") + } */ return true } -func initWhitelist() { - release.whitelist = make(map[string]*repo) - for _, repo := range me.allrepos { - if strings.HasPrefix(repo.String(), "go.wit.com/dev/") { - release.whitelist[repo.String()] = repo - } - if repo.String() == "go.wit.com/apps/guireleaser" { - release.whitelist[repo.String()] = repo - } - if repo.String() == "go.wit.com/lib/gui/repostatus" { - release.whitelist[repo.String()] = repo - } - } -} - func scanForReady() bool { for _, repo := range me.allrepos { goSumS := repo.getGoSumStatus() diff --git a/structs.go b/structs.go index a7aba2a..bb03c2d 100644 --- a/structs.go +++ b/structs.go @@ -26,6 +26,7 @@ type autoType struct { // #### autotypist Global Display Options autoHidePerfect *gui.Node autoHideReadOnly *gui.Node + ignoreWhitelist *gui.Node // #### autotypist Global Build Options // what to change all the branches to diff --git a/whitelist.go b/whitelist.go new file mode 100644 index 0000000..bebef43 --- /dev/null +++ b/whitelist.go @@ -0,0 +1,36 @@ +// This is a simple example +package main + +import ( + "strings" +) + +func initWhitelist() { + release.whitelist = make(map[string]*repo) + for _, repo := range me.allrepos { + if strings.HasPrefix(repo.String(), "go.wit.com/dev/") { + release.whitelist[repo.String()] = repo + } + if repo.String() == "go.wit.com/apps/guireleaser" { + release.whitelist[repo.String()] = repo + } + if repo.String() == "go.wit.com/lib/gui/repostatus" { + release.whitelist[repo.String()] = repo + } + } +} + +func whitelist(path string) bool { + // log.Info("whitelist START", path) + if me.ignoreWhitelist.Checked() { + return true + } + + _, ok := release.whitelist[path] + if ok { + // log.Info("whitelist ok == true", path) + return true + } + // log.Info("whitelist ok == false", path) + return false +}