repolist/scan.go

83 lines
1.8 KiB
Go

package repolist
import (
"fmt"
"os/user"
"strings"
"go.wit.com/log"
)
func (r *RepoList) SetAutoScan(b bool) {
me.autoScan = b
}
func (r *RepoList) ScanRepositories() (int, string) {
var i int
t := TimeFunction(func() {
for _, repo := range me.allrepos {
i += 1
repo.NewScan()
}
})
s := fmt.Sprint(t)
log.Info("Scanned", i, "repositories. todo: count/show changes", s)
return i, s
}
func (r *Repo) NewScan() bool {
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.currentName.SetLabel(cbname)
// r.currentVersion.SetLabel(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)
}
}
// r.targetV.SetText(r.Status.GetTargetVersion())
status := r.Status.GetStatus()
r.dirtyLabel.SetLabel(status)
if status == "PERFECT" {
if me.autoHidePerfect {
r.Hide()
}
return true
}
return false
}