summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-01-30 13:52:27 -0600
committerJeff Carr <[email protected]>2024-01-30 13:52:27 -0600
commit9d7620df62adf0c35f27b0304cace077f8a9a7ad (patch)
treedd8d83ceaa30f03bdde20bea8550bb0dd4113df1
parent0ca10f55534c057c651d136c89d096224a6f6461 (diff)
more code cleanup
Signed-off-by: Jeff Carr <[email protected]>
-rw-r--r--globalBuildOptions.go164
-rw-r--r--quickCmd.go52
-rw-r--r--releaseWindow.go2
3 files changed, 53 insertions, 165 deletions
diff --git a/globalBuildOptions.go b/globalBuildOptions.go
deleted file mode 100644
index 043892e..0000000
--- a/globalBuildOptions.go
+++ /dev/null
@@ -1,164 +0,0 @@
-// This is a simple example
-package main
-
-import (
- "os"
- "path/filepath"
-
- "go.wit.com/log"
-
- "go.wit.com/gui"
- "go.wit.com/lib/gadgets"
- "go.wit.com/lib/gui/repostatus"
-)
-
-func doesExist(path string) bool {
- if _, err := os.Stat(path); err != nil {
- if os.IsNotExist(err) {
- return false
- }
- }
- return true
-}
-
-// only errors on bad errors
-func quickCmd(fullpath string, cmd []string) bool {
- var err error
- var b bool
- var output string
-
- if me.autoWorkingPwd.String() != fullpath {
- me.autoWorkingPwd.SetValue(fullpath)
- }
-
- if me.autoDryRun.Checked() {
- log.Warn("RUN --dry-run", fullpath, cmd)
- return false
- } else {
- log.Warn("RUN:", fullpath, cmd)
- }
-
- err, b, output = repostatus.RunCmd(fullpath, cmd)
- if err != nil {
- log.Warn("cmd =", cmd)
- log.Warn("err =", err)
- log.Warn("b =", b)
- log.Warn("output =", string(output))
- return false
- } else if !b {
- log.Warn("b =", b)
- log.Warn("output =", string(output))
- return true
- }
- log.Warn("output = ", string(output))
- return true
-}
-
-func globalBuildOptions(box *gui.Node) {
- vbox := box.NewVerticalBox("DISPLAYVBOX")
- group1 := vbox.NewGroup("Global Build Options")
- grid := group1.NewGrid("buildOptions", 2, 1)
-
- me.mainBranch = gadgets.NewBasicCombobox(grid, "default main branch")
- me.mainBranch.AddText("gitea server default")
- me.mainBranch.Disable()
-
- me.develBranch = gadgets.NewBasicCombobox(grid, "default devel branch")
- me.develBranch.AddText("devel")
-
- me.userBranch = gadgets.NewBasicCombobox(grid, "default user branch")
- me.userBranch.AddText("jcarr")
-
- grid.NewLabel("<nil>")
- grid.NewButton("set working branches", func() {
- log.Warn("set working branches here")
- })
- // gadgets.OneLiner(grid, "default user branch")
-
- // select the branch you want to test, build and develop against
- // this lets you select your user branch, but, when you are happy
- // you can merge everything into the devel branch and make sure it actually
- // works. Then, when that is good, merge and version everything in master
- var newBranch *gui.Node
- grid.NewButton("set current branch to:", func() {
- log.Warn("set current branch to:", newBranch.String())
- /*
- me.toMoveToBranch = guiBranch.String()
- setCurrentBranch.SetLabel("set all branches to " + me.toMoveToBranch)
- me.mainBranch.Disable()
- */
- })
- newBranch = grid.NewCombobox()
- newBranch.AddText("guimaster")
- newBranch.AddText("master")
- newBranch.AddText("main")
- newBranch.AddText("guidevel")
- newBranch.AddText("jcarr")
- newBranch.SetText("jcarr")
-
- me.autoWorkingPwd = gadgets.NewOneLiner(grid, "working directory (pwd)")
- me.userHomePwd = gadgets.NewOneLiner(grid, "user home")
- me.goSrcPwd = gadgets.NewOneLiner(grid, "go src home")
-
- homeDir, err := os.UserHomeDir()
- if err != nil {
- log.Warn("Error getting home directory:", err)
- homeDir = "/home/autotypist"
- }
- me.userHomePwd.SetText(homeDir)
- srcDir := filepath.Join(homeDir, "go/src")
- me.goSrcPwd.SetText(srcDir)
-
- group2 := vbox.NewGroup("Run in every git repository")
- me.stopOnErrors = group2.NewCheckbox("Stop on errors")
- me.stopOnErrors.SetChecked(true)
-
- me.autoDryRun = group2.NewCheckbox("autotypist --dry-run")
- me.autoDryRun.SetChecked(true)
-
- group2.NewButton("parse .git/config ScanGitConfig()", func() {
- repostatus.ScanGitConfig()
- })
-
- group2.NewButton("parse go.sum ScanGoSrc()", func() {
- repostatus.ScanGoSrc()
- })
-
- group2.NewButton("run git status", func() {
- me.autoWorkingPwd.SetValue("~/go/src")
- log.Warn("scanning allrepos")
- for path, _ := range me.allrepos {
- fullpath := "/home/jcarr/go/src/" + path
- quickCmd(fullpath, []string{"git", "status"})
- }
- })
-
- me.rerunGoMod = group2.NewButton("remove go.mod & go.sum", func() {
- for path, _ := range me.allrepos {
- fullpath := "/home/jcarr/go/src/" + path
- if quickCmd(fullpath, []string{"rm", "-f", "go.mod", "go.sum"}) {
- log.Info("rm go.mod FAILED in repo", fullpath, me.stopOnErrors.Bool())
- if me.stopOnErrors.Bool() {
- return
- }
- }
- }
- })
-
- me.rerunGoMod = group2.NewButton("run go mod & go tidy", func() {
- os.Unsetenv("GO111MODULE")
- for path, _ := range me.allrepos {
- fullpath := "/home/jcarr/go/src/" + path
- quickCmd(fullpath, []string{"go", "mod", "init"})
- quickCmd(fullpath, []string{"go", "mod", "tidy"})
- }
- })
-
- me.rerunGoMod = group2.NewButton("git checkout go.mod & go.sum", func() {
- for path, _ := range me.allrepos {
- fullpath := "/home/jcarr/go/src/" + path
- quickCmd(fullpath, []string{"git", "checkout", "go.mod"})
- quickCmd(fullpath, []string{"git", "checkout", "go.sum"})
- }
- })
-}
diff --git a/quickCmd.go b/quickCmd.go
new file mode 100644
index 0000000..2f250af
--- /dev/null
+++ b/quickCmd.go
@@ -0,0 +1,52 @@
+// This is a simple example
+package main
+
+import (
+ "os"
+
+ "go.wit.com/log"
+
+ "go.wit.com/lib/gui/repostatus"
+)
+
+func doesExist(path string) bool {
+ if _, err := os.Stat(path); err != nil {
+ if os.IsNotExist(err) {
+ return false
+ }
+ }
+ return true
+}
+
+// only errors on bad errors
+func quickCmd(fullpath string, cmd []string) bool {
+ var err error
+ var b bool
+ var output string
+
+ if me.autoWorkingPwd.String() != fullpath {
+ me.autoWorkingPwd.SetValue(fullpath)
+ }
+
+ if me.autoDryRun.Checked() {
+ log.Warn("RUN --dry-run", fullpath, cmd)
+ return false
+ } else {
+ log.Warn("RUN:", fullpath, cmd)
+ }
+
+ err, b, output = repostatus.RunCmd(fullpath, cmd)
+ if err != nil {
+ log.Warn("cmd =", cmd)
+ log.Warn("err =", err)
+ log.Warn("b =", b)
+ log.Warn("output =", string(output))
+ return false
+ } else if !b {
+ log.Warn("b =", b)
+ log.Warn("output =", string(output))
+ return true
+ }
+ log.Warn("output = ", string(output))
+ return true
+}
diff --git a/releaseWindow.go b/releaseWindow.go
index 19ada35..d168374 100644
--- a/releaseWindow.go
+++ b/releaseWindow.go
@@ -92,7 +92,7 @@ func createReleaseWindow() {
repo := me.allrepos[path]
// mt.Printf("%s: %s\n", key, myMap[key])
- //// for _, repo := range me.allrepos {
+ //// for _, repo := range me.allrepos {
// goSumS := repo.getGoSumStatus()
// dirtyS := repo.dirtyLabel.String()