Skip to content

Commit 94aeafd

Browse files
Merge pull request #961 from tkashem/bz-662263
Bug 1662263: include git sha in ART builds
2 parents 4a943b2 + ce8cd26 commit 94aeafd

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Makefile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@ IMAGE_TAG ?= "dev"
1616
SPECIFIC_UNIT_TEST := $(if $(TEST),-run $(TEST),)
1717
export GO111MODULE=on
1818

19+
# ART builds are performed in dist-git, with content (but not commits) copied
20+
# from the source repo. Thus at build time if your code is inspecting the local
21+
# git repo it is getting unrelated commits and tags from the dist-git repo,
22+
# not the source repo.
23+
# For ART image builds, SOURCE_GIT_COMMIT, SOURCE_GIT_TAG, SOURCE_DATE_EPOCH
24+
# variables are inserted in Dockerfile to enable recovering the original git
25+
# metadata at build time.
26+
GIT_COMMIT := $(if $(SOURCE_GIT_COMMIT),$(SOURCE_GIT_COMMIT),$(shell git rev-parse HEAD))
27+
1928
.PHONY: build test run clean vendor schema-check \
2029
vendor-update coverage coverage-html e2e .FORCE
2130

@@ -54,7 +63,7 @@ build-linux: build_cmd=build
5463
build-linux: arch_flags=GOOS=linux GOARCH=386
5564
build-linux: clean $(CMDS)
5665

57-
$(CMDS): version_flags=-ldflags "-X $(PKG)/pkg/version.GitCommit=`git rev-parse --short HEAD` -X $(PKG)/pkg/version.OLMVersion=`cat OLM_VERSION`"
66+
$(CMDS): version_flags=-ldflags "-X $(PKG)/pkg/version.GitCommit=$(GIT_COMMIT) -X $(PKG)/pkg/version.OLMVersion=`cat OLM_VERSION`"
5867
$(CMDS):
5968
CGO_ENABLED=0 $(arch_flags) go $(build_cmd) $(MOD_FLAGS) $(version_flags) -o bin/$(shell basename $@) $@
6069

0 commit comments

Comments
 (0)