Skip to content

Commit b06ad2a

Browse files
authored
Merge pull request #85 from gman0/backport-pr-82-2
version: add tracking clean workdir and fix printing
2 parents fa7315e + 067aeb5 commit b06ad2a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

internal/version/version.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ var (
2727
buildTime = time.Now()
2828
version = "unreleased"
2929
commit string
30+
treestate string
3031
metadata string
3132
)
3233

@@ -41,6 +42,11 @@ func Commit() string {
4142
return commit
4243
}
4344

45+
// TreeState returns the git tree state. Can be "clean" or "dirty".
46+
func TreeState() string {
47+
return treestate
48+
}
49+
4450
// Metadata returns metadata passed during build.
4551
func Metadata() string {
4652
return metadata
@@ -53,6 +59,6 @@ func BuildTime() time.Time {
5359

5460
// FullVersion constructs a string with full version information.
5561
func FullVersion() string {
56-
return fmt.Sprintf("%s (commit: %s; build time: %s; metadata: %s)",
57-
Version(), Commit(), Metadata(), BuildTime())
62+
return fmt.Sprintf("%s (commit: %s (%s); build time: %s; metadata: %s)",
63+
Version(), Commit(), TreeState(), BuildTime(), Metadata())
5864
}

0 commit comments

Comments
 (0)