changing branches works

This commit is contained in:
Jeff Carr 2024-02-16 17:55:53 -06:00
parent bdb7617143
commit c253a30fb6
8 changed files with 86 additions and 93 deletions

View File

@ -1,6 +1,10 @@
# to build by hand export GO111MODULE=off # to build by hand export GO111MODULE=off
all: build all: build
reset
./autotypist
only-me: build
reset reset
./autotypist --only-me ./autotypist --only-me

View File

@ -50,7 +50,7 @@ func docsBox(vbox *gui.Node) {
shell.Run([]string{"ping", "-c", "3", "git.wit.org"}) shell.Run([]string{"ping", "-c", "3", "git.wit.org"})
}) })
group.NewButton("send docs to browser (localhost:8080)", func() { group.NewButton("open docs in browser (localhost:8080)", func() {
me.autotypistWindow.Disable() me.autotypistWindow.Disable()
defer me.autotypistWindow.Enable() defer me.autotypistWindow.Enable()

View File

@ -56,11 +56,13 @@ func quickCmd(fullpath string, cmd []string) bool {
func globalBuildOptions(vbox *gui.Node) { func globalBuildOptions(vbox *gui.Node) {
group1 := vbox.NewGroup("Global Build Options") group1 := vbox.NewGroup("Global Build Options")
grid := group1.NewGrid("buildOptions", 2, 1) grid := group1.NewGrid("buildOptions", 0, 0)
// me.autoWorkingPwd = gadgets.NewOneLiner(grid, "working directory (pwd)") // me.autoWorkingPwd = gadgets.NewOneLiner(grid, "working directory (pwd)")
me.userHomePwd = gadgets.NewOneLiner(grid, "user home") me.userHomePwd = gadgets.NewOneLiner(grid, "user home")
grid.NextRow()
me.goSrcPwd = gadgets.NewOneLiner(grid, "go src home") me.goSrcPwd = gadgets.NewOneLiner(grid, "go src home")
grid.NextRow()
usr, _ := user.Current() usr, _ := user.Current()
homeDir, err := os.UserHomeDir() homeDir, err := os.UserHomeDir()
@ -72,61 +74,26 @@ func globalBuildOptions(vbox *gui.Node) {
srcDir := filepath.Join(homeDir, "go/src") srcDir := filepath.Join(homeDir, "go/src")
me.goSrcPwd.SetText(srcDir) me.goSrcPwd.SetText(srcDir)
me.mainBranch = gadgets.NewBasicCombobox(grid, "default main branch")
me.mainBranch.AddText("gitea server default")
me.mainBranch.Disable()
me.develBranch = gadgets.NewBasicCombobox(grid, "default devel branch")
me.develBranch.AddText("devel")
me.develBranch.Disable()
me.userBranch = gadgets.NewBasicCombobox(grid, "default user branch")
me.userBranch.AddText(usr.Username)
me.userBranch.Disable()
var newBranch *gui.Node
var setBranchB *gui.Node
// gadgets.OneLiner(grid, "default user branch")
// select the branch you want to test, build and develop against // select the branch you want to test, build and develop against
// this lets you select your user branch, but, when you are happy // 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 // 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 // works. Then, when that is good, merge and version everything in master
setBranchB = grid.NewButton("set current branch to:", func() { me.setBranchB = grid.NewButton("set current branch to:", func() {
targetName := newBranch.String() targetName := me.newBranch.String()
log.Warn("set current branch to:", targetName) log.Warn("setting all branches to", targetName)
/*
me.toMoveToBranch = guiBranch.String()
setCurrentBranch.SetLabel("set all branches to " + me.toMoveToBranch)
me.mainBranch.Disable()
*/
for _, repo := range me.allrepos { for _, repo := range me.allrepos {
if targetName == "jcarr" { repo.status.CheckoutBranch(targetName)
if repo.status.CheckoutUser() { repo.status.UpdateNew()
log.Warn("set master branch worked", repo.String())
repo.newScan() repo.newScan()
} else {
log.Warn("set master branch failed", repo.String())
repo.newScan()
}
} else {
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()
}
}
} }
}) })
newBranch = grid.NewCombobox() me.newBranch = grid.NewCombobox()
newBranch.AddText("master") me.newBranch.AddText("master")
newBranch.AddText("devel") me.newBranch.AddText("devel")
newBranch.AddText(usr.Username) me.newBranch.AddText(usr.Username)
newBranch.SetText(usr.Username) me.newBranch.SetText(usr.Username)
newBranch.Custom = func() {
setBranchB.SetLabel("set current branches to " + newBranch.String()) // checking this will automatically make the branches off of devel
} me.autoCreateBranches = grid.NewCheckbox("create if missing").SetChecked(true)
grid.NextRow()
} }

View File

@ -5,6 +5,7 @@ import (
"go.wit.com/lib/debugger" "go.wit.com/lib/debugger"
"go.wit.com/lib/gui/gowit" "go.wit.com/lib/gui/gowit"
"go.wit.com/lib/gui/logsettings" "go.wit.com/lib/gui/logsettings"
"go.wit.com/log"
) )
func globalDisplaySetRepoState() { func globalDisplaySetRepoState() {
@ -66,7 +67,13 @@ func globalDisplayOptions(vbox *gui.Node) {
globalDisplayShow() globalDisplayShow()
} }
} }
me.scanEveryMinute = group1.NewCheckbox("Scan every minute").SetChecked(false) scanbox := group1.Box().Horizontal()
me.autoScanReposCB = scanbox.NewCheckbox("auto scan").SetChecked(true)
scanbox.NewButton("scan now", func() {
log.Info("re-scanning repos now")
scanRepositories()
})
me.duration = scanbox.NewLabel("")
var tagsW *tagWindow var tagsW *tagWindow
group1.NewButton("git tags Window", func() { group1.NewButton("git tags Window", func() {

43
main.go
View File

@ -53,34 +53,39 @@ func main() {
// processing is done. update the repo summary box // processing is done. update the repo summary box
me.summary.Update() me.summary.Update()
// scan repos every 30 seconds // scan repos every i seconds
// check every second for the checkbox changing // check every 'delay seconds for the checkbox changing
var i int = 60 // this logic is unintuitive because I want it to fluidly
// never tricker quickly but also want to print something
// out that the app is alive since, technically
// the GUI is *NOT* this app and could be alive when
// the application is actually stalled somewhere
// plus these things are fun for me and a distraction when
// I've been working 50 days in a row on this gui code
// this also means that if you click the checkbox after
// the delay, then the scan will run right away, but if
// you check the checkbox twice in 5 seconds, it won't
// rerun until the delay again
var delay int = 99
var i int = delay
myTicker(1*time.Second, "newScan()", func() { myTicker(1*time.Second, "newScan()", func() {
i += 1 i += 1
if !me.scanEveryMinute.Checked() { // check if the checkbox is checked
if i < 60 { if !me.autoScanReposCB.Checked() {
i = 60 if i < delay {
i = delay
} }
// print every 27 seconds // print every 'delay' seconds
if i%27 == 0 { if i%delay == 0 {
log.Info("Not auto scanning", i) log.Info("Not auto scanning", i)
} }
return return
} }
if i < 60 { if i < delay {
return return
} }
i = 0 i = 0
timeFunction(func() { scanRepositories()
// scanGoSum()
for _, repo := range me.allrepos {
repo.newScan()
}
})
/*
s := fmt.Sprint(duration)
// me.autoWorkingPwd.SetText(s)
*/
}) })
} }

View File

@ -67,7 +67,7 @@ func repolistWindow() {
repoAllButtons(me.reposbox) repoAllButtons(me.reposbox)
me.reposgroup = me.reposbox.NewGroup("go repositories (read from ~/.config/myrepolist)") me.reposgroup = me.reposbox.NewGroup("git repositories (configure in ~/.config/myrepolist)")
me.reposgrid = me.reposgroup.NewGrid("test", 0, 0) me.reposgrid = me.reposgroup.NewGrid("test", 0, 0)
me.reposgrid.NewLabel("") // path goes here me.reposgrid.NewLabel("") // path goes here
@ -146,14 +146,6 @@ func repoAllButtons(box *gui.Node) {
// hbox.Horizontal() // hbox.Horizontal()
hbox.Vertical() hbox.Vertical()
box1 := hbox.Box().Vertical()
box1.NewButton("status.Update() all", func() {
for _, repo := range me.allrepos {
repo.status.UpdateNew()
repo.newScan()
}
})
box2 := hbox.Box().Vertical() box2 := hbox.Box().Vertical()
box2.NewButton("merge all user to devel", func() { box2.NewButton("merge all user to devel", func() {
me.reposwin.Disable() me.reposwin.Disable()

18
scan.go
View File

@ -3,11 +3,24 @@ package main
import ( import (
"fmt" "fmt"
"os/user" "os/user"
"strings"
"time" "time"
"go.wit.com/log" "go.wit.com/log"
) )
func scanRepositories() {
log.Info("Scanned", me.summary.totalOL.String(), "repositories. todo: count/show changes")
t := timeFunction(func() {
for _, repo := range me.allrepos {
repo.status.UpdateNew()
repo.newScan()
}
})
s := fmt.Sprint(t)
me.duration.SetText(s)
}
func (r *repo) newScan() bool { func (r *repo) newScan() bool {
if r.status == nil { if r.status == nil {
log.Warn("repo.status = nil. not initialized for some reason") log.Warn("repo.status = nil. not initialized for some reason")
@ -48,8 +61,9 @@ func (r *repo) newScan() bool {
r.lastTag.SetLabel(lasttag) r.lastTag.SetLabel(lasttag)
r.vLabel.SetLabel(cbname + " " + cbversion) r.vLabel.SetLabel(cbname + " " + cbversion)
if r.status.Changed() { if c, ok := r.status.Changed(); ok {
log.Warn("should scan here") c := strings.TrimSpace(c)
log.Warn("repo", r.status.Path(), "changed", c)
} }
status := r.status.GetStatus() status := r.status.GetStatus()
r.dirtyLabel.SetLabel(status) r.dirtyLabel.SetLabel(status)

View File

@ -44,11 +44,6 @@ type autoType struct {
// then switch back to your 'username' branch and do a build there // then switch back to your 'username' branch and do a build there
toMoveToBranch string toMoveToBranch string
// displays the preferred names used for the repo tree state
mainBranch *gadgets.BasicCombobox
develBranch *gadgets.BasicCombobox
userBranch *gadgets.BasicCombobox
// this button will regenerate everyones go.mod & go.sum // this button will regenerate everyones go.mod & go.sum
rerunGoMod *gui.Node rerunGoMod *gui.Node
@ -61,11 +56,9 @@ type autoType struct {
// checkbox for --dry-run // checkbox for --dry-run
autoDryRun *gui.Node autoDryRun *gui.Node
// checkbox for intermittent scanning // checkbox to enable intermittent scanning
scanEveryMinute *gui.Node // if checked, it will check all your repos for changes
autoScanReposCB *gui.Node
// The current working directory
// autoWorkingPwd *gadgets.OneLiner
// what is being used as your home dir // what is being used as your home dir
userHomePwd *gadgets.OneLiner userHomePwd *gadgets.OneLiner
@ -82,6 +75,17 @@ type autoType struct {
// has total dirty, total read-only // has total dirty, total read-only
// total patches, etc // total patches, etc
summary *patchSummary summary *patchSummary
// shows how long the scan went for
duration *gui.Node
// when switch to user or devel branches, autocreate them
autoCreateBranches *gui.Node
// these hold the branches that the user can switch all
// the repositories to them
newBranch *gui.Node
setBranchB *gui.Node
} }
type repo struct { type repo struct {