package repolist import ( "fmt" "strconv" "strings" "go.wit.com/log" ) func (r *RepoList) RegisterHideFunction(f func(*RepoRow)) { me.hideFunction = f } func (r *RepoList) ScanRepositories() (int, string) { var i int var shown int var total int t := TimeFunction(func() { for _, repo := range me.allrepos { i += 1 changed := repo.NewScan() total += changed } var hidden int for _, repo := range me.allrepos { if repo.Hidden() { hidden += 1 } else { shown += 1 } } }) s := fmt.Sprint(t) tmp := strconv.Itoa(shown) + " repos shown" me.shownCount.SetText(tmp) me.duration.SetText(s) log.Info("repolist Scanned", i, "repositories.", total, "changes in", s) return i, s } func (r *RepoRow) NewScan() int { var changed int = 0 if r.Status == nil { log.Log(REPOWARN, "repo.Status = nil. not initialized for some reason") return changed } // run the repostatus update r.Status.Update() if r.lastTag != nil { if r.pb != nil { r.lastTag.SetLabel(r.pb.GetLastTag()) } else { log.Info("r.pb was nil") } } if r.masterVersion == nil { panic("what the fuck node") } if r.pb == nil { panic("what the fuck pb") } r.masterVersion.SetLabel(r.pb.GetMasterVersion()) r.develVersion.SetLabel(r.pb.GetDevelVersion()) r.userVersion.SetLabel(r.pb.GetUserVersion()) r.gitState.SetLabel(r.Status.GitState()) r.currentName.SetLabel(r.Status.GetCurrentBranchName()) r.currentVersion.SetLabel(r.Status.GetCurrentBranchVersion()) if r.Status.GitState() == "PERFECT" { r.Hide() } else { r.Show() } /* tags := []string{"%(objectname)", "%(creatordate)", "%(*authordate)", "%(refname)", "%(subject)"} format := strings.Join(tags, "_,,,_") cmd := []string{"git", "for-each-ref", "--sort=taggerdate", "--format", format} // log.Info("RUNNING:", strings.Join(cmd, " ")) result := r.pb.RunQuiet(cmd) if result.Error != nil { log.Warn("git for-each-ref error:", result.Error) } for i, line := range result.Stdout { log.Info(i, line) } if me.hideFunction == nil { // application didn't register a hide function // always show everything in that case r.Show() } else { me.hideFunction(r) } */ // print out whatever changes have happened if c, ok := r.Status.Changed(); ok { log.Log(REPOWARN, "something finally changed") c := strings.TrimSpace(c) for _, line := range strings.Split(c, "\n") { log.Log(REPOWARN, r.Status.Path(), line) changed += 1 } } return changed }