dump lots of old code

This commit is contained in:
Jeff Carr 2025-01-07 06:46:24 -06:00
parent 100fed12c4
commit 3fb30bb11b
6 changed files with 22 additions and 251 deletions

View File

@ -13,10 +13,10 @@ import (
"github.com/destel/rill/mockapi" "github.com/destel/rill/mockapi"
"go.wit.com/lib/gui/repolist" "go.wit.com/lib/gui/repolist"
"go.wit.com/log"
) )
// okay // okay
/*
func checkoutDevel() bool { func checkoutDevel() bool {
log.Info("running git checkout devel everwhere") log.Info("running git checkout devel everwhere")
var failed int = 0 var failed int = 0
@ -39,6 +39,7 @@ func checkoutDevel() bool {
log.Info("Ran git checkout in", count, "repos. failure count =", failed) log.Info("Ran git checkout in", count, "repos. failure count =", failed)
return true return true
} }
*/
// https://news.ycombinator.com/item?id=42237166 // https://news.ycombinator.com/item?id=42237166
// https://github.com/destel/rill // https://github.com/destel/rill

View File

@ -2,10 +2,6 @@ package main
import ( import (
"os" "os"
"os/user"
"path/filepath"
"go.wit.com/log"
"go.wit.com/gui" "go.wit.com/gui"
"go.wit.com/lib/gadgets" "go.wit.com/lib/gadgets"
@ -21,17 +17,6 @@ func globalBuildOptions(vbox *gui.Node) {
me.goSrcPwd = gadgets.NewOneLiner(grid, "go src home") me.goSrcPwd = gadgets.NewOneLiner(grid, "go src home")
grid.NextRow() grid.NextRow()
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)
grid.NextRow()
me.stopOnErrors = grid.NewCheckbox("Stop on errors").SetChecked(true) me.stopOnErrors = grid.NewCheckbox("Stop on errors").SetChecked(true)
grid.NextRow() grid.NextRow()
@ -46,153 +31,4 @@ func globalBuildOptions(vbox *gui.Node) {
me.autoDryRun.SetChecked(true) me.autoDryRun.SetChecked(true)
grid.NextRow() grid.NextRow()
grid.NewGroup("git checkout")
// checking this will automatically make the branches off of devel
grid.NextRow()
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")
} else {
os.Unsetenv("AUTOTYPIST_CREATE_BRANCHES")
}
}
grid.NextRow()
grid.NewButton("git checkout master branch", func() {
me.forge.CheckoutMaster()
})
grid.NewLabel("") // set the order of these in the config file
grid.NextRow()
grid.NewButton("git checkout devel branch", func() {
me.forge.CheckoutDevel()
})
grid.NewLabel("") // set the order of these in the config file
grid.NextRow()
grid.NewButton("git checkout "+usr.Username+" branch", func() {
me.forge.CheckoutUser()
})
grid.NewLabel("")
grid.NextRow()
// select the branches you want to test, build and develop against
// let's call this the 'mode' ?
// 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
/*
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
*/
grid.NextRow()
grid.NewGroup("update all repos from upstream")
grid.NextRow()
grid.NewButton("git pull", func() {
me.Disable()
defer me.Enable()
rillGitPull()
/*
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
loop := me.repos.View.ReposSortByName()
for loop.Scan() {
repo := loop.Repo()
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)
})
grid.NextRow()
grid.NewGroup("build")
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()
} }

View File

@ -1,7 +1,6 @@
package main package main
import ( import (
"os"
"path/filepath" "path/filepath"
"strconv" "strconv"
"strings" "strings"
@ -20,69 +19,6 @@ func globalResetOptions(box *gui.Node) {
}) })
grid.NextRow() grid.NextRow()
grid.NewButton("delete user branches", func() {
os.Setenv("REPO_FORCE", "off")
loop := me.repos.View.ReposSortByName()
for loop.Scan() {
repo := loop.Repo()
repo.Status.DeleteUserBranch(false)
}
})
grid.NextRow()
grid.NewButton("delete user branches --force", func() {
os.Setenv("REPO_FORCE", "on")
loop := me.repos.View.ReposSortByName()
for loop.Scan() {
repo := loop.Repo()
repo.Status.DeleteUserBranch(true)
}
})
grid.NextRow()
grid.NewButton("git reset all branches", func() {
loop := me.repos.View.ReposSortByName()
for loop.Scan() {
repo := loop.Repo()
repo.Status.ResetBranches()
}
})
grid.NextRow()
grid.NewButton("rm -f go.mod go.sum", func() {
me.Disable()
loop := me.repos.View.ReposSortByName()
for loop.Scan() {
repo := loop.Repo()
if repo.Status.Whitelist {
continue
}
if repo.Status.ReadOnly() {
continue
}
repo.Status.Run([]string{"rm", "-f", "go.mod", "go.sum"})
}
me.Enable()
})
grid.NextRow()
grid.NewButton("git reset --hard", func() {
me.Disable()
loop := me.repos.View.ReposSortByName()
for loop.Scan() {
repo := loop.Repo()
if repo.Status.Whitelist {
continue
}
if repo.Status.ReadOnly() {
continue
}
repo.Status.Run([]string{"git", "reset", "--hard"})
}
me.Enable()
})
grid.NextRow()
// this dumps everything // this dumps everything
grid.NewLabel("clean start over") grid.NewLabel("clean start over")
me.deleteGoSrcPkgB = grid.NewButton("rm ~/go/src & ~/go/pkg & ~/.cache/go-build", func() { me.deleteGoSrcPkgB = grid.NewButton("rm ~/go/src & ~/go/pkg & ~/.cache/go-build", func() {

View File

@ -1,11 +1,6 @@
package main package main
import ( /*
"os"
"go.wit.com/lib/gui/repolist"
)
// like tcl/tk, use ENV variables to set display preferences // like tcl/tk, use ENV variables to set display preferences
func hideFunction(r *repolist.RepoRow) { func hideFunction(r *repolist.RepoRow) {
// always show dirty repos // always show dirty repos
@ -48,3 +43,4 @@ func hideFunction(r *repolist.RepoRow) {
// as read-only=true // as read-only=true
r.Show() r.Show()
} }
*/

View File

@ -76,7 +76,7 @@ func main() {
// handleCmdLine() // handleCmdLine()
// setup the autoscan functions // setup the autoscan functions
me.repos.View.RegisterHideFunction(hideFunction) // me.repos.View.RegisterHideFunction(hideFunction)
// processing is done. update the repo summary box // processing is done. update the repo summary box
// me.summary.Update() // me.summary.Update()

View File

@ -113,22 +113,24 @@ func (r *repoWindow) repoMenu() *gui.Node {
}) })
box2.NewButton("show apps", func() { box2.NewButton("show apps", func() {
loop := me.repos.View.ReposSortByName() /*
for loop.Scan() { loop := me.repos.View.ReposSortByName()
repo := loop.Repo() for loop.Scan() {
rtype := repo.Status.RepoType() repo := loop.Repo()
switch rtype { rtype := repo.Status.RepoType()
case "'binary'": switch rtype {
// log.Info(repo.Status.Path(), "compile here. Show()") case "'binary'":
repo.Show() // log.Info(repo.Status.Path(), "compile here. Show()")
case "'library'": repo.Show()
// log.Info(repo.Status.Path(), "library here. Hide()") case "'library'":
repo.Hide() // log.Info(repo.Status.Path(), "library here. Hide()")
default: repo.Hide()
log.Info(repo.Status.Path(), "unknown type", rtype) default:
// repo.Hide() log.Info(repo.Status.Path(), "unknown type", rtype)
// repo.Hide()
}
} }
} */
}) })
box2.NewButton("scan now", func() { box2.NewButton("scan now", func() {
log.Info("re-scanning now") log.Info("re-scanning now")