totals by branch type

This commit is contained in:
Jeff Carr 2025-08-17 23:00:14 -05:00
parent 8b3f289eae
commit 0de26aee43
1 changed files with 39 additions and 12 deletions

View File

@ -38,7 +38,7 @@ import (
func (f *Forge) PrintHumanTable(allr *gitpb.Repos) {
log.DaemonMode(true)
var count int
t := new(tally)
// print the header
args := []string{"repopath", "cur br", "age", "master", "devel", "user", "curver", "lasttag", "next", "repo type"}
@ -49,15 +49,15 @@ func (f *Forge) PrintHumanTable(allr *gitpb.Repos) {
for all.Scan() {
repo := all.Next()
f.printRepoToTable(repo, sizes, false)
count += 1
tallyBranchTotals(t, repo)
}
log.Info("Total git repositories:", count)
log.Infof("Total repositories: %d (%d master) (%d devel) (%d user) (%d unknown)\n", t.total, t.master, t.devel, t.user, t.unknown)
}
func (f *Forge) PrintForgedTable(allr *gitpb.Repos) {
log.DaemonMode(true)
var count int
t := new(tally)
// print the header
args := []string{"namespace", "cur br", "age", "master", "devel", "last tag", "", "", "", ""}
@ -68,15 +68,15 @@ func (f *Forge) PrintForgedTable(allr *gitpb.Repos) {
for all.Scan() {
repo := all.Next()
f.printForgedToTable(repo, sizes)
count += 1
tallyBranchTotals(t, repo)
}
log.Info("Total git repositories:", count)
log.Infof("Total repositories: %d (%d master) (%d devel) (%d user) (%d unknown)\n", t.total, t.master, t.devel, t.user, t.unknown)
}
func (f *Forge) PrintHumanTableFull(allr *gitpb.Repos) {
log.DaemonMode(true)
var count int
t := new(tally)
// print the header
args := []string{"cur br", "age", "master", "devel", "user", "curver", "lasttag", "next", "repo type", "repopath"}
@ -87,16 +87,16 @@ func (f *Forge) PrintHumanTableFull(allr *gitpb.Repos) {
for all.Scan() {
repo := all.Next()
f.printRepoToTable(repo, sizes, true)
count += 1
tallyBranchTotals(t, repo)
}
log.Info("Total git repositories:", count)
log.Infof("Total repositories: %d (%d master) (%d devel) (%d user) (%d unknown)\n", t.total, t.master, t.devel, t.user, t.unknown)
}
// also shows which files are dirty
func (f *Forge) PrintHumanTableDirty(allr *gitpb.Repos) {
log.DaemonMode(true)
var count int
t := new(tally)
// print the header
args := []string{"repopath", "cur br", "age", "master", "devel", "user", "curver", "lasttag", "next", "repo type"}
@ -113,9 +113,36 @@ func (f *Forge) PrintHumanTableDirty(allr *gitpb.Repos) {
var mver string = repo.GetMasterVersion()
repo.Tags.GetAge(mver)
count += 1
tallyBranchTotals(t, repo)
}
log.Info("Total git repositories:", count)
log.Infof("Total repositories: %d (%d master) (%d devel) (%d user) (%d unknown)\n", t.total, t.master, t.devel, t.user, t.unknown)
}
// used to count which repos are on which branches (master/main, devel, user)
type tally struct {
total int
master int
devel int
user int
unknown int
}
func tallyBranchTotals(t *tally, repo *gitpb.Repo) {
t.total += 1
if repo.GetCurrentBranchName() == repo.GetMasterBranchName() {
t.master += 1
return
}
if repo.GetCurrentBranchName() == repo.GetDevelBranchName() {
t.devel += 1
return
}
if repo.GetCurrentBranchName() == repo.GetUserBranchName() {
t.user += 1
return
}
t.unknown += 1
}
func standardTable5(arg1, arg2, arg3, arg4, arg5 string) string {