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-16 04:46:17 -06:00
|
|
|
)
|
|
|
|
|
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")
|
2024-02-16 17:55:53 -06:00
|
|
|
grid := group1.NewGrid("buildOptions", 0, 0)
|
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")
|
2024-02-16 17:55:53 -06:00
|
|
|
grid.NextRow()
|
2024-01-30 23:38:46 -06:00
|
|
|
me.goSrcPwd = gadgets.NewOneLiner(grid, "go src home")
|
2024-02-16 17:55:53 -06:00
|
|
|
grid.NextRow()
|
2024-01-30 23:38:46 -06:00
|
|
|
|
|
|
|
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-02-24 11:54:47 -06:00
|
|
|
grid.NextRow()
|
|
|
|
|
2024-11-13 11:56:58 -06:00
|
|
|
me.stopOnErrors = grid.NewCheckbox("Stop on errors").SetChecked(true)
|
|
|
|
grid.NextRow()
|
|
|
|
|
|
|
|
me.autoDryRun = grid.NewCheckbox("autotypist --dry-run")
|
|
|
|
me.autoDryRun.Custom = func() {
|
|
|
|
if me.autoDryRun.Checked() {
|
|
|
|
os.Setenv("REPO_DRYRUN", "on")
|
|
|
|
} else {
|
|
|
|
os.Setenv("REPO_DRYRUN", "off")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
me.autoDryRun.SetChecked(true)
|
|
|
|
grid.NextRow()
|
|
|
|
|
2024-02-24 11:54:47 -06:00
|
|
|
grid.NewGroup("git checkout")
|
|
|
|
// checking this will automatically make the branches off of devel
|
|
|
|
grid.NextRow()
|
2024-11-13 11:56:58 -06:00
|
|
|
me.autoCreateBranches = grid.NewCheckbox("auto-create {devel,user} branches").SetChecked(true)
|
2024-02-25 13:09:56 -06:00
|
|
|
me.autoCreateBranches.Custom = func() {
|
|
|
|
if me.autoCreateBranches.Checked() {
|
|
|
|
os.Setenv("AUTOTYPIST_CREATE_BRANCHES", "on")
|
|
|
|
} else {
|
|
|
|
os.Unsetenv("AUTOTYPIST_CREATE_BRANCHES")
|
|
|
|
}
|
|
|
|
}
|
2024-02-24 11:54:47 -06:00
|
|
|
grid.NextRow()
|
|
|
|
|
2024-11-13 11:56:58 -06:00
|
|
|
grid.NewButton("git checkout master branch", func() {
|
2024-02-25 13:09:56 -06:00
|
|
|
me.repos.View.ArgCheckoutMaster()
|
2024-02-24 11:54:47 -06:00
|
|
|
})
|
2024-11-13 11:56:58 -06:00
|
|
|
grid.NewLabel("") // set the order of these in the config file
|
2024-02-24 11:54:47 -06:00
|
|
|
grid.NextRow()
|
|
|
|
|
2024-11-13 11:56:58 -06:00
|
|
|
grid.NewButton("git checkout devel branch", func() {
|
2024-02-24 11:54:47 -06:00
|
|
|
me.repos.View.ArgCheckoutDevel()
|
|
|
|
})
|
2024-11-13 11:56:58 -06:00
|
|
|
grid.NewLabel("") // set the order of these in the config file
|
2024-02-24 11:54:47 -06:00
|
|
|
grid.NextRow()
|
2024-01-30 23:38:46 -06:00
|
|
|
|
2024-11-13 11:56:58 -06:00
|
|
|
grid.NewButton("git checkout "+usr.Username+" branch", func() {
|
2024-02-24 11:54:47 -06:00
|
|
|
me.repos.View.ArgCheckoutUser()
|
|
|
|
})
|
2024-11-13 11:56:58 -06:00
|
|
|
grid.NewLabel("")
|
2024-02-24 11:54:47 -06:00
|
|
|
grid.NextRow()
|
2024-02-25 13:09:56 -06:00
|
|
|
|
|
|
|
// select the branches you want to test, build and develop against
|
|
|
|
// let's call this the 'mode' ?
|
2024-01-16 04:46:17 -06:00
|
|
|
// 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-11-04 03:23:28 -06:00
|
|
|
/*
|
|
|
|
if repo.Status.BranchExists(targetName) {
|
|
|
|
ok := repo.Status.CheckoutBranch(targetName)
|
|
|
|
if ok {
|
|
|
|
// checkout went fine
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
log.Info("couldn't set", repo.Status.Path(), "branch to", targetName)
|
|
|
|
log.Info("but branch exists so something went wrong")
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if !me.autoCreateBranches.Checked() {
|
|
|
|
log.Info("not auto creating branch", targetName)
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
// branch doesn't exist. make it
|
|
|
|
// todo: make this branch from 'devel' branch if it exists
|
|
|
|
log.Info("should make the", targetName, "branch here!")
|
|
|
|
if me.autoCreateBranches.Checked() {
|
|
|
|
log.Info("going to make the branch!")
|
|
|
|
repo.Status.RunCmd([]string{"git", "branch", targetName})
|
|
|
|
repo.Status.RunCmd([]string{"git", "checkout", targetName})
|
|
|
|
} else {
|
|
|
|
log.Info("not auto creating branch", targetName)
|
|
|
|
}
|
|
|
|
repo.Scan()
|
|
|
|
count += 1
|
|
|
|
*/
|
2024-02-16 17:55:53 -06:00
|
|
|
|
|
|
|
grid.NextRow()
|
2024-02-29 17:29:19 -06:00
|
|
|
|
|
|
|
grid.NewGroup("update from upstream")
|
2024-03-02 07:44:18 -06:00
|
|
|
grid.NextRow()
|
2024-11-13 11:56:58 -06:00
|
|
|
grid.NewButton("git pull", func() {
|
|
|
|
me.Disable()
|
|
|
|
defer me.Enable()
|
|
|
|
loop := me.repos.View.ReposSortByName()
|
|
|
|
for loop.Scan() {
|
|
|
|
repo := loop.Repo()
|
|
|
|
repo.Run([]string{"git", "pull"})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
grid.NextRow()
|
|
|
|
|
|
|
|
// TODO: fix this
|
|
|
|
grid.NewButton("git fetch", func() {
|
2024-02-25 09:43:11 -06:00
|
|
|
me.Disable()
|
|
|
|
defer me.Enable()
|
|
|
|
log.Warn("updating all master branches")
|
|
|
|
var count, failed int
|
2024-11-13 11:56:58 -06:00
|
|
|
loop := me.repos.View.ReposSortByName()
|
|
|
|
for loop.Scan() {
|
|
|
|
repo := loop.Repo()
|
2024-02-25 09:43:11 -06:00
|
|
|
var err error
|
|
|
|
var out string
|
|
|
|
count += 1
|
|
|
|
if err, out = repo.Status.FetchMaster(); err != nil {
|
|
|
|
log.Warn(repo.Name(), "fetch failed", err, out)
|
|
|
|
failed += 1
|
|
|
|
} else {
|
|
|
|
log.Warn(repo.Name(), "fetch sent:", out)
|
|
|
|
}
|
|
|
|
if err, out = repo.Status.FetchDevel(); err != nil {
|
|
|
|
log.Warn(repo.Name(), "fetch failed", err, out)
|
|
|
|
failed += 1
|
|
|
|
} else {
|
|
|
|
log.Warn(repo.Name(), "fetch sent:", out)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
log.Warn("updated all master branches", count, "failed =", failed)
|
|
|
|
})
|
2024-11-13 11:56:58 -06:00
|
|
|
grid.NextRow()
|
2024-02-20 10:58:58 -06:00
|
|
|
|
2024-11-13 11:56:58 -06:00
|
|
|
me.autoRebuildButton = grid.NewButton("rebuild autotypist", func() {
|
|
|
|
me.autoRebuildButton.Disable()
|
|
|
|
me.autoRebuildButton.SetLabel("running....")
|
|
|
|
attemptAutoRebuild()
|
|
|
|
me.autoRebuildButton.Enable()
|
|
|
|
me.autoRebuildButton.SetLabel("rebuild autotypist")
|
2024-02-20 10:58:58 -06:00
|
|
|
})
|
2024-11-13 11:56:58 -06:00
|
|
|
grid.NextRow()
|
2024-02-20 10:58:58 -06:00
|
|
|
|
2024-11-13 11:56:58 -06:00
|
|
|
|
|
|
|
grid.NewButton("go build", func() {
|
2024-02-20 10:58:58 -06:00
|
|
|
me.Disable()
|
|
|
|
defer me.Enable()
|
2024-11-13 11:56:58 -06:00
|
|
|
// r.showApps()
|
|
|
|
loop := me.repos.View.ReposSortByName()
|
|
|
|
for loop.Scan() {
|
|
|
|
repo := loop.Repo()
|
|
|
|
if repo.Hidden() {
|
|
|
|
// log.Info("skip hidden", repo.String())
|
2024-02-20 10:58:58 -06:00
|
|
|
} else {
|
2024-11-13 11:56:58 -06:00
|
|
|
log.Info("try to build", repo.Name())
|
|
|
|
if repo.Status.Build() {
|
|
|
|
log.Info("build worked", repo.Name())
|
|
|
|
} else {
|
|
|
|
log.Info("build failed", repo.Name())
|
|
|
|
go repo.Status.Xterm("bash")
|
|
|
|
return
|
|
|
|
}
|
2024-02-20 10:58:58 -06:00
|
|
|
}
|
|
|
|
}
|
2024-11-13 11:56:58 -06:00
|
|
|
log.Info("")
|
|
|
|
log.Info("every build worked !!!")
|
|
|
|
log.Info("")
|
2024-02-20 10:58:58 -06:00
|
|
|
})
|
2024-11-13 11:56:58 -06:00
|
|
|
grid.NextRow()
|
|
|
|
}
|
2024-02-20 10:58:58 -06:00
|
|
|
|
2024-11-13 11:56:58 -06:00
|
|
|
// this code isn't ready yet
|
|
|
|
/*
|
2024-02-20 10:58:58 -06:00
|
|
|
s.checkB = s.grid.NewButton("Check repos are working", func() {
|
|
|
|
me.Disable()
|
|
|
|
defer me.Enable()
|
2024-11-13 11:56:58 -06:00
|
|
|
for loop.Scan() {
|
2024-02-20 10:58:58 -06:00
|
|
|
if repo.GitURL() != "" {
|
|
|
|
log.Info("repo already checked. do they match?")
|
|
|
|
log.Info("go.wit.com =", repo.GoURL())
|
|
|
|
log.Info("localurl =", repo.Path())
|
|
|
|
} else {
|
|
|
|
ok, giturl := gowit.CheckRegistered(repo)
|
|
|
|
if ok {
|
|
|
|
log.Info("is url correct?", repo.Path(), "vs", giturl)
|
|
|
|
repo.giturl = giturl
|
|
|
|
if giturl != repo.Path() {
|
|
|
|
log.Info("repo check failed", repo.String())
|
|
|
|
s.unknownOL.SetText(repo.String())
|
|
|
|
s.unknownOL.Show()
|
|
|
|
s.unknownSubmitB.Show()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
log.Info("repo check failed", repo.String())
|
|
|
|
repo.giturl = "look in .git/config"
|
|
|
|
s.unknownOL.SetText(repo.String())
|
|
|
|
s.unknownOL.Show()
|
|
|
|
s.unknownSubmitB.Show()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
s.checkB.SetText("GOOD")
|
|
|
|
})
|
|
|
|
*/
|