Merge pull request #138 from vmware-tanzu/no_dirty_in_version

Do not append "-dirty" to the version number when the git repo is dirty
This commit is contained in:
Andrew Keesler 2020-10-02 13:33:21 -04:00 committed by GitHub
commit 916db74d65
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 8 deletions

View File

@ -38,9 +38,10 @@ kube::version::get_version_vars() {
fi
fi
# If KUBE_GIT_VERSION is supplied and is not a valid Semantic Version, then refuse to build.
# If KUBE_GIT_VERSION is supplied
if [[ -n "${KUBE_GIT_VERSION:-""}" ]]; then
# If KUBE_GIT_VERSION is not a valid Semantic Version, then refuse to build.
if ! [[ "${KUBE_GIT_VERSION}" =~ ^v([0-9]+)\.([0-9]+)(\.[0-9]+)?(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$ ]]; then
echo "KUBE_GIT_VERSION should be a valid Semantic Version starting with a \"v\". Current value: ${KUBE_GIT_VERSION}"
echo "Please see more details here: https://semver.org"
@ -52,13 +53,6 @@ kube::version::get_version_vars() {
KUBE_GIT_MINOR=${BASH_REMATCH[2]}
fi
if [[ "${KUBE_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.
KUBE_GIT_VERSION+="-dirty"
fi
else
# KUBE_GIT_VERSION was not supplied
KUBE_GIT_VERSION='?.?.?'