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"
|
|
|
|
|
|
|
|
"go.wit.com/log"
|
|
|
|
|
2024-01-18 05:03:04 -06:00
|
|
|
"go.wit.com/gui"
|
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 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-23 11:22:33 -06:00
|
|
|
if me.autoWorkingPwd.String() != fullpath {
|
|
|
|
me.autoWorkingPwd.SetValue(fullpath)
|
2024-01-18 16:21:43 -06:00
|
|
|
}
|
2024-01-18 14:21:02 -06:00
|
|
|
log.Warn("RUN:", fullpath, cmd)
|
2024-01-23 11:22:33 -06:00
|
|
|
if me.autoDryRun.Checked() {
|
2024-01-18 16:21:43 -06:00
|
|
|
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) {
|
2024-01-20 17:17:48 -06:00
|
|
|
vbox := box.NewVerticalBox("DISPLAYVBOX")
|
|
|
|
group1 := vbox.NewGroup("Global Build Options")
|
|
|
|
grid := group1.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("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
|
|
|
|
2024-01-23 11:48:08 -06:00
|
|
|
grid.NewLabel("<nil>")
|
|
|
|
grid.NewButton("set working branches", func() {
|
|
|
|
log.Warn("set working branches here")
|
|
|
|
})
|
|
|
|
// gadgets.OneLiner(grid, "default user branch")
|
|
|
|
|
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
|
2024-01-20 17:17:48 -06:00
|
|
|
var newBranch *gui.Node
|
2024-01-23 11:48:08 -06:00
|
|
|
grid.NewButton("set current branch to:", func() {
|
|
|
|
log.Warn("set current branch to:", newBranch.String())
|
2024-01-20 17:17:48 -06:00
|
|
|
/*
|
|
|
|
me.toMoveToBranch = guiBranch.String()
|
|
|
|
setCurrentBranch.SetLabel("set all branches to " + me.toMoveToBranch)
|
|
|
|
me.mainBranch.Disable()
|
|
|
|
*/
|
|
|
|
})
|
|
|
|
newBranch = grid.NewCombobox()
|
|
|
|
newBranch.AddText("guimaster")
|
2024-01-23 11:48:08 -06:00
|
|
|
newBranch.AddText("master")
|
|
|
|
newBranch.AddText("main")
|
2024-01-20 17:17:48 -06:00
|
|
|
newBranch.AddText("guidevel")
|
|
|
|
newBranch.AddText("jcarr")
|
|
|
|
newBranch.SetText("jcarr")
|
|
|
|
|
2024-01-23 11:22:33 -06:00
|
|
|
me.autoWorkingPwd = gadgets.NewOneLiner(grid, "working directory (pwd)")
|
|
|
|
|
2024-01-20 17:17:48 -06:00
|
|
|
group2 := vbox.NewGroup("Run in every git repository")
|
2024-01-20 18:45:55 -06:00
|
|
|
me.stopOnErrors = group2.NewCheckbox("Stop on errors")
|
|
|
|
me.stopOnErrors.SetChecked(true)
|
|
|
|
|
2024-01-23 11:22:33 -06:00
|
|
|
me.autoDryRun = group2.NewCheckbox("autotypist --dry-run")
|
|
|
|
me.autoDryRun.SetChecked(true)
|
|
|
|
|
2024-01-20 18:45:55 -06:00
|
|
|
group2.NewButton("run git status", func() {
|
2024-01-23 11:22:33 -06:00
|
|
|
me.autoWorkingPwd.SetValue("~/go/src")
|
2024-01-18 16:21:43 -06:00
|
|
|
log.Warn("scanning allrepos")
|
|
|
|
for _, path := range me.allrepos {
|
|
|
|
fullpath := "/home/jcarr/go/src/" + path
|
|
|
|
quickCmd(fullpath, []string{"git", "status"})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2024-01-20 17:17:48 -06:00
|
|
|
me.rerunGoMod = group2.NewButton("remove go.mod & go.sum", func() {
|
2024-01-20 18:45:55 -06:00
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-01-18 13:46:25 -06:00
|
|
|
})
|
|
|
|
|
2024-01-20 17:17:48 -06:00
|
|
|
me.rerunGoMod = group2.NewButton("run go mod & go tidy", func() {
|
2024-01-19 18:37:27 -06:00
|
|
|
os.Unsetenv("GO111MODULE")
|
|
|
|
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-20 18:45:55 -06:00
|
|
|
|
|
|
|
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"})
|
|
|
|
}
|
|
|
|
})
|
2024-01-16 04:46:17 -06:00
|
|
|
}
|