From 8cd7387cc0bad590b2b63925e4ca8d6fc17a8f61 Mon Sep 17 00:00:00 2001 From: Filipe Brandenburger Date: Fri, 29 Aug 2014 23:34:39 -0700 Subject: [PATCH] Include `-dirty` suffix in version info when building on a dirty tree Ensure the output of `git describe` will include the `-dirty` suffix when building on a tree with modified files in it. Tested: - ... Signed-off-by: Filipe Brandenburger --- hack/config-go.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hack/config-go.sh b/hack/config-go.sh index c0fc26153ea..fcd4918f7d6 100644 --- a/hack/config-go.sh +++ b/hack/config-go.sh @@ -47,6 +47,12 @@ kube::version_ldflags() { # Use git describe to find the version based on annotated tags. if git_version=$(git describe --abbrev=14 "${git_commit}^{commit}" 2>/dev/null); then + if [[ "${git_tree_state}" == "dirty" ]]; then + # git describe --dirty only considers changes to existing files, but + # that is problematic since new untracked .go files affect the build, + # so use our idea of "dirty" from git status instead. + git_version+="-dirty" + fi ldflags+=(-X "${KUBE_GO_PACKAGE}/pkg/version.gitVersion" "${git_version}") fi fi