2024-01-16 04:46:17 -06:00
|
|
|
// This is a simple example
|
|
|
|
package main
|
|
|
|
|
2024-01-18 00:58:14 -06:00
|
|
|
import (
|
2024-01-16 04:46:17 -06:00
|
|
|
"os"
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"go.wit.com/log"
|
|
|
|
|
2024-01-18 05:03:04 -06:00
|
|
|
"go.wit.com/gui"
|
2024-01-18 22:33:53 -06:00
|
|
|
"go.wit.com/lib/debugger"
|
2024-01-18 00:58:14 -06:00
|
|
|
"go.wit.com/lib/gadgets"
|
2024-01-18 14:46:20 -06:00
|
|
|
"go.wit.com/lib/gui/repostatus"
|
2024-01-16 04:46:17 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
func doesExist(path string) bool {
|
|
|
|
if _, err := os.Stat(path); err != nil {
|
|
|
|
if os.IsNotExist(err) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2024-01-18 16:21:43 -06:00
|
|
|
var quickCmds [][]string
|
|
|
|
var quickCmdLastPath string
|
|
|
|
var quickCmdDoNotRun bool = false
|
|
|
|
|
2024-01-18 13:46:25 -06:00
|
|
|
// only errors on bad errors
|
|
|
|
func quickCmd(fullpath string, cmd []string) bool {
|
|
|
|
var err error
|
|
|
|
var b bool
|
|
|
|
var output string
|
|
|
|
|
2024-01-18 16:21:43 -06:00
|
|
|
if quickCmdLastPath != fullpath {
|
|
|
|
quickCmds = append(quickCmds, []string{"cd", fullpath})
|
|
|
|
quickCmdLastPath = fullpath
|
|
|
|
}
|
|
|
|
quickCmds = append(quickCmds, cmd)
|
2024-01-18 14:21:02 -06:00
|
|
|
log.Warn("RUN:", fullpath, cmd)
|
2024-01-18 16:21:43 -06:00
|
|
|
if quickCmdDoNotRun {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2024-01-18 14:46:20 -06:00
|
|
|
err, b, output = repostatus.RunCmd(fullpath, cmd)
|
2024-01-18 13:46:25 -06:00
|
|
|
if err != nil {
|
2024-01-18 14:21:02 -06:00
|
|
|
log.Error(err)
|
2024-01-18 13:46:25 -06:00
|
|
|
return false
|
2024-01-18 14:46:20 -06:00
|
|
|
} else if !b {
|
2024-01-18 14:21:02 -06:00
|
|
|
log.Warn("b =", b)
|
|
|
|
log.Warn("output =", string(output))
|
2024-01-18 13:46:25 -06:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
log.Warn("output = ", string(output))
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2024-01-16 04:46:17 -06:00
|
|
|
func globalBuildOptions(box *gui.Node) {
|
|
|
|
var setCurrentBranch *gui.Node
|
|
|
|
group1 := box.NewGroup("Global Build Options")
|
|
|
|
groupvbox := group1.NewBox("bw vbox", false)
|
|
|
|
// grouphbox := groupvbox.NewBox("bw hbox", true)
|
|
|
|
|
2024-01-18 00:58:14 -06:00
|
|
|
grid := groupvbox.NewGrid("buildOptions", 2, 1)
|
2024-01-16 04:46:17 -06:00
|
|
|
|
|
|
|
me.mainBranch = gadgets.NewBasicCombobox(grid, "default main branch")
|
2024-01-17 03:57:17 -06:00
|
|
|
me.mainBranch.AddText("guimain")
|
|
|
|
me.mainBranch.AddText("gitea server default")
|
2024-01-16 04:46:17 -06:00
|
|
|
me.mainBranch.Disable()
|
|
|
|
|
|
|
|
me.develBranch = gadgets.NewBasicCombobox(grid, "default devel branch")
|
2024-01-17 03:57:17 -06:00
|
|
|
me.develBranch.AddText("devel")
|
2024-01-16 04:46:17 -06:00
|
|
|
|
|
|
|
me.userBranch = gadgets.NewBasicCombobox(grid, "default user branch")
|
2024-01-17 03:57:17 -06:00
|
|
|
me.userBranch.AddText("jcarr")
|
2024-01-16 04:46:17 -06:00
|
|
|
|
|
|
|
// 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
|
|
|
|
guiBranch := gadgets.NewBasicCombobox(grid, "Set Current Working Branch")
|
2024-01-17 03:57:17 -06:00
|
|
|
guiBranch.AddText("guimaster")
|
|
|
|
guiBranch.AddText("guidevel")
|
|
|
|
guiBranch.AddText("jcarr")
|
2024-01-18 00:58:14 -06:00
|
|
|
guiBranch.Custom = func() {
|
2024-01-17 03:57:17 -06:00
|
|
|
me.toMoveToBranch = guiBranch.String()
|
2024-01-19 18:37:27 -06:00
|
|
|
setCurrentBranch.SetLabel("set all branches to " + me.toMoveToBranch)
|
2024-01-16 04:46:17 -06:00
|
|
|
me.mainBranch.Disable()
|
|
|
|
}
|
2024-01-18 13:46:25 -06:00
|
|
|
|
2024-01-18 16:21:43 -06:00
|
|
|
groupvbox.NewButton("git status", func() {
|
|
|
|
quickCmdDoNotRun = false
|
|
|
|
quickCmdLastPath = "~/go/src"
|
|
|
|
quickCmds = [][]string{}
|
|
|
|
log.Warn("scanning allrepos")
|
|
|
|
for _, path := range me.allrepos {
|
|
|
|
fullpath := "/home/jcarr/go/src/" + path
|
|
|
|
quickCmd(fullpath, []string{"git", "status"})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2024-01-18 13:46:25 -06:00
|
|
|
groupvbox.NewButton("rebuild autotypist", func() {
|
2024-01-18 17:39:38 -06:00
|
|
|
os.Setenv("GO111MODULE", "off")
|
2024-01-18 16:21:43 -06:00
|
|
|
quickCmdDoNotRun = true
|
|
|
|
quickCmdLastPath = "~/go/src"
|
|
|
|
quickCmds = [][]string{}
|
|
|
|
log.Warn("scanning allrepos")
|
2024-01-19 18:37:27 -06:00
|
|
|
fullpath := "/home/jcarr/"
|
|
|
|
quickCmd(fullpath, []string{"mkdir", "-p", "/home/jcarr/go/src/go.wit.com/apps/"})
|
2024-01-18 13:46:25 -06:00
|
|
|
|
2024-01-19 18:37:27 -06:00
|
|
|
fullpath = "/home/jcarr/go/src/go.wit.com/apps/"
|
|
|
|
quickCmd(fullpath, []string{"go", "get", "go.wit.com/apps/autotypist"})
|
2024-01-18 13:46:25 -06:00
|
|
|
fullpath = "/home/jcarr/go/src/go.wit.com/apps/autotypist"
|
2024-01-18 17:39:38 -06:00
|
|
|
quickCmd(fullpath, []string{"go", "get", "-v", "go.wit.com/toolkits/debian"})
|
2024-01-18 13:46:25 -06:00
|
|
|
|
|
|
|
fullpath = "/home/jcarr/go/src/go.wit.com/toolkits/debian"
|
2024-01-19 18:37:27 -06:00
|
|
|
quickCmd(fullpath, []string{"make", "download"})
|
2024-01-18 14:21:02 -06:00
|
|
|
quickCmd(fullpath, []string{"make"})
|
2024-01-18 13:46:25 -06:00
|
|
|
|
2024-01-18 14:21:02 -06:00
|
|
|
fullpath = "/home/jcarr/go/src/go.wit.com/apps/autotypist"
|
2024-01-18 17:39:38 -06:00
|
|
|
quickCmd(fullpath, []string{"go", "get", "-v", "-u", "."})
|
2024-01-19 18:37:27 -06:00
|
|
|
quickCmd(fullpath, []string{"go", "build", "-v", "-x"})
|
2024-01-18 16:21:43 -06:00
|
|
|
me.script = quickCmds
|
|
|
|
setGitCommands()
|
2024-01-18 13:46:25 -06:00
|
|
|
})
|
|
|
|
|
2024-01-19 18:37:27 -06:00
|
|
|
me.rerunGoMod = groupvbox.NewButton("remove all go.mod and go.sum", func() {
|
|
|
|
quickCmdDoNotRun = false
|
2024-01-18 05:03:04 -06:00
|
|
|
log.Warn("scanning allrepos")
|
2024-01-18 14:21:02 -06:00
|
|
|
for _, path := range me.allrepos {
|
2024-01-18 05:03:04 -06:00
|
|
|
fullpath := "/home/jcarr/go/src/" + path
|
2024-01-19 18:37:27 -06:00
|
|
|
quickCmd(fullpath, []string{"rm", "-f", "go.mod", "go.sum"})
|
|
|
|
}
|
|
|
|
})
|
2024-01-18 14:21:02 -06:00
|
|
|
|
2024-01-19 18:37:27 -06:00
|
|
|
me.rerunGoMod = groupvbox.NewButton("re-run go mod & go tidy", func() {
|
|
|
|
quickCmdDoNotRun = false
|
|
|
|
os.Unsetenv("GO111MODULE")
|
|
|
|
log.Warn("scanning allrepos")
|
|
|
|
for _, path := range me.allrepos {
|
|
|
|
fullpath := "/home/jcarr/go/src/" + path
|
2024-01-18 14:21:02 -06:00
|
|
|
quickCmd(fullpath, []string{"go", "mod", "init"})
|
|
|
|
quickCmd(fullpath, []string{"go", "mod", "tidy"})
|
2024-01-18 05:03:04 -06:00
|
|
|
}
|
|
|
|
})
|
2024-01-19 18:37:27 -06:00
|
|
|
|
2024-01-18 00:58:14 -06:00
|
|
|
setCurrentBranch = groupvbox.NewButton("set all branches to", func() {
|
2024-01-18 05:03:04 -06:00
|
|
|
log.Warn("scanning allrepos")
|
|
|
|
for repo, path := range me.allrepos {
|
|
|
|
log.Warn("found repo", repo.String())
|
2024-01-16 04:46:17 -06:00
|
|
|
var changeBranch [][]string
|
|
|
|
changeBranch = append(changeBranch, []string{"cd", "go/src/" + path})
|
|
|
|
changeBranch = append(changeBranch, []string{"git", "checkout", me.toMoveToBranch})
|
|
|
|
me.script = changeBranch
|
|
|
|
setGitCommands()
|
2024-01-18 05:03:04 -06:00
|
|
|
// goMake("--doit")
|
2024-01-16 04:46:17 -06:00
|
|
|
}
|
|
|
|
})
|
|
|
|
var everything *gui.Node
|
2024-01-18 00:58:14 -06:00
|
|
|
everything = groupvbox.NewButton("go get everything on go.wit.com", func() {
|
2024-01-18 22:33:53 -06:00
|
|
|
quickCmdDoNotRun = false
|
|
|
|
quickCmds = [][]string{}
|
2024-01-16 04:46:17 -06:00
|
|
|
var perfect bool = true
|
|
|
|
repos := myrepolist()
|
|
|
|
for _, line := range repos {
|
|
|
|
log.Warn("repo =", line)
|
|
|
|
path, _, _, _ := splitLine(line)
|
|
|
|
path = strings.TrimSpace(path)
|
|
|
|
if path == "#" {
|
|
|
|
// skip comment lines
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if doesExist("/home/jcarr/go/src/" + path) {
|
|
|
|
continue
|
|
|
|
}
|
2024-01-18 22:33:53 -06:00
|
|
|
// attempt to download it
|
|
|
|
quickCmd("/home/jcarr/go/src/go.wit.com", []string{"go", "get", "-v", path})
|
2024-01-16 04:46:17 -06:00
|
|
|
perfect = false
|
|
|
|
}
|
|
|
|
|
|
|
|
if perfect {
|
|
|
|
var notes [][]string
|
|
|
|
notes = append(notes, []string{"you have already downloaded"})
|
|
|
|
notes = append(notes, []string{"everything on go.wit.com"})
|
|
|
|
me.script = notes
|
|
|
|
setGitCommands()
|
|
|
|
doit.Disable()
|
|
|
|
everything.Disable()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2024-01-18 22:33:53 -06:00
|
|
|
me.script = quickCmds
|
2024-01-16 04:46:17 -06:00
|
|
|
doit.Enable()
|
|
|
|
setGitCommands()
|
|
|
|
})
|
2024-01-18 00:58:14 -06:00
|
|
|
groupvbox.NewButton("build all apps", func() {
|
2024-01-16 04:46:17 -06:00
|
|
|
})
|
2024-01-18 22:33:53 -06:00
|
|
|
|
|
|
|
groupvbox.NewButton("Debugger", func() {
|
|
|
|
debugger.DebugWindow(me.myGui)
|
|
|
|
})
|
2024-01-16 04:46:17 -06:00
|
|
|
}
|