summaryrefslogtreecommitdiff
path: root/tableBuild.go
blob: 1b8399370888a3749fa5d97f822ce0e446d5680b (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
47
48
49
50
51
52
// Copyright 2025 WIT.COM Inc Licensed GPL 3.0

package forgepb

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

// returns
func (f *Forge) GetPackageVersion(repo *gitpb.Repo) string {
	var s string

	s = repo.GetUserVersion()
	if repo.CheckDirty() {
		s += "-dirty"
	}
	return s
}

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) GetBuildBaseTB(pb *gitpb.Repos) *gitpb.ReposTable {
	t := pb.NewTable(".deb details")
	t.NewUuid()

	var col *gitpb.RepoFunc

	col = t.AddStringFunc("Build Version", func(r *gitpb.Repo) string {
		return f.GetPackageVersion(r)
	})
	col.Width = 24

	col = t.AddStringFunc("RepoType", func(r *gitpb.Repo) string {
		return f.GetRepoType(r)
	})
	col.Width = 8
	return t
}