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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
// Copyright 2025 WIT.COM Inc Licensed GPL 3.0
package forgepb
import (
"fmt"
"go.wit.com/lib/cobol"
"go.wit.com/lib/protobuf/gitpb"
"go.wit.com/log"
)
// this is the default table layout for repos in forge
func (f *Forge) PrintTable(pb *gitpb.Repos) {
f.PrintDefaultTB(pb)
}
func (f *Forge) PrintDefaultTB(pb *gitpb.Repos) string {
pb.SortByUserVersion()
tablePB := f.makeDefaultTB(pb)
tablePB.PrintTable()
var dirty int
var writable int
var bins int
var protos int
for repo := range pb.IterAll() {
if repo.IsDirty() {
dirty += 1
}
if repo.IsBinary() {
bins += 1
}
if repo.IsProtobuf() {
protos += 1
}
if f.Config.IsWritable(repo.Namespace) {
writable += 1
}
}
return log.Sprintf("f.DefaultRepos: total=(%d) dirty=(%d) writable=(%d) binaries=(%d) protobufs(%d)", pb.Len(), dirty, writable, bins, protos)
}
func (f *Forge) NormalCheckTB(pb *gitpb.Repos) string {
var col *gitpb.RepoFunc
t := f.makeDefaultBaseTB(pb)
col = t.AddStateChange()
col.Width = 16
col = t.AddState()
col.Width = -1
t.PrintTable()
return log.Sprintf("f.NormalCheck: total=(%d)", pb.Len())
}
func (f *Forge) getRepoType(repo *gitpb.Repo) string {
var rtype string = repo.GetRepoType()
switch rtype {
case "binary":
rtype = "GO bin"
case "library":
rtype = "GO lib"
case "protobuf":
rtype = "GO pb"
}
if f.IsPrivate(repo) {
rtype = "priv"
}
return rtype
}
func (f *Forge) makeDefaultTB(pb *gitpb.Repos) *gitpb.ReposTable {
t := f.makeDefaultBaseTB(pb)
var col *gitpb.RepoFunc
col = t.AddStringFunc("type", func(r *gitpb.Repo) string {
return f.getRepoType(r)
})
col.Width = 6
col = t.AddStringFunc("r/w", func(r *gitpb.Repo) string {
if f.IsWritable(r) {
return "rw"
}
return ""
})
col.Width = 3
col = t.AddState()
col.Width = 12
col = t.AddURL()
col.Width = -1
return t
}
func (f *Forge) makeDefaultBaseTB(pb *gitpb.Repos) *gitpb.ReposTable {
t := pb.NewTable("forgedList")
t.NewUuid()
var col *gitpb.RepoFunc
col = t.AddNamespace()
col.Width = 33
col.Header.Name = fmt.Sprintf("Repos (%s) (%s)", f.cache.Name, f.mode.String())
col = t.AddCurrentBranchName()
col.Width = 7
col.Header.Name = "branch"
col = t.AddStringFunc("age", func(r *gitpb.Repo) string {
if r.IsDirty() {
return ""
}
dur := r.NewestAge()
return cobol.FormatDuration(dur)
})
col.Width = 5
col = t.AddStringFunc("user", func(r *gitpb.Repo) string {
ver := r.GetUserVersion()
if r.IsDirty() {
ver = "* " + ver
}
return ver
})
col.Width = 14
col = t.AddDevelVersion()
col.Width = 12
col.Header.Name = "devel"
col = t.AddMasterVersion()
col.Width = 12
col.Header.Name = "master"
return t
}
|