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
all: build
reset
./autotypist
only-me: build
reset
./autotypist --only-me

View File

@ -50,7 +50,7 @@ func docsBox(vbox *gui.Node) {
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()
defer me.autotypistWindow.Enable()

View File

@ -56,11 +56,13 @@ func quickCmd(fullpath string, cmd []string) bool {
func globalBuildOptions(vbox *gui.Node) {
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.userHomePwd = gadgets.NewOneLiner(grid, "user home")
grid.NextRow()
me.goSrcPwd = gadgets.NewOneLiner(grid, "go src home")
grid.NextRow()
usr, _ := user.Current()
homeDir, err := os.UserHomeDir()
@ -72,61 +74,26 @@ func globalBuildOptions(vbox *gui.Node) {
srcDir := filepath.Join(homeDir, "go/src")
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
// 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
setBranchB = grid.NewButton("set current branch to:", func() {
targetName := newBranch.String()
log.Warn("set current branch to:", targetName)
/*
me.toMoveToBranch = guiBranch.String()
setCurrentBranch.SetLabel("set all branches to " + me.toMoveToBranch)
me.mainBranch.Disable()
*/
me.setBranchB = grid.NewButton("set current branch to:", func() {
targetName := me.newBranch.String()
log.Warn("setting all branches to", targetName)
for _, repo := range me.allrepos {
if targetName == "jcarr" {
if repo.status.CheckoutUser() {
log.Warn("set master branch worked", repo.String())
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()
}
}
repo.status.CheckoutBranch(targetName)
repo.status.UpdateNew()
repo.newScan()
}
})
newBranch = grid.NewCombobox()
newBranch.AddText("master")
newBranch.AddText("devel")
newBranch.AddText(usr.Username)
newBranch.SetText(usr.Username)
newBranch.Custom = func() {
setBranchB.SetLabel("set current branches to " + newBranch.String())
}
me.newBranch = grid.NewCombobox()
me.newBranch.AddText("master")
me.newBranch.AddText("devel")
me.newBranch.AddText(usr.Username)
me.newBranch.SetText(usr.Username)
// 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/gui/gowit"
"go.wit.com/lib/gui/logsettings"
"go.wit.com/log"
)
func globalDisplaySetRepoState() {
@ -66,7 +67,13 @@ func globalDisplayOptions(vbox *gui.Node) {
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
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
me.summary.Update()
// scan repos every 30 seconds
// check every second for the checkbox changing
var i int = 60
// scan repos every i seconds
// check every 'delay seconds for the checkbox changing
// 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() {
i += 1
if !me.scanEveryMinute.Checked() {
if i < 60 {
i = 60
// check if the checkbox is checked
if !me.autoScanReposCB.Checked() {
if i < delay {
i = delay
}
// print every 27 seconds
if i%27 == 0 {
// print every 'delay' seconds
if i%delay == 0 {
log.Info("Not auto scanning", i)
}
return
}
if i < 60 {
if i < delay {
return
}
i = 0
timeFunction(func() {
// scanGoSum()
for _, repo := range me.allrepos {
repo.newScan()
}
})
/*
s := fmt.Sprint(duration)
// me.autoWorkingPwd.SetText(s)
*/
scanRepositories()
})
}

View File

@ -67,7 +67,7 @@ func repolistWindow() {
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.NewLabel("") // path goes here
@ -146,14 +146,6 @@ func repoAllButtons(box *gui.Node) {
// hbox.Horizontal()
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.NewButton("merge all user to devel", func() {
me.reposwin.Disable()

18
scan.go
View File

@ -3,11 +3,24 @@ package main
import (
"fmt"
"os/user"
"strings"
"time"
"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 {
if r.status == nil {
log.Warn("repo.status = nil. not initialized for some reason")
@ -48,8 +61,9 @@ func (r *repo) newScan() bool {
r.lastTag.SetLabel(lasttag)
r.vLabel.SetLabel(cbname + " " + cbversion)
if r.status.Changed() {
log.Warn("should scan here")
if c, ok := r.status.Changed(); ok {
c := strings.TrimSpace(c)
log.Warn("repo", r.status.Path(), "changed", c)
}
status := r.status.GetStatus()
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
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
rerunGoMod *gui.Node
@ -61,11 +56,9 @@ type autoType struct {
// checkbox for --dry-run
autoDryRun *gui.Node
// checkbox for intermittent scanning
scanEveryMinute *gui.Node
// The current working directory
// autoWorkingPwd *gadgets.OneLiner
// checkbox to enable intermittent scanning
// if checked, it will check all your repos for changes
autoScanReposCB *gui.Node
// what is being used as your home dir
userHomePwd *gadgets.OneLiner
@ -82,6 +75,17 @@ type autoType struct {
// has total dirty, total read-only
// total patches, etc
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 {