summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-08-17 23:00:14 -0500
committerJeff Carr <[email protected]>2025-08-17 23:00:14 -0500
commit0de26aee43600bec508ea19d6ababe0c1ea5cd9a (patch)
tree022f76bdd9f7a1e9cc7c29f99489991eb203465c
parent8b3f289eae2b651ea03ec7af87776bb492ca1bc0 (diff)
totals by branch type
-rw-r--r--humanTable.go51
1 files changed, 39 insertions, 12 deletions
diff --git a/humanTable.go b/humanTable.go
index 850d3d1..aa47f59 100644
--- a/humanTable.go
+++ b/humanTable.go
@@ -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 {