summaryrefslogtreecommitdiff
path: root/humanForgedTable.go
blob: a4d19f5913416f578394fe88db2cdda8fa574ffa (plain)
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
// Copyright 2025 WIT.COM Inc Licensed GPL 3.0

package forgepb

import (
	"go.wit.com/lib/protobuf/gitpb"
)

func (f *Forge) PrintForgedTable(pb *gitpb.Repos) {
	tablePB := f.makeForgedTable(pb)
	tablePB.PrintTable()
}

func (f *Forge) makeForgedTable(pb *gitpb.Repos) *gitpb.ReposTable {
	t := pb.NewTable("forgedList")
	t.NewUuid()

	var col *gitpb.RepoAnyFunc

	col = t.AddMasterVersion()
	col.Width = 7

	col = t.AddMasterBranchName()
	col.Width = 10

	col = t.AddStringFunc("blah", func(r *gitpb.Repo) string {
		if r.Tags == nil {
			return "tags=nil"
		}
		if r.Tags.Master == nil {
			return "mtag=nil"
		}
		return r.Tags.Master.Hash
	})
	col.Width = 12

	col = t.AddNamespace()
	col.Width = 32

	col = t.AddURL()
	col.Width = 32

	col = t.AddFullPath()
	col.Width = -1
	return t
}