2024-01-16 04:46:17 -06:00
|
|
|
package main
|
|
|
|
|
2024-01-18 00:58:14 -06:00
|
|
|
import (
|
2024-01-16 04:46:17 -06:00
|
|
|
"os"
|
2024-01-30 17:22:46 -06:00
|
|
|
"os/user"
|
2024-01-26 14:21:05 -06:00
|
|
|
"path/filepath"
|
2024-01-16 04:46:17 -06:00
|
|
|
|
|
|
|
"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-02-13 12:54:32 -06:00
|
|
|
// if me.autoWorkingPwd.String() != fullpath {
|
|
|
|
// me.autoWorkingPwd.SetValue(fullpath)
|
|
|
|
// }
|
2024-01-25 13:09:33 -06:00
|
|
|
|
2024-01-23 11:22:33 -06:00
|
|
|
if me.autoDryRun.Checked() {
|
2024-01-25 13:09:33 -06:00
|
|
|
log.Warn("RUN --dry-run", fullpath, cmd)
|
2024-01-18 16:21:43 -06:00
|
|
|
return false
|
2024-01-25 13:09:33 -06:00
|
|
|
} else {
|
|
|
|
log.Warn("RUN:", fullpath, cmd)
|
2024-01-18 16:21:43 -06:00
|
|
|
}
|
|
|
|
|
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-27 14:40:17 -06:00
|
|
|
log.Warn("cmd =", cmd)
|
|
|
|
log.Warn("err =", err)
|
|
|
|
log.Warn("b =", b)
|
|
|
|
log.Warn("output =", string(output))
|
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-02-12 15:24:35 -06:00
|
|
|
func globalBuildOptions(vbox *gui.Node) {
|
2024-01-20 17:17:48 -06:00
|
|
|
group1 := vbox.NewGroup("Global Build Options")
|
|
|
|
grid := group1.NewGrid("buildOptions", 2, 1)
|
2024-01-16 04:46:17 -06:00
|
|
|
|
2024-02-13 09:18:04 -06:00
|
|
|
// me.autoWorkingPwd = gadgets.NewOneLiner(grid, "working directory (pwd)")
|
2024-01-30 23:38:46 -06:00
|
|
|
me.userHomePwd = gadgets.NewOneLiner(grid, "user home")
|
|
|
|
me.goSrcPwd = gadgets.NewOneLiner(grid, "go src home")
|
|
|
|
|
|
|
|
usr, _ := user.Current()
|
|
|
|
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)
|
|
|
|
|
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-30 17:22:46 -06:00
|
|
|
me.userBranch.AddText(usr.Username)
|
2024-01-16 04:46:17 -06:00
|
|
|
|
2024-01-31 00:19:21 -06:00
|
|
|
var newBranch *gui.Node
|
|
|
|
var setBranchB *gui.Node
|
|
|
|
|
2024-01-23 11:48:08 -06:00
|
|
|
// 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-31 00:19:21 -06:00
|
|
|
setBranchB = grid.NewButton("set current branch to:", func() {
|
2024-01-23 11:48:08 -06:00
|
|
|
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()
|
|
|
|
*/
|
2024-01-31 00:19:21 -06:00
|
|
|
for _, repo := range me.allrepos {
|
|
|
|
if repo.status.CheckoutMaster() {
|
|
|
|
log.Warn("set master branch worked", repo.String)
|
|
|
|
repo.newScan()
|
|
|
|
} else {
|
|
|
|
log.Warn("set master branch failed", repo.String)
|
|
|
|
repo.newScan()
|
|
|
|
}
|
|
|
|
// return
|
|
|
|
}
|
2024-01-20 17:17:48 -06:00
|
|
|
})
|
|
|
|
newBranch = grid.NewCombobox()
|
2024-01-23 11:48:08 -06:00
|
|
|
newBranch.AddText("master")
|
2024-01-30 17:22:46 -06:00
|
|
|
newBranch.AddText("devel")
|
|
|
|
newBranch.AddText(usr.Username)
|
|
|
|
newBranch.SetText(usr.Username)
|
2024-01-31 08:47:08 -06:00
|
|
|
newBranch.Custom = func() {
|
2024-01-31 00:19:21 -06:00
|
|
|
setBranchB.SetLabel("set current branches to " + newBranch.String())
|
|
|
|
}
|
2024-01-16 04:46:17 -06:00
|
|
|
}
|