summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-02-16 17:55:53 -0600
committerJeff Carr <[email protected]>2024-02-16 17:55:53 -0600
commitc253a30fb61cdc956e1cefb8296e34bf74ddf90c (patch)
treefc4b962a2e768866619acce615deaa99fd56dde9
parentbdb761714361a3986834b8b50bb34cce45d01e4d (diff)
changing branches works
-rw-r--r--Makefile4
-rw-r--r--docs.go (renamed from pkgsite.go)2
-rw-r--r--globalBuildOptions.go69
-rw-r--r--globalDisplayOptions.go9
-rw-r--r--main.go43
-rw-r--r--repolist.go10
-rw-r--r--scan.go18
-rw-r--r--structs.go24
8 files changed, 86 insertions, 93 deletions
diff --git a/Makefile b/Makefile
index 34fc476..14f2253 100644
--- a/Makefile
+++ b/Makefile
@@ -2,6 +2,10 @@
all: build
reset
+ ./autotypist
+
+only-me: build
+ reset
./autotypist --only-me
stderr: build
diff --git a/pkgsite.go b/docs.go
index db61518..219d4bc 100644
--- a/pkgsite.go
+++ b/docs.go
@@ -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()
diff --git a/globalBuildOptions.go b/globalBuildOptions.go
index cc71e41..20b3eb4 100644
--- a/globalBuildOptions.go
+++ b/globalBuildOptions.go
@@ -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()
}
diff --git a/globalDisplayOptions.go b/globalDisplayOptions.go
index c41ddc0..877ff92 100644
--- a/globalDisplayOptions.go
+++ b/globalDisplayOptions.go
@@ -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() {
diff --git a/main.go b/main.go
index a7d7d8b..34f774a 100644
--- a/main.go
+++ b/main.go
@@ -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()
})
}
diff --git a/repolist.go b/repolist.go
index 6d0b3a3..a3c46e9 100644
--- a/repolist.go
+++ b/repolist.go
@@ -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()
diff --git a/scan.go b/scan.go
index 0f98690..0e05cc5 100644
--- a/scan.go
+++ b/scan.go
@@ -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)
diff --git a/structs.go b/structs.go
index d831a16..1f24534 100644
--- a/structs.go
+++ b/structs.go
@@ -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 {