2024-01-13 23:42:06 -06:00
|
|
|
package main
|
|
|
|
|
2024-01-18 00:58:14 -06:00
|
|
|
import (
|
2024-01-26 02:04:19 -06:00
|
|
|
"fmt"
|
2024-01-30 18:50:00 -06:00
|
|
|
"os/user"
|
2024-01-26 02:04:19 -06:00
|
|
|
"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()
|
2024-01-30 18:50:00 -06:00
|
|
|
usr, _ := user.Current()
|
|
|
|
if uname != usr.Username {
|
2024-01-20 18:45:55 -06:00
|
|
|
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
|
|
|
// 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()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|