more more into repostatus package

better working labels
    autotypist auto hides
    hide unmodified repos works again
    go build args out of order
    download the toolkits
    first auto rebuild of autotypist

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-01-19 18:37:27 -06:00
parent fa56bf146b
commit db36cef85a
10 changed files with 96 additions and 166 deletions

View File

@ -9,10 +9,10 @@ build:
echo "build it!" echo "build it!"
goimports -w *.go goimports -w *.go
-rm resources/*.so -rm resources/*.so
cp ~/go/src/go.wit.com/toolkits/*.so resources/
go build -v -x go build -v -x
install: install:
cp ~/go/src/go.wit.com/toolkits/*.so resources/
rm -f ~/go/src/go.wit.com/toolkits/*.so rm -f ~/go/src/go.wit.com/toolkits/*.so
go install -v -x go install -v -x
autotypist autotypist

View File

@ -84,7 +84,7 @@ func globalBuildOptions(box *gui.Node) {
guiBranch.AddText("jcarr") guiBranch.AddText("jcarr")
guiBranch.Custom = func() { guiBranch.Custom = func() {
me.toMoveToBranch = guiBranch.String() me.toMoveToBranch = guiBranch.String()
setCurrentBranch.Set("set all branches to " + me.toMoveToBranch) setCurrentBranch.SetLabel("set all branches to " + me.toMoveToBranch)
me.mainBranch.Disable() me.mainBranch.Disable()
} }
@ -105,62 +105,45 @@ func globalBuildOptions(box *gui.Node) {
quickCmdLastPath = "~/go/src" quickCmdLastPath = "~/go/src"
quickCmds = [][]string{} quickCmds = [][]string{}
log.Warn("scanning allrepos") log.Warn("scanning allrepos")
fullpath := "/home/jcarr/go/src" fullpath := "/home/jcarr/"
quickCmd(fullpath, []string{"mkdir", "-p", "go.wit.com/apps/"}) quickCmd(fullpath, []string{"mkdir", "-p", "/home/jcarr/go/src/go.wit.com/apps/"})
fullpath = "/home/jcarr/go/src/go.wit.com/apps/"
quickCmd(fullpath, []string{"go", "get", "go.wit.com/apps/autotypist"})
fullpath = "/home/jcarr/go/src/go.wit.com/apps/autotypist" fullpath = "/home/jcarr/go/src/go.wit.com/apps/autotypist"
quickCmd(fullpath, []string{"go", "get", "-v", "go.wit.com/apps/autotypist"})
quickCmd(fullpath, []string{"go", "get", "-v", "go.wit.com/toolkits/debian"}) quickCmd(fullpath, []string{"go", "get", "-v", "go.wit.com/toolkits/debian"})
fullpath = "/home/jcarr/go/src/go.wit.com/toolkits/debian" fullpath = "/home/jcarr/go/src/go.wit.com/toolkits/debian"
quickCmd(fullpath, []string{"make", "download"})
quickCmd(fullpath, []string{"make"}) quickCmd(fullpath, []string{"make"})
fullpath = "/home/jcarr/go/src/go.wit.com/apps/autotypist" fullpath = "/home/jcarr/go/src/go.wit.com/apps/autotypist"
quickCmd(fullpath, []string{"go", "get", "-v", "-u", "."}) quickCmd(fullpath, []string{"go", "get", "-v", "-u", "."})
quickCmd(fullpath, []string{"go", "-v", "-x", "build"}) quickCmd(fullpath, []string{"go", "build", "-v", "-x"})
me.script = quickCmds me.script = quickCmds
setGitCommands() setGitCommands()
}) })
me.rerunGoMod = groupvbox.NewButton("remove all go.mod and go.sum", func() {
quickCmdDoNotRun = false
log.Warn("scanning allrepos")
for _, path := range me.allrepos {
fullpath := "/home/jcarr/go/src/" + path
quickCmd(fullpath, []string{"rm", "-f", "go.mod", "go.sum"})
}
})
me.rerunGoMod = groupvbox.NewButton("re-run go mod & go tidy", func() { me.rerunGoMod = groupvbox.NewButton("re-run go mod & go tidy", func() {
me.rerunGoMod.Disable() quickCmdDoNotRun = false
quickCmdDoNotRun = true
quickCmdLastPath = "~/go/src"
quickCmds = [][]string{}
log.Warn("scanning allrepos")
os.Unsetenv("GO111MODULE") os.Unsetenv("GO111MODULE")
log.Warn("scanning allrepos")
for _, path := range me.allrepos { for _, path := range me.allrepos {
fullpath := "/home/jcarr/go/src/" + path fullpath := "/home/jcarr/go/src/" + path
// set the button text for the user
me.rerunGoMod.SetText("Running go.mod " + fullpath)
quickCmd(fullpath, []string{"pwd"})
quickCmd(fullpath, []string{"ls", "-l"})
quickCmd(fullpath, []string{"git", "status"}) // TODO: process this?
quickCmd(fullpath, []string{"rm", "go.mod", "go.sum"})
quickCmd(fullpath, []string{"go", "mod", "init"}) quickCmd(fullpath, []string{"go", "mod", "init"})
// don't hammer google's golang versioning system
if quickCmdDoNotRun {
quickCmd(fullpath, []string{"sleep", ".2"})
} else {
log.Sleep(.2)
}
quickCmd(fullpath, []string{"go", "mod", "tidy"}) quickCmd(fullpath, []string{"go", "mod", "tidy"})
// don't hammer google's golang versioning system
if quickCmdDoNotRun {
quickCmd(fullpath, []string{"sleep", ".1"})
} else {
log.Sleep(.1)
}
quickCmd(fullpath, []string{"git", "status"}) // TODO: process this?
} }
// re-enable the button
me.rerunGoMod.SetText("re-run go mod & go tidy")
me.script = quickCmds
setGitCommands()
me.rerunGoMod.Enable()
}) })
setCurrentBranch = groupvbox.NewButton("set all branches to", func() { setCurrentBranch = groupvbox.NewButton("set all branches to", func() {
log.Warn("scanning allrepos") log.Warn("scanning allrepos")
for repo, path := range me.allrepos { for repo, path := range me.allrepos {

View File

@ -2,8 +2,6 @@
package main package main
import ( import (
"go.wit.com/log"
"go.wit.com/gui" "go.wit.com/gui"
// "go.wit.com/gui/gadgets" // "go.wit.com/gui/gadgets"
) )
@ -14,42 +12,29 @@ func globalDisplayOptions(box *gui.Node) {
// grouphbox := groupvbox.NewBox("bw hbox", true) // grouphbox := groupvbox.NewBox("bw hbox", true)
groupvbox.NewButton("Show Repository Window", func() { groupvbox.NewButton("Show Repository Window", func() {
repoworld() // repoworld()
// reposwin.Draw() reposwin.Toggle()
}) })
me.autoHidePerfect = groupvbox.NewCheckbox("Hide repos") me.autoHidePerfect = groupvbox.NewCheckbox("Hide Perfectly clean repos").SetChecked(true)
me.autoHidePerfect.Custom = func() { me.autoHidePerfect.Custom = func() {
me.autoHidePerfect.SetText("Hide Perfectly clean repos") if me.autoHidePerfect.Checked() {
if me.autoHidePerfect.Bool() { hidePerfect()
log.Warn("Should hide here")
} else { } else {
log.Warn("Should show here") showAll()
} }
} }
me.autoHidePerfect.Set(true)
groupvbox.NewButton("hide perfect", func() {
me.autoHidePerfect.SetText("Hide Perfectly clean repos")
hidePerfect()
})
groupvbox.NewButton("show all", func() { groupvbox.NewButton("show all", func() {
for repo, _ := range me.allrepos { for repo, _ := range me.allrepos {
if repo.dirtyLabel.String() == "PERFECT" { if repo.dirtyLabel.String() == "PERFECT" {
if repo.hidden { if repo.hidden {
repo.show() repo.Show()
} }
// return // return
} }
} }
}) })
groupvbox.NewButton("reposwin.Hide()", func() {
reposwin.Hide()
})
groupvbox.NewButton("reposwin.Show()", func() {
reposwin.Show()
})
groupvbox.NewButton("status.Update() all", func() { groupvbox.NewButton("status.Update() all", func() {
for repo, _ := range me.allrepos { for repo, _ := range me.allrepos {
repo.status.Update() repo.status.Update()
@ -69,40 +54,17 @@ func hidePerfect() {
if repo.hidden { if repo.hidden {
continue continue
} }
repo.hide() repo.Hide()
// return // return
} }
} }
} }
func (r *repo) hide() { func showAll() {
r.pLabel.Hide() for repo, _ := range me.allrepos {
r.lastTag.Hide() if repo.hidden {
r.vLabel.Hide() repo.Show()
repo.hidden = false
r.masterName.Hide() }
r.masterVersion.Hide() }
r.develName.Hide()
r.develVersion.Hide()
r.userName.Hide()
r.userVersion.Hide()
r.dirtyLabel.Hide()
r.showButton.Hide()
r.hidden = true
}
func (r *repo) show() {
r.pLabel.Show()
r.lastTag.Show()
r.vLabel.Show()
r.masterName.Show()
r.masterVersion.Show()
r.develName.Show()
r.develVersion.Show()
r.userName.Show()
r.userVersion.Show()
r.dirtyLabel.Show()
r.showButton.Show()
r.hidden = false
} }

View File

@ -56,7 +56,7 @@ func globalResetOptions(box *gui.Node) {
break break
} }
} }
newCmds = append(newCmds, []string{"cd", "."}) newCmds = append(newCmds, []string{"cd", "/home/jcarr/"})
newCmds = append(newCmds, []string{"rm", "-rf", "go/src/"}) newCmds = append(newCmds, []string{"rm", "-rf", "go/src/"})
newCmds = append(newCmds, []string{"chmod", "700", "-R", "go/pkg/"}) newCmds = append(newCmds, []string{"chmod", "700", "-R", "go/pkg/"})
newCmds = append(newCmds, []string{"rm", "-rf", "go/pkg/"}) newCmds = append(newCmds, []string{"rm", "-rf", "go/pkg/"})

20
go.mod
View File

@ -1,20 +0,0 @@
module go.wit.com/apps/autotypist
go 1.21.4
require (
go.wit.com/gui v0.12.16
go.wit.com/lib/gadgets v0.12.9
go.wit.com/lib/gui/repostatus v0.12.13
go.wit.com/log v0.5.5
)
require (
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/hashicorp/go-multierror v1.0.0 // indirect
github.com/posener/complete v1.2.3 // indirect
go.wit.com/dev/alexflint/arg v1.4.5 // indirect
go.wit.com/dev/alexflint/scalar v1.2.1 // indirect
go.wit.com/dev/davecgh/spew v1.1.4 // indirect
go.wit.com/widget v1.1.5 // indirect
)

28
go.sum
View File

@ -1,28 +0,0 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/go-multierror v1.0.0 h1:iVjPR7a6H0tWELX5NxNe7bYopibicUzc7uPribsnS6o=
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/posener/complete v1.2.3 h1:NP0eAhjcjImqslEwo/1hq7gpajME0fTLTezBKDqfXqo=
github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
go.wit.com/dev/alexflint/arg v1.4.5 h1:asDx5f9IlfpknKjPBqqb2qndE91Pbo7ZDkWUgddfMhY=
go.wit.com/dev/alexflint/arg v1.4.5/go.mod h1:wnWc+c6z8kSdDKYriMf6RpM+FiXmo5RYp/t4FNi0MU0=
go.wit.com/dev/alexflint/scalar v1.2.1 h1:loXOcbVnd+8YeJRLey+XXidecBiedMDO00zQ26TvKNs=
go.wit.com/dev/alexflint/scalar v1.2.1/go.mod h1:+rYsfxqdI2cwA8kJ7GCMwWbNJvfvWUurOCXLiwdTtSs=
go.wit.com/dev/davecgh/spew v1.1.4 h1:C9hj/rjlUpdK+E6aroyLjCbS5MFcyNUOuP1ICLWdNek=
go.wit.com/dev/davecgh/spew v1.1.4/go.mod h1:sihvWmnQ/09FWplnEmozt90CCVqBtGuPXM811tgfhFA=
go.wit.com/gui v0.12.16 h1:GBiPiDyzkGCxwNegehHiONmNppaqyFZv7iteLUHJ/Po=
go.wit.com/gui v0.12.16/go.mod h1:27+THr2a84GZ61KKUuN30WYnYoSsBewllUKc+fnWLto=
go.wit.com/lib/gadgets v0.12.9 h1:yayXQDiAENfMElRMeh7Yab1f6HNkiy5Aw6KNP5Wd1DI=
go.wit.com/lib/gadgets v0.12.9/go.mod h1:Hb/vSiW22hPJjTVA1mShQ6HuqQ7dHGB95WLEfZlPO3M=
go.wit.com/lib/gui/repostatus v0.12.13 h1:kumPC2wEYjAk+mCQzjrNfcr40CY0qaXva4EjfW0kExk=
go.wit.com/lib/gui/repostatus v0.12.13/go.mod h1:QxWg6Ml68eiz7mhrX+pF0oXHtixpzllaEi1XDP/VaH4=
go.wit.com/log v0.5.5 h1:bK3b94uVKgev4jB5wg06FnvCFBEapQICTSH2YW+CWr4=
go.wit.com/log v0.5.5/go.mod h1:BaJBfHFqcJSJLXGQ9RHi3XVhPgsStxSMZRlaRxW4kAo=
go.wit.com/widget v1.1.5 h1:jx5hJ2WLZJnCcvMuaLHegzpNlzwo+0kOkzsRkzRiB30=
go.wit.com/widget v1.1.5/go.mod h1:I8tnD3x3ECbB/CRNnLCdC+uoyk7rK0AEkzK1bQYSqoQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

10
main.go
View File

@ -25,7 +25,7 @@ func main() {
me.myGui.Default() me.myGui.Default()
autotypistWindow() autotypistWindow()
// repoworld() repoworld()
log.Sleep(.3) log.Sleep(.3)
// hidePerfect() // hidePerfect()
gui.Watchdog() gui.Watchdog()
@ -60,7 +60,7 @@ func addRepo(grid *gui.Node, path string, master string, devel string, user stri
return return
} }
log.Warn("status window exists. trying TestDraw() here") log.Warn("status window exists. trying TestDraw() here")
newRepo.status.Show() newRepo.status.Toggle()
newRepo.status.Update() newRepo.status.Update()
}) })
if path == "" { if path == "" {
@ -68,9 +68,9 @@ func addRepo(grid *gui.Node, path string, master string, devel string, user stri
newRepo.pButton.Hide() newRepo.pButton.Hide()
} }
newRepo.status = repostatus.New(me.myGui, newRepo.path) newRepo.status = repostatus.New(me.myGui, newRepo.path)
newRepo.status.SetMasterName(master) newRepo.status.SetMasterBranchName(master)
newRepo.status.SetDevelName(devel) newRepo.status.SetDevelBranchName(devel)
newRepo.status.SetUserName(user) newRepo.status.SetUserBranchName(user)
newRepo.hidden = false newRepo.hidden = false
newRepo.status.Update() newRepo.status.Update()
newRepo.newScan() newRepo.newScan()

View File

@ -40,3 +40,39 @@ func myrepolist() []string {
lines := strings.Split(out, "\n") lines := strings.Split(out, "\n")
return lines return lines
} }
func (r *repo) Hide() {
r.pLabel.Hide()
r.pButton.Hide()
r.cButton.Hide()
r.lastTag.Hide()
r.vLabel.Hide()
r.masterName.Hide()
r.masterVersion.Hide()
r.develName.Hide()
r.develVersion.Hide()
r.userName.Hide()
r.userVersion.Hide()
r.dirtyLabel.Hide()
r.showButton.Hide()
r.hidden = true
}
func (r *repo) Show() {
r.pLabel.Show()
r.pButton.Show()
r.cButton.Show()
r.lastTag.Show()
r.vLabel.Show()
r.masterName.Show()
r.masterVersion.Show()
r.develName.Show()
r.develVersion.Show()
r.userName.Show()
r.userVersion.Show()
r.dirtyLabel.Show()
r.showButton.Show()
r.hidden = false
}

39
scan.go
View File

@ -19,41 +19,38 @@ func (r *repo) newScan() bool {
log.Warn("repo does not exist", r.getPath()) log.Warn("repo does not exist", r.getPath())
return false return false
} }
mn := r.status.GetMasterName() mn := r.status.GetMasterBranchName()
r.masterName.Set(mn) r.masterName.SetLabel(mn)
mv := r.status.GetMasterVersion() mv := r.status.GetMasterVersion()
r.masterVersion.Set(mv) r.masterVersion.SetLabel(mv)
dn := r.status.GetDevelName() dn := r.status.GetDevelBranchName()
r.develName.Set(dn) r.develName.SetLabel(dn)
dv := r.status.GetDevelVersion() dv := r.status.GetDevelVersion()
r.develVersion.Set(dv) r.develVersion.SetLabel(dv)
un := r.status.GetUserName() un := r.status.GetUserBranchName()
r.userName.Set(un) r.userName.SetLabel(un)
uv := r.status.GetUserVersion() uv := r.status.GetUserVersion()
r.userVersion.Set(uv) r.userVersion.SetLabel(uv)
cbname := r.status.GetCurrentBranchName() cbname := r.status.GetCurrentBranchName()
cbversion := r.status.GetCurrentBranchVersion() cbversion := r.status.GetCurrentBranchVersion()
lasttag := r.status.GetLastTagVersion() lasttag := r.status.GetLastTagVersion()
r.lastTag.Set(lasttag) r.lastTag.SetLabel(lasttag)
r.vLabel.Set(cbname + " " + cbversion) r.vLabel.SetLabel(cbname + " " + cbversion)
status := r.getStatus() if r.status.Changed() {
if status == "dirty" { log.Warn("should scan here")
r.dirtyLabel.Set(status)
return false
}
if status == "merge" {
r.dirtyLabel.Set(status)
return false
} }
status := r.status.GetStatus()
r.dirtyLabel.SetLabel(status)
if status == "PERFECT" { if status == "PERFECT" {
r.dirtyLabel.Set(status) if me.autoHidePerfect.Checked() {
r.Hide()
}
return true return true
} }
r.dirtyLabel.Set("unknown " + status)
return false return false
} }

View File

@ -64,5 +64,5 @@ func setGitCommands() {
log.Warn("s =", s) log.Warn("s =", s)
tmp = append(tmp, s) tmp = append(tmp, s)
} }
cmds.Set(strings.Join(tmp, "\n")) cmds.SetText(strings.Join(tmp, "\n"))
} }