diff options
| author | Jeff Carr <[email protected]> | 2024-01-26 02:04:19 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-01-26 02:04:19 -0600 |
| commit | 1f757d26ff6feb54e50844ece059ff220ff18a49 (patch) | |
| tree | 78f7d5cc17a0004e1d60852579134006604ba3a7 /scan.go | |
| parent | 4773d43cf6a39c6d6efdf1703adbe4db8707330e (diff) | |
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 <[email protected]>
Diffstat (limited to 'scan.go')
| -rw-r--r-- | scan.go | 55 |
1 files changed, 48 insertions, 7 deletions
@@ -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() + } + } +} |
