summaryrefslogtreecommitdiff
path: root/scan.go
diff options
context:
space:
mode:
Diffstat (limited to 'scan.go')
-rw-r--r--scan.go55
1 files changed, 48 insertions, 7 deletions
diff --git a/scan.go b/scan.go
index c5b5ae5..f60f73a 100644
--- a/scan.go
+++ b/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()
+ }
+ }
+}