1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
// Copyright 2025 WIT.COM Inc Licensed GPL 3.0
package gitpb
import (
"fmt"
"strings"
"go.wit.com/lib/cobol"
"go.wit.com/log"
)
func (pb *Stats) PrintTable() string {
t := pb.MakeTable("missing repos table")
// limit the number of lines
t.PrintTable()
return log.Sprintf("pb.StatsTB: top 16 refs total=(%d)", pb.Len())
}
func (pb *Stats) PrintTableLimit(limit int) string {
t := pb.MakeTable("missing repos table")
// limit the number of lines
t.PrintTableLimit(limit)
return log.Sprintf("pb.StatsTB: top %d refs total=(%d)", limit, pb.Len())
}
func (pb *Stats) MakeTable(name string) *StatsTable {
t := pb.NewTable(name)
t.NewUuid()
var col *StatFunc
col = t.AddPatchId()
col.Width = 10
col = t.AddStringFunc("Hash", func(r *Stat) string {
if r.Hash != "" {
return fmt.Sprintf("Hash(%8.8s)", r.Hash)
}
if r.TreeHash != "" {
return fmt.Sprintf("Tree(%8.8s)", r.TreeHash)
}
if r.TagHash != "" {
return fmt.Sprintf("Tag (%8.8s)", r.TagHash)
}
return fmt.Sprintf(" (%8.8s)", "")
})
col.Width = 20
col.Header.Name = "Git Hash"
col = t.AddStringFunc("age", func(r *Stat) string {
return cobol.Time(r.CommitTime)
})
col.Width = 27
col = t.AddTags()
col.Width = 20
// col = t.AddName()
// col.Width = 30
col = t.AddStringFunc("Name", func(r *Stat) string {
if strings.HasPrefix(r.Name, "refs/tags/") {
return strings.TrimPrefix(r.Name, "refs/tags/")
}
if strings.HasPrefix(r.Name, "refs/heads/") {
return strings.TrimPrefix(r.Name, "refs/heads/")
}
if strings.HasPrefix(r.Name, "refs/remotes/") {
return strings.TrimPrefix(r.Name, "refs/remotes/")
}
if strings.HasPrefix(r.Name, "refs/") {
return strings.TrimPrefix(r.Name, "refs/")
}
return fmt.Sprintf("%s", r.Name)
})
col.Width = 16
col = t.AddStringFunc("Submect", func(r *Stat) string {
// return fmt.Sprintf("subject(%s) name(%s)", r.SanitizedSubject, r.Name)
return fmt.Sprintf("%s", r.SanitizedSubject)
})
col.Width = -1
// col = t.AddSubject()
// col.Width = -1
return t
}
|