From de49589ab5d4254b9792c712127ba5b718d762b1 Mon Sep 17 00:00:00 2001 From: David McMahon Date: Wed, 8 Nov 2017 15:37:49 -0800 Subject: [PATCH] Capture git export-subst strings in version.sh for 'git archive' use. Eliminate the need to update pkg/version/base.go on release branch tagging. Kubernetes-commit: 9a9d11bb75010f43d771bf0449d462bc153760ce --- pkg/version/base.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/version/base.go b/pkg/version/base.go index c377705f..7ab0ed3a 100644 --- a/pkg/version/base.go +++ b/pkg/version/base.go @@ -51,9 +51,13 @@ var ( // semantic version is a git hash, but the version itself is no // longer the direct output of "git describe", but a slight // translation to be semver compliant. + + // NOTE: The $Format strings are replaced during 'git archive' thanks to the + // companion .gitattributes file containing 'export-subst' in this same + // directory. See also https://git-scm.com/docs/gitattributes gitVersion string = "v0.0.0-master+$Format:%h$" - gitCommit string = "$Format:%H$" // sha1 from git, output of $(git rev-parse HEAD) - gitTreeState string = "not a git tree" // state of git tree, either "clean" or "dirty" + gitCommit string = "$Format:%H$" // sha1 from git, output of $(git rev-parse HEAD) + gitTreeState string = "" // state of git tree, either "clean" or "dirty" buildDate string = "1970-01-01T00:00:00Z" // build date in ISO8601 format, output of $(date -u +'%Y-%m-%dT%H:%M:%SZ') )