allow scan every minute
move go mod status into repostatus working on improving logic of which package to release next Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
4773d43cf6
commit
1f757d26ff
|
@ -53,6 +53,12 @@ func globalDisplayOptions(box *gui.Node) {
|
|||
if release.win == nil {
|
||||
log.Info("Creating the Release Window")
|
||||
createReleaseWindow()
|
||||
for _, repo := range me.allrepos {
|
||||
repo.status.Update()
|
||||
repo.newScan()
|
||||
}
|
||||
// open the repo window
|
||||
reposwin.Toggle()
|
||||
log.Info("Toggling the Release Window")
|
||||
release.win.Toggle()
|
||||
}
|
||||
|
@ -93,6 +99,7 @@ func globalDisplayOptions(box *gui.Node) {
|
|||
globalDisplayShow()
|
||||
}
|
||||
}
|
||||
me.scanEveryMinute = group1.NewCheckbox("Scan every minute").SetChecked(false)
|
||||
|
||||
group1.NewButton("status.Update() all", func() {
|
||||
for _, repo := range me.allrepos {
|
||||
|
|
33
main.go
33
main.go
|
@ -3,8 +3,10 @@ package main
|
|||
|
||||
import (
|
||||
"embed"
|
||||
"fmt"
|
||||
"os/user"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"go.wit.com/log"
|
||||
|
||||
|
@ -28,9 +30,34 @@ func main() {
|
|||
autotypistWindow()
|
||||
repoworld()
|
||||
|
||||
// keeps the app alive
|
||||
// TODO: rescan the status of the repos every so often?
|
||||
gui.Watchdog()
|
||||
// scan repos every 30 seconds
|
||||
// check every second for the checkbox changing
|
||||
var i int = 60
|
||||
myTicker(1 * time.Second, "newScan()", func() {
|
||||
i += 1
|
||||
if ! me.scanEveryMinute.Checked() {
|
||||
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)
|
||||
})
|
||||
}
|
||||
|
||||
func addRepo(grid *gui.Node, path string, master string, devel string, user string) {
|
||||
|
|
|
@ -75,11 +75,11 @@ func createReleaseWindow() {
|
|||
if ok, missing := release.current.status.CheckGoSum(); ok {
|
||||
log.Info("repo has go.sum requirements that are clean")
|
||||
release.status.SetValue("CLEAN")
|
||||
release.current.goSumStatus.SetValue("CLEAN")
|
||||
release.current.setGoSumStatus("CLEAN")
|
||||
} else {
|
||||
log.Info("BAD repo has go.sum requirements that are screwed up. missing:", missing)
|
||||
release.status.SetValue("BAD")
|
||||
release.current.goSumStatus.SetValue("BAD")
|
||||
release.current.setGoSumStatus("BAD")
|
||||
}
|
||||
if release.current.status.ReadOnly() {
|
||||
release.readOnly.SetValue("true")
|
||||
|
@ -115,11 +115,9 @@ func createReleaseWindow() {
|
|||
release.current.status.SetVersion("0", "13", "12", release.reason.String())
|
||||
})
|
||||
release.grid.NewButton("set ignore", func() {
|
||||
tmp := release.current.goSumStatus.String()
|
||||
tmp := release.current.getGoSumStatus()
|
||||
log.Info("trying to set repo IGNORE is now =", tmp)
|
||||
release.current.goSumStatus.SetValue("IGNORE")
|
||||
release.current.goSumStatus.SetLabel("IGNORE")
|
||||
release.current.goSumStatus.SetText("IGNORE")
|
||||
release.current.setGoSumStatus("IGNORE")
|
||||
})
|
||||
release.checkDirtyB = release.grid.NewButton("CheckDirty()", func() {
|
||||
buttonDisable()
|
||||
|
@ -136,15 +134,12 @@ func createReleaseWindow() {
|
|||
log.Info("Run CheckGoSum on repo:", tmp)
|
||||
if ok, missing := release.current.status.CheckGoSum(); ok {
|
||||
log.Info("repo has go.sum requirements that are clean")
|
||||
release.current.goSumStatus.SetValue("CLEAN")
|
||||
release.current.goSumStatus.SetLabel("CLEAN")
|
||||
release.current.goSumStatus.SetText("CLEAN")
|
||||
release.current.setGoSumStatus("CLEAN")
|
||||
} else {
|
||||
if missing == "" {
|
||||
log.Info("BAD VERSION repo has go.sum requirements that are screwed up.", tmp)
|
||||
if release.current.goSumStatus.String() == "BAD" {
|
||||
release.current.goSumStatus.SetLabel("BAD VERSION")
|
||||
release.current.goSumStatus.SetText("BAD VERSION")
|
||||
if release.current.getGoSumStatus() == "BAD" {
|
||||
release.current.setGoSumStatus("BAD VERSION")
|
||||
}
|
||||
} else {
|
||||
log.Info("BAD VERSION repo has go.sum requirements that are screwed up.", tmp)
|
||||
|
@ -230,7 +225,7 @@ func buttonEnable() {
|
|||
func findDirty2() bool {
|
||||
log.Info("findDirty2() START")
|
||||
for _, repo := range me.allrepos {
|
||||
goSumS := repo.goSumStatus.String()
|
||||
goSumS := repo.getGoSumStatus()
|
||||
dirtyS := repo.dirtyLabel.String()
|
||||
|
||||
if goSumS == "IGNORE" {
|
||||
|
@ -272,7 +267,7 @@ func setCurrentRepo(newcur *repo, s string, note string) bool {
|
|||
|
||||
func findNextDirty() bool {
|
||||
for _, repo := range me.allrepos {
|
||||
goSumS := repo.goSumStatus.String()
|
||||
goSumS := repo.getGoSumStatus()
|
||||
dirtyS := repo.dirtyLabel.String()
|
||||
|
||||
log.Info("findNextDirty()", repo.String(), goSumS, dirtyS)
|
||||
|
@ -303,10 +298,10 @@ func findNextDirty() bool {
|
|||
if goSumS == "DIRTY" {
|
||||
if ok, missing := repo.status.CheckGoSum(); ok {
|
||||
log.Info("repo has go.sum requirements that are clean")
|
||||
// repo.goSumStatus.SetLabel("CLEAN")
|
||||
// repo.setGoSumStatus("CLEAN")
|
||||
} else {
|
||||
log.Info("DIRTY 2 repo has go.sum requirements that are screwed up. missing:", missing)
|
||||
repo.goSumStatus.SetLabel("DIRTY 2")
|
||||
repo.setGoSumStatus("DIRTY 2")
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -321,7 +316,7 @@ func findNextDirty() bool {
|
|||
|
||||
func findNextRepo() {
|
||||
for _, repo := range me.allrepos {
|
||||
goSumS := repo.goSumStatus.String()
|
||||
goSumS := repo.getGoSumStatus()
|
||||
dirtyS := repo.dirtyLabel.String()
|
||||
|
||||
log.Info("findNextRepo()", repo.String(), goSumS, dirtyS)
|
||||
|
@ -346,10 +341,10 @@ func findNextRepo() {
|
|||
if goSumS == "DIRTY" {
|
||||
if ok, missing := repo.status.CheckGoSum(); ok {
|
||||
log.Info("repo has go.sum requirements that are clean")
|
||||
// repo.goSumStatus.SetLabel("CLEAN")
|
||||
// repo.setGoSumStatus("CLEAN")
|
||||
} else {
|
||||
log.Info("DIRTY 3 repo has go.sum requirements that are screwed up. missing:", missing)
|
||||
repo.goSumStatus.SetLabel("DIRTY 3")
|
||||
repo.setGoSumStatus("DIRTY 3")
|
||||
continue
|
||||
}
|
||||
|
||||
|
|
55
scan.go
55
scan.go
|
@ -2,6 +2,9 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"go.wit.com/log"
|
||||
|
||||
"go.wit.com/lib/gui/repostatus"
|
||||
|
@ -74,24 +77,33 @@ func (r *repo) getStatus() string {
|
|||
return "merge"
|
||||
}
|
||||
|
||||
func (r *repo) getGoSumStatus() string {
|
||||
return r.goSumStatus.String()
|
||||
}
|
||||
|
||||
func (r *repo) setGoSumStatus(s string) {
|
||||
r.goSumStatus.SetLabel(s)
|
||||
r.status.SetGoSumStatus(s)
|
||||
}
|
||||
|
||||
func scanGoSum() {
|
||||
for _, repo := range me.allrepos {
|
||||
latestversion := repo.status.GetLastTagVersion()
|
||||
if repo.goSumStatus.String() == "BAD" {
|
||||
if repo.getGoSumStatus() == "BAD" {
|
||||
continue
|
||||
}
|
||||
if repo.goSumStatus.String() == "DIRTY" {
|
||||
if repo.getGoSumStatus() == "DIRTY" {
|
||||
continue
|
||||
}
|
||||
if repo.status.CheckPrimativeGoMod() {
|
||||
log.Info("PRIMATIVE repo:", latestversion, repo.status.String())
|
||||
repo.goSumStatus.SetLabel("PRIMATIVE")
|
||||
repo.setGoSumStatus("PRIMATIVE")
|
||||
continue
|
||||
}
|
||||
if repo.status.CheckDirty() {
|
||||
log.Info("dirty repo:", latestversion, repo.status.String())
|
||||
log.Info("dirty repo.goSumStatus =", repo.goSumStatus.String())
|
||||
repo.goSumStatus.SetLabel("DIRTY")
|
||||
log.Info("dirty repo.getGoSumStatus =", repo.getGoSumStatus())
|
||||
repo.setGoSumStatus("DIRTY")
|
||||
|
||||
// release.repo.SetValue(repo.status.String())
|
||||
// release.status.SetValue("dirty")
|
||||
|
@ -102,10 +114,10 @@ func scanGoSum() {
|
|||
}
|
||||
if ok, missing := repo.status.CheckGoSum(); ok {
|
||||
log.Info("repo has go.sum requirements that are clean")
|
||||
repo.goSumStatus.SetLabel("CLEAN")
|
||||
repo.setGoSumStatus("CLEAN")
|
||||
} else {
|
||||
log.Info("repo has go.sum requirements that are screwed up. missing:", missing)
|
||||
repo.goSumStatus.SetLabel("BAD")
|
||||
repo.setGoSumStatus("BAD")
|
||||
|
||||
// release.repo.SetValue(repo.status.String())
|
||||
// release.status.SetValue("bad")
|
||||
|
@ -127,3 +139,32 @@ func scanGoSum() {
|
|||
}
|
||||
log.Info("scan() did everything, not sure what to do next")
|
||||
}
|
||||
|
||||
// timeFunction takes a function as an argument and returns the execution time.
|
||||
func timeFunction(f func()) time.Duration {
|
||||
startTime := time.Now() // Record the start time
|
||||
f() // Execute the function
|
||||
return time.Since(startTime) // Calculate the elapsed time
|
||||
}
|
||||
|
||||
func myTicker(t time.Duration, name string, f func()) {
|
||||
ticker := time.NewTicker(t)
|
||||
defer ticker.Stop()
|
||||
done := make(chan bool)
|
||||
/*
|
||||
go func() {
|
||||
time.Sleep(10 * time.Second)
|
||||
done <- true
|
||||
}()
|
||||
*/
|
||||
for {
|
||||
select {
|
||||
case <-done:
|
||||
fmt.Println("Done!")
|
||||
return
|
||||
case t := <-ticker.C:
|
||||
log.Verbose(name, "Current time: ", t)
|
||||
f()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,6 +49,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
|
||||
|
||||
|
|
Loading…
Reference in New Issue