gui cleanup

This commit is contained in:
Jeff Carr 2024-11-13 11:56:58 -06:00
parent 169d2127da
commit 967fc70a48
4 changed files with 106 additions and 123 deletions

View File

@ -9,7 +9,6 @@ import (
"go.wit.com/gui"
"go.wit.com/lib/gadgets"
"go.wit.com/lib/gui/repolist"
)
func globalBuildOptions(vbox *gui.Node) {
@ -33,10 +32,25 @@ func globalBuildOptions(vbox *gui.Node) {
me.goSrcPwd.SetText(srcDir)
grid.NextRow()
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()
grid.NewGroup("git checkout")
// checking this will automatically make the branches off of devel
grid.NextRow()
me.autoCreateBranches = grid.NewCheckbox("auto-create branches if not upstream").SetChecked(true)
me.autoCreateBranches = grid.NewCheckbox("auto-create {devel,user} branches").SetChecked(true)
me.autoCreateBranches.Custom = func() {
if me.autoCreateBranches.Checked() {
os.Setenv("AUTOTYPIST_CREATE_BRANCHES", "on")
@ -46,22 +60,22 @@ func globalBuildOptions(vbox *gui.Node) {
}
grid.NextRow()
grid.NewButton("git checkout default", func() {
grid.NewButton("git checkout master branch", func() {
me.repos.View.ArgCheckoutMaster()
})
grid.NewLabel("master,main,etc.") // set the order of these in the config file ?
grid.NewLabel("") // set the order of these in the config file
grid.NextRow()
grid.NewButton("git checkout devel", func() {
grid.NewButton("git checkout devel branch", func() {
me.repos.View.ArgCheckoutDevel()
})
grid.NewLabel("guidevel,devel") // set the order of these in the config file ?
grid.NewLabel("") // set the order of these in the config file
grid.NextRow()
grid.NewButton("git checkout user", func() {
grid.NewButton("git checkout "+usr.Username+" branch", func() {
me.repos.View.ArgCheckoutUser()
})
grid.NewLabel(usr.Username)
grid.NewLabel("")
grid.NextRow()
// select the branches you want to test, build and develop against
@ -102,12 +116,26 @@ func globalBuildOptions(vbox *gui.Node) {
grid.NewGroup("update from upstream")
grid.NextRow()
grid.NewButton("git fetch master & devel branches", func() {
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() {
me.Disable()
defer me.Enable()
log.Warn("updating all master branches")
var count, failed int
for _, repo := range repolist.AllRepos() {
loop := me.repos.View.ReposSortByName()
for loop.Scan() {
repo := loop.Repo()
var err error
var out string
count += 1
@ -126,53 +154,51 @@ func globalBuildOptions(vbox *gui.Node) {
}
log.Warn("updated all master branches", count, "failed =", failed)
})
grid.NextRow()
me.autoRebuildButton = grid.NewButton("rebuild autotypist", func() {
me.autoRebuildButton.Disable()
me.autoRebuildButton.SetLabel("running....")
attemptAutoRebuild()
me.autoRebuildButton.Enable()
me.autoRebuildButton.SetLabel("rebuild autotypist")
})
grid.NextRow()
grid.NewButton("go build", func() {
me.Disable()
defer me.Enable()
// r.showApps()
loop := me.repos.View.ReposSortByName()
for loop.Scan() {
repo := loop.Repo()
if repo.Hidden() {
// log.Info("skip hidden", repo.String())
} else {
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
}
}
}
log.Info("")
log.Info("every build worked !!!")
log.Info("")
})
grid.NextRow()
}
// this code isn't ready yet
/*
s.gitPullB = grid.NewButton("git pull", func() {
me.Disable()
defer me.Enable()
for _, repo := range repolist.AllRepos() {
// gitcmd := []string{"git", "fetch", "origin"}
itcmd := []string{"git", "pull"}
err, output := repo.RunCmd(gitcmd)
log.Info("output =", output)
if err == nil {
log.Info("git fetch worked", repo.Name())
} else {
log.Info("git fetch failed", repo.Name())
return
}
}
gitPullB.SetText("GOOD")
// update the stats
// s.Update()
})
s.gitPushB = grid.NewButton("git push", func() {
me.Disable()
defer me.Enable()
for _, repo := range repolist.AllRepos() {
gitcmd := []string{"git", "push"}
err, output := repo.RunCmd(gitcmd)
log.Info("output =", output)
if err == nil {
log.Info("git push worked", repo.Name())
} else {
log.Info("git push failed", repo.Name())
return
}
}
s.gitPushB.SetText("GOOD")
// update the stats
s.Update()
})
s.checkB = s.grid.NewButton("Check repos are working", func() {
me.Disable()
defer me.Enable()
for _, repo := range repolist.AllRepos() {
for loop.Scan() {
if repo.GitURL() != "" {
log.Info("repo already checked. do they match?")
log.Info("go.wit.com =", repo.GoURL())

View File

@ -7,40 +7,19 @@ import (
"strings"
"go.wit.com/gui"
"go.wit.com/lib/gui/repolist"
"go.wit.com/log"
)
func globalResetOptions(box *gui.Node) {
group2 := box.NewGroup("Global Destructive Options")
me.autoRebuildButton = group2.NewButton("rebuild autotypist", func() {
me.autoRebuildButton.Disable()
me.autoRebuildButton.SetLabel("running....")
attemptAutoRebuild()
me.autoRebuildButton.Enable()
me.autoRebuildButton.SetLabel("rebuild autotypist")
})
me.stopOnErrors = group2.NewCheckbox("Stop on errors")
me.stopOnErrors.SetChecked(true)
me.autoDryRun = group2.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 := group2.RawGrid()
grid.NewButton("delete user branches", func() {
os.Setenv("REPO_FORCE", "off")
for _, repo := range repolist.AllRepos() {
loop := me.repos.View.ReposSortByName()
for loop.Scan() {
repo := loop.Repo()
repo.Status.DeleteUserBranch(false)
}
})
@ -48,14 +27,18 @@ func globalResetOptions(box *gui.Node) {
grid.NewButton("delete user branches --force", func() {
os.Setenv("REPO_FORCE", "on")
for _, repo := range repolist.AllRepos() {
loop := me.repos.View.ReposSortByName()
for loop.Scan() {
repo := loop.Repo()
repo.Status.DeleteUserBranch(true)
}
})
grid.NextRow()
grid.NewButton("reset all branches", func() {
for _, repo := range repolist.AllRepos() {
grid.NewButton("git reset all branches", func() {
loop := me.repos.View.ReposSortByName()
for loop.Scan() {
repo := loop.Repo()
repo.Status.ResetBranches()
}
})
@ -64,7 +47,9 @@ func globalResetOptions(box *gui.Node) {
grid.NewLabel("start over")
me.deleteGoSrcPkgB = grid.NewButton("rm ~/go/src & ~/go/pkg", func() {
var state string = me.deleteGoSrcPkgB.String()
for _, repo := range repolist.AllRepos() {
loop := me.repos.View.ReposSortByName()
for loop.Scan() {
repo := loop.Repo()
if repo.GoPath() == "go.wit.com/apps/autotypist" {
continue
}

View File

@ -65,23 +65,6 @@ func makeRepoView() *repoWindow {
return r
}
func (r *repoWindow) showApps() {
for _, repo := range r.View.AllRepos() {
switch repo.Status.RepoType() {
case "binary":
//log.Info("compile here. Show()")
repo.Show()
case "library":
//log.Info("library here. Hide()")
repo.Hide()
default:
log.Info("showApps() unknown. Show()")
repo.Hide()
}
}
}
func (r *repoWindow) repoMenu() *gui.Node {
// reposbox.SetExpand(false)
group1 := r.box.NewGroup("Run on all repos:")
@ -118,36 +101,25 @@ func (r *repoWindow) repoMenu() *gui.Node {
r.Enable()
})
box2.NewButton("git pull", func() {
r.Disable()
defer r.Enable()
for _, repo := range r.View.AllRepos() {
repo.Run([]string{"git", "pull"})
box2.NewButton("show apps", func() {
loop := me.repos.View.ReposSortByName()
for loop.Scan() {
repo := loop.Repo()
rtype := repo.Status.RepoType()
switch rtype {
case "'binary'":
// log.Info(repo.Status.Path(), "compile here. Show()")
repo.Show()
case "'library'":
// log.Info(repo.Status.Path(), "library here. Hide()")
repo.Hide()
default:
log.Info(repo.Status.Path(), "unknown type", rtype)
// repo.Hide()
}
}
})
box2.NewButton("test all builds", func() {
r.Disable()
defer r.Enable()
r.showApps()
for _, repo := range r.View.AllRepos() {
if repo.Hidden() {
// log.Info("skip hidden", repo.String())
} else {
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
}
}
}
log.Info("")
log.Info("every build worked !!!")
log.Info("")
})
return box2
}

View File

@ -3,8 +3,8 @@ package main
import (
"strings"
"go.wit.com/log"
"go.wit.com/lib/gui/shell"
"go.wit.com/log"
)
// only errors on bad errors