2024-01-09 01:16:00 -06:00
|
|
|
// This is a simple example
|
|
|
|
package main
|
|
|
|
|
2024-01-18 00:58:14 -06:00
|
|
|
import (
|
2024-01-15 08:11:08 -06:00
|
|
|
"embed"
|
2024-01-26 02:04:19 -06:00
|
|
|
"fmt"
|
2024-01-18 00:58:14 -06:00
|
|
|
"os/user"
|
2024-01-23 22:48:07 -06:00
|
|
|
"strings"
|
2024-01-26 02:04:19 -06:00
|
|
|
"time"
|
2024-01-09 10:21:58 -06:00
|
|
|
|
2024-01-09 02:00:51 -06:00
|
|
|
"go.wit.com/log"
|
|
|
|
|
2024-01-18 05:03:04 -06:00
|
|
|
"go.wit.com/gui"
|
2024-01-18 00:58:14 -06:00
|
|
|
"go.wit.com/lib/gadgets"
|
|
|
|
"go.wit.com/lib/gui/repostatus"
|
2024-01-09 01:16:00 -06:00
|
|
|
)
|
|
|
|
|
2024-01-15 21:11:28 -06:00
|
|
|
//go:embed resources/*
|
2024-01-15 08:11:08 -06:00
|
|
|
var resToolkit embed.FS
|
|
|
|
|
2024-01-09 01:16:00 -06:00
|
|
|
func main() {
|
2024-01-23 11:22:33 -06:00
|
|
|
me = new(autoType)
|
2024-01-24 22:22:34 -06:00
|
|
|
me.allrepos = make(map[string]*repo)
|
2024-01-18 05:03:04 -06:00
|
|
|
|
|
|
|
me.myGui = gui.New()
|
|
|
|
me.myGui.InitEmbed(resToolkit)
|
2024-01-18 14:46:20 -06:00
|
|
|
// me.myGui.LoadToolkit("nocui")
|
2024-01-18 05:03:04 -06:00
|
|
|
me.myGui.Default()
|
2024-01-09 01:16:00 -06:00
|
|
|
|
2024-01-16 11:56:55 -06:00
|
|
|
autotypistWindow()
|
2024-01-19 18:37:27 -06:00
|
|
|
repoworld()
|
2024-01-20 17:17:48 -06:00
|
|
|
|
2024-01-26 02:04:19 -06:00
|
|
|
// scan repos every 30 seconds
|
|
|
|
// check every second for the checkbox changing
|
|
|
|
var i int = 60
|
2024-01-26 11:59:59 -06:00
|
|
|
myTicker(1*time.Second, "newScan()", func() {
|
2024-01-26 02:04:19 -06:00
|
|
|
i += 1
|
2024-01-26 11:59:59 -06:00
|
|
|
if !me.scanEveryMinute.Checked() {
|
2024-01-26 02:04:19 -06:00
|
|
|
if i < 60 {
|
|
|
|
i = 60
|
|
|
|
}
|
|
|
|
// print every 13 seconds
|
|
|
|
if i%13 == 0 {
|
|
|
|
log.Info("Not auto scanning", i)
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if i < 60 {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
i = 0
|
|
|
|
duration := timeFunction(func() {
|
|
|
|
scanGoSum()
|
|
|
|
for _, repo := range me.allrepos {
|
|
|
|
repo.newScan()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
s := fmt.Sprint(duration)
|
|
|
|
me.autoWorkingPwd.SetText(s)
|
|
|
|
})
|
2024-01-09 01:16:00 -06:00
|
|
|
}
|
|
|
|
|
2024-01-13 23:27:46 -06:00
|
|
|
func addRepo(grid *gui.Node, path string, master string, devel string, user string) {
|
2024-01-24 22:22:34 -06:00
|
|
|
_, ok := me.allrepos[path]
|
|
|
|
if ok {
|
|
|
|
log.Info("addRepo() already had path", path)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2024-01-09 02:22:01 -06:00
|
|
|
newRepo := new(repo)
|
|
|
|
|
2024-01-23 22:48:07 -06:00
|
|
|
path = strings.Trim(path, "/") // trim any extranous '/' chars put in the config file by the user
|
2024-01-23 11:22:33 -06:00
|
|
|
if path == "" {
|
|
|
|
log.Warn("addRepo() got empty path", path, master, devel, user)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2024-01-13 21:39:44 -06:00
|
|
|
if repostatus.VerifyLocalGoRepo(path) {
|
2024-01-23 11:22:33 -06:00
|
|
|
log.Verbose("newRepo actually exists", newRepo.getPath())
|
2024-01-13 21:39:44 -06:00
|
|
|
} else {
|
2024-01-23 11:22:33 -06:00
|
|
|
log.Warn("repostatus.VerifyLocalGoRepo() failed for for", path, master, devel, user)
|
2024-01-13 21:39:44 -06:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2024-01-09 02:22:01 -06:00
|
|
|
newRepo.path = path
|
2024-01-15 08:11:08 -06:00
|
|
|
newRepo.pLabel = grid.NewLabel(path).SetProgName("path")
|
2024-01-20 18:45:55 -06:00
|
|
|
|
2024-01-15 08:11:08 -06:00
|
|
|
newRepo.lastTag = grid.NewLabel("").SetProgName("lastTag")
|
|
|
|
|
|
|
|
newRepo.masterVersion = grid.NewLabel("").SetProgName("masterVersion")
|
|
|
|
newRepo.develVersion = grid.NewLabel("").SetProgName("develVersion")
|
|
|
|
newRepo.userVersion = grid.NewLabel("").SetProgName("userVersion")
|
2024-01-20 18:45:55 -06:00
|
|
|
|
2024-01-09 09:56:33 -06:00
|
|
|
newRepo.dirtyLabel = grid.NewLabel("")
|
2024-01-24 02:41:34 -06:00
|
|
|
newRepo.goSumStatus = grid.NewLabel("?")
|
2024-01-09 02:22:01 -06:00
|
|
|
|
2024-01-20 18:45:55 -06:00
|
|
|
newRepo.vLabel = grid.NewLabel("").SetProgName("current")
|
|
|
|
|
2024-01-23 11:22:33 -06:00
|
|
|
newRepo.statusButton = grid.NewButton("Configure", func() {
|
2024-01-13 21:39:44 -06:00
|
|
|
if newRepo.status == nil {
|
|
|
|
log.Warn("status window doesn't exist")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
log.Warn("status window exists. trying TestDraw() here")
|
2024-01-19 18:37:27 -06:00
|
|
|
newRepo.status.Toggle()
|
2024-01-23 22:48:07 -06:00
|
|
|
/// newRepo.status.Update()
|
2024-01-09 02:00:51 -06:00
|
|
|
})
|
2024-01-23 11:22:33 -06:00
|
|
|
|
|
|
|
// newRepo.status = repostatus.New(me.myGui, newRepo.path)
|
|
|
|
newRepo.status = repostatus.NewRepoStatusWindow(newRepo.path)
|
|
|
|
newRepo.hidden = false
|
2024-01-24 22:22:34 -06:00
|
|
|
newRepo.status.SetMainWorkingName(master)
|
|
|
|
newRepo.status.SetDevelWorkingName(devel)
|
|
|
|
newRepo.status.SetUserWorkingName(user)
|
2024-01-23 11:22:33 -06:00
|
|
|
/*
|
2024-01-23 22:48:07 -06:00
|
|
|
newRepo.status.SetDevelBranchName(devel)
|
|
|
|
newRepo.status.SetUserBranchName(user)
|
|
|
|
newRepo.status.Update()
|
|
|
|
newRepo.newScan()
|
2024-01-23 11:22:33 -06:00
|
|
|
*/
|
2024-01-24 22:22:34 -06:00
|
|
|
me.allrepos[path] = newRepo
|
2024-01-09 02:00:51 -06:00
|
|
|
}
|
|
|
|
|
2024-01-16 11:56:55 -06:00
|
|
|
func autotypistWindow() {
|
2024-01-18 05:03:04 -06:00
|
|
|
win := me.myGui.NewWindow("autotypist for GO & git. it types faster than you can.")
|
2024-01-17 20:52:07 -06:00
|
|
|
box := win.NewBox("bw hbox", true)
|
2024-01-20 17:17:48 -06:00
|
|
|
|
2024-01-16 11:56:55 -06:00
|
|
|
globalDisplayOptions(box)
|
|
|
|
globalBuildOptions(box)
|
2024-01-20 17:17:48 -06:00
|
|
|
globalTestingOptions(box)
|
2024-01-16 11:56:55 -06:00
|
|
|
globalResetOptions(box)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2024-01-09 01:16:00 -06:00
|
|
|
// This creates a window
|
2024-01-10 19:44:38 -06:00
|
|
|
func repoworld() {
|
2024-01-18 05:03:04 -06:00
|
|
|
reposwin = gadgets.NewBasicWindow(me.myGui, "All git repositories in ~/go/src/")
|
2024-01-14 10:36:46 -06:00
|
|
|
reposwin.Make()
|
|
|
|
|
|
|
|
reposbox = reposwin.Box().NewBox("bw vbox", false)
|
2024-01-18 00:58:14 -06:00
|
|
|
reposwin.Draw()
|
2024-01-18 22:33:53 -06:00
|
|
|
reposwin.Custom = func() {
|
2024-01-23 11:22:33 -06:00
|
|
|
log.Warn("GOT HERE: main() gadgets.NewBasicWindow() close")
|
|
|
|
log.Warn("Should I do something special here?")
|
2024-01-18 22:33:53 -06:00
|
|
|
}
|
2024-01-18 00:58:14 -06:00
|
|
|
|
2024-01-14 10:36:46 -06:00
|
|
|
reposgroup = reposbox.NewGroup("go repositories (read from ~/.config/myrepolist)")
|
2024-01-24 02:41:34 -06:00
|
|
|
reposgrid = reposgroup.NewGrid("test", 9, 1)
|
2024-01-20 18:45:55 -06:00
|
|
|
|
|
|
|
reposgrid.NewLabel("") // path goes here
|
2024-01-14 10:36:46 -06:00
|
|
|
|
2024-01-15 08:11:08 -06:00
|
|
|
reposgrid.NewLabel("last tag").SetProgName("last tag")
|
2024-01-20 18:45:55 -06:00
|
|
|
|
|
|
|
reposgrid.NewLabel("master version")
|
|
|
|
reposgrid.NewLabel("devel version")
|
|
|
|
reposgrid.NewLabel("user version")
|
|
|
|
|
2024-01-14 10:36:46 -06:00
|
|
|
reposgrid.NewLabel("Status")
|
2024-01-24 02:41:34 -06:00
|
|
|
reposgrid.NewLabel("go.sum")
|
2024-01-20 18:45:55 -06:00
|
|
|
|
|
|
|
reposgrid.NewLabel("Current Version").SetProgName("Current Version")
|
|
|
|
|
2024-01-14 21:43:31 -06:00
|
|
|
reposgrid.NewLabel("Show()")
|
2024-01-09 02:00:51 -06:00
|
|
|
|
2024-01-09 10:41:35 -06:00
|
|
|
repos := myrepolist()
|
2024-01-13 23:27:46 -06:00
|
|
|
for _, line := range repos {
|
2024-01-23 11:22:33 -06:00
|
|
|
log.Verbose("repo =", line)
|
2024-01-13 23:27:46 -06:00
|
|
|
path, mbranch, dbranch, ubranch := splitLine(line)
|
2024-01-18 00:58:14 -06:00
|
|
|
if mbranch == "" {
|
|
|
|
mbranch = "master"
|
|
|
|
}
|
|
|
|
if dbranch == "" {
|
|
|
|
dbranch = "devel"
|
|
|
|
}
|
2024-01-13 23:27:46 -06:00
|
|
|
usr, _ := user.Current()
|
2024-01-18 00:58:14 -06:00
|
|
|
if ubranch == "" {
|
|
|
|
ubranch = usr.Username
|
|
|
|
}
|
2024-01-14 10:36:46 -06:00
|
|
|
addRepo(reposgrid, path, mbranch, dbranch, ubranch)
|
2024-01-09 10:21:58 -06:00
|
|
|
}
|
2024-01-24 22:22:34 -06:00
|
|
|
|
|
|
|
for i, path := range repostatus.ListGitDirectories() {
|
|
|
|
// log.Info("addRepo()", i, path)
|
|
|
|
tmp := strings.TrimPrefix(path, "/home/jcarr/go/src/")
|
|
|
|
log.Info("addRepo()", i, tmp)
|
|
|
|
addRepo(reposgrid, tmp, "master", "master", "master")
|
|
|
|
}
|
|
|
|
|
2024-01-24 16:25:41 -06:00
|
|
|
reposwin.Toggle()
|
2024-01-09 01:16:00 -06:00
|
|
|
}
|