2024-01-13 23:42:06 -06:00
|
|
|
// This is a simple example
|
|
|
|
package main
|
|
|
|
|
2024-01-18 00:58:14 -06:00
|
|
|
import (
|
2024-01-26 02:04:19 -06:00
|
|
|
"fmt"
|
|
|
|
"time"
|
|
|
|
|
2024-01-13 23:42:06 -06:00
|
|
|
"go.wit.com/log"
|
|
|
|
|
2024-01-18 00:58:14 -06:00
|
|
|
"go.wit.com/lib/gui/repostatus"
|
2024-01-13 23:42:06 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
func (r *repo) newScan() bool {
|
|
|
|
if r.status == nil {
|
|
|
|
log.Warn("repo.status = nil. not initialized for some reason")
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
// r.scan()
|
|
|
|
if repostatus.VerifyLocalGoRepo(r.getPath()) {
|
2024-01-23 11:22:33 -06:00
|
|
|
log.Verbose("repo actually exists", r.getPath())
|
2024-01-13 23:42:06 -06:00
|
|
|
} else {
|
|
|
|
log.Warn("repo does not exist", r.getPath())
|
|
|
|
return false
|
|
|
|
}
|
2024-01-20 18:45:55 -06:00
|
|
|
mname := r.status.GetMasterBranchName()
|
|
|
|
mver := r.status.GetMasterVersion()
|
|
|
|
if mname != "guimaster" {
|
|
|
|
mver = mver + " (" + mname + ")"
|
|
|
|
}
|
|
|
|
r.masterVersion.SetLabel(mver)
|
2024-01-13 23:42:06 -06:00
|
|
|
|
2024-01-20 18:45:55 -06:00
|
|
|
dname := r.status.GetDevelBranchName()
|
|
|
|
dver := r.status.GetDevelVersion()
|
|
|
|
if dname != "devel" {
|
|
|
|
dver = dver + " (" + dname + ")"
|
|
|
|
}
|
|
|
|
r.develVersion.SetLabel(dver)
|
2024-01-13 23:42:06 -06:00
|
|
|
|
2024-01-20 18:45:55 -06:00
|
|
|
uname := r.status.GetUserBranchName()
|
|
|
|
uver := r.status.GetUserVersion()
|
|
|
|
if uname != "jcarr" {
|
|
|
|
uver = uver + " (" + uname + ")"
|
|
|
|
}
|
|
|
|
r.userVersion.SetLabel(uver)
|
2024-01-13 23:42:06 -06:00
|
|
|
|
|
|
|
cbname := r.status.GetCurrentBranchName()
|
|
|
|
cbversion := r.status.GetCurrentBranchVersion()
|
2024-01-15 08:11:08 -06:00
|
|
|
lasttag := r.status.GetLastTagVersion()
|
2024-01-19 18:37:27 -06:00
|
|
|
r.lastTag.SetLabel(lasttag)
|
|
|
|
r.vLabel.SetLabel(cbname + " " + cbversion)
|
2024-01-13 23:42:06 -06:00
|
|
|
|
2024-01-19 18:37:27 -06:00
|
|
|
if r.status.Changed() {
|
|
|
|
log.Warn("should scan here")
|
2024-01-15 08:11:08 -06:00
|
|
|
}
|
2024-01-19 18:37:27 -06:00
|
|
|
status := r.status.GetStatus()
|
|
|
|
r.dirtyLabel.SetLabel(status)
|
2024-01-15 08:11:08 -06:00
|
|
|
if status == "PERFECT" {
|
2024-01-19 18:37:27 -06:00
|
|
|
if me.autoHidePerfect.Checked() {
|
|
|
|
r.Hide()
|
|
|
|
}
|
2024-01-15 08:11:08 -06:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2024-01-26 02:04:19 -06:00
|
|
|
func (r *repo) getGoSumStatus() string {
|
|
|
|
return r.goSumStatus.String()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *repo) setGoSumStatus(s string) {
|
|
|
|
r.goSumStatus.SetLabel(s)
|
|
|
|
r.status.SetGoSumStatus(s)
|
|
|
|
}
|
|
|
|
|
2024-01-26 11:59:59 -06:00
|
|
|
func (r *repo) checkDirty() bool {
|
|
|
|
if r.status.CheckDirty() {
|
|
|
|
log.Info("dirty repo:", r.status.String(), r.getGoSumStatus())
|
|
|
|
r.setGoSumStatus("DIRTY")
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2024-01-26 09:34:42 -06:00
|
|
|
func (r *repo) checkSafeGoSumRemake() {
|
|
|
|
if ok, bad := r.status.CheckSafeGoSumRemake(); ok {
|
|
|
|
log.Info("checkSafeGoSumRemake() is safe to redo")
|
|
|
|
r.setGoSumStatus("SAFE")
|
2024-01-26 11:59:59 -06:00
|
|
|
r.status.MakeRedomod()
|
2024-01-26 09:34:42 -06:00
|
|
|
} else {
|
|
|
|
log.Info("checkSafeGoSumRemake() is not safe. problems:", bad)
|
|
|
|
r.setGoSumStatus("BAD DEP")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-24 02:41:34 -06:00
|
|
|
func scanGoSum() {
|
2024-01-24 22:22:34 -06:00
|
|
|
for _, repo := range me.allrepos {
|
2024-01-24 02:41:34 -06:00
|
|
|
latestversion := repo.status.GetLastTagVersion()
|
2024-01-26 02:04:19 -06:00
|
|
|
if repo.getGoSumStatus() == "BAD" {
|
2024-01-24 02:41:34 -06:00
|
|
|
continue
|
|
|
|
}
|
2024-01-26 02:04:19 -06:00
|
|
|
if repo.getGoSumStatus() == "DIRTY" {
|
2024-01-24 02:41:34 -06:00
|
|
|
continue
|
|
|
|
}
|
2024-01-24 16:25:41 -06:00
|
|
|
if repo.status.CheckPrimativeGoMod() {
|
|
|
|
log.Info("PRIMATIVE repo:", latestversion, repo.status.String())
|
2024-01-26 02:04:19 -06:00
|
|
|
repo.setGoSumStatus("PRIMATIVE")
|
2024-01-24 16:25:41 -06:00
|
|
|
continue
|
|
|
|
}
|
2024-01-26 11:59:59 -06:00
|
|
|
if repo.checkDirty() {
|
2024-01-24 02:41:34 -06:00
|
|
|
log.Info("dirty repo:", latestversion, repo.status.String())
|
2024-01-26 02:04:19 -06:00
|
|
|
log.Info("dirty repo.getGoSumStatus =", repo.getGoSumStatus())
|
|
|
|
repo.setGoSumStatus("DIRTY")
|
2024-01-24 02:41:34 -06:00
|
|
|
|
|
|
|
// release.repo.SetValue(repo.status.String())
|
|
|
|
// release.status.SetValue("dirty")
|
|
|
|
// release.notes.SetValue("You must commit your changes\nbefore you can continue")
|
|
|
|
// release.current = repo
|
|
|
|
// release.openrepo.Enable()
|
|
|
|
continue
|
|
|
|
}
|
2024-01-24 22:22:34 -06:00
|
|
|
if ok, missing := repo.status.CheckGoSum(); ok {
|
2024-01-24 02:41:34 -06:00
|
|
|
log.Info("repo has go.sum requirements that are clean")
|
2024-01-26 02:04:19 -06:00
|
|
|
repo.setGoSumStatus("CLEAN")
|
2024-01-24 02:41:34 -06:00
|
|
|
} else {
|
2024-01-24 22:22:34 -06:00
|
|
|
log.Info("repo has go.sum requirements that are screwed up. missing:", missing)
|
2024-01-26 02:04:19 -06:00
|
|
|
repo.setGoSumStatus("BAD")
|
2024-01-24 02:41:34 -06:00
|
|
|
|
|
|
|
// release.repo.SetValue(repo.status.String())
|
|
|
|
// release.status.SetValue("bad")
|
|
|
|
// release.notes.SetValue("the go.sum file is wrong")
|
|
|
|
// release.current = repo
|
|
|
|
// release.openrepo.Enable()
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
status := repo.dirtyLabel.String()
|
|
|
|
if status == "PERFECT" {
|
|
|
|
continue
|
|
|
|
} else {
|
|
|
|
repo.status.Update()
|
|
|
|
repo.newScan()
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Info("repo:", latestversion, status, repo.status.String())
|
|
|
|
}
|
2024-01-29 09:38:32 -06:00
|
|
|
log.Info("scanGoSum() did everything, not sure what to do next")
|
2024-01-24 02:41:34 -06:00
|
|
|
}
|
2024-01-26 02:04:19 -06:00
|
|
|
|
|
|
|
// 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()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|