2024-02-17 08:39:55 -06:00
|
|
|
package repolist
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os/user"
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"go.wit.com/log"
|
|
|
|
)
|
|
|
|
|
2024-02-17 14:22:24 -06:00
|
|
|
func (r *RepoList) SetAutoScan(b bool) {
|
|
|
|
me.autoScan = b
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *RepoList) ScanRepositories() (int, string) {
|
2024-02-17 08:39:55 -06:00
|
|
|
var i int
|
|
|
|
t := timeFunction(func() {
|
|
|
|
for _, repo := range me.allrepos {
|
|
|
|
i += 1
|
2024-02-17 14:22:24 -06:00
|
|
|
repo.NewScan()
|
2024-02-17 08:39:55 -06:00
|
|
|
}
|
|
|
|
})
|
|
|
|
s := fmt.Sprint(t)
|
|
|
|
log.Info("Scanned", i, "repositories. todo: count/show changes", s)
|
|
|
|
return i, s
|
|
|
|
}
|
|
|
|
|
2024-02-17 14:22:24 -06:00
|
|
|
func (r *Repo) NewScan() bool {
|
2024-02-17 08:39:55 -06:00
|
|
|
if r.status == nil {
|
|
|
|
log.Warn("repo.status = nil. not initialized for some reason")
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
// first run the repostatus update
|
|
|
|
r.status.UpdateNew()
|
|
|
|
|
|
|
|
// now read those values and display them in our table
|
|
|
|
mname := r.status.GetMasterBranchName()
|
|
|
|
mver := r.status.GetMasterVersion()
|
|
|
|
mver = mver + " (" + mname + ")"
|
|
|
|
r.masterVersion.SetLabel(mver)
|
|
|
|
|
|
|
|
dname := r.status.GetDevelBranchName()
|
|
|
|
dver := r.status.GetDevelVersion()
|
|
|
|
if dname != "devel" {
|
|
|
|
dver = dver + " (" + dname + ")"
|
|
|
|
}
|
|
|
|
r.develVersion.SetLabel(dver)
|
|
|
|
|
|
|
|
uname := r.status.GetUserBranchName()
|
|
|
|
uver := r.status.GetUserVersion()
|
|
|
|
usr, _ := user.Current()
|
|
|
|
if uname != usr.Username {
|
|
|
|
uver = uver + " (" + uname + ")"
|
|
|
|
}
|
|
|
|
r.userVersion.SetLabel(uver)
|
|
|
|
|
|
|
|
cbname := r.status.GetCurrentBranchName()
|
|
|
|
cbversion := r.status.GetCurrentBranchVersion()
|
|
|
|
lasttag := r.status.GetLastTagVersion()
|
|
|
|
r.lastTag.SetLabel(lasttag)
|
|
|
|
r.vLabel.SetLabel(cbname + " " + cbversion)
|
|
|
|
|
|
|
|
if c, ok := r.status.Changed(); ok {
|
|
|
|
c := strings.TrimSpace(c)
|
|
|
|
for _, line := range strings.Split(c, "\n") {
|
|
|
|
log.Info(r.status.Path(), line)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
status := r.status.GetStatus()
|
|
|
|
r.dirtyLabel.SetLabel(status)
|
|
|
|
if status == "PERFECT" {
|
|
|
|
if me.autoHidePerfect {
|
|
|
|
r.Hide()
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|