summarylogtreecommitdiffstats
path: root/build_info.patch
blob: cb1af7991390f3a24711e07bea208fe7248ad988 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
diff --git a/Makefile b/Makefile
index b5c88bd6e..a5c95d273 100644
--- a/Makefile
+++ b/Makefile
@@ -36,7 +36,8 @@ SKAFFOLD_TEST_PACKAGES = ./pkg/skaffold/... ./cmd/... ./hack/... ./pkg/webhook/.
 GO_FILES = $(shell find . -type f -name '*.go' -not -path "./pkg/diag/*")
 
 VERSION_PACKAGE = $(REPOPATH)/pkg/skaffold/version
-COMMIT = $(shell git rev-parse HEAD)
+COMMIT ?= $(shell git rev-parse HEAD)
+TREE_STATE ?= $(if $(shell git status --porcelain),dirty,clean)
 
 ifeq "$(strip $(VERSION))" ""
 	override VERSION = $(shell git describe --always --tags --dirty)
@@ -45,6 +46,7 @@ endif
 GO_LDFLAGS = -X $(VERSION_PACKAGE).version=$(VERSION)
 GO_LDFLAGS += -X $(VERSION_PACKAGE).buildDate=$(shell date +'%Y-%m-%dT%H:%M:%SZ')
 GO_LDFLAGS += -X $(VERSION_PACKAGE).gitCommit=$(COMMIT)
+GO_LDFLAGS += -X $(VERSION_PACKAGE).gitTreeState=$(TREE_STATE)
 GO_LDFLAGS += -s -w
 
 GO_BUILD_TAGS_linux = osusergo netgo static_build release