From 0ab52045cde0c16f9f99dad41cee019ff88e974e Mon Sep 17 00:00:00 2001 From: Magnus Edenhill Date: Thu, 20 Apr 2017 13:54:24 +0200 Subject: [PATCH] Use default fallback version if built outside of git repo (#92) --- configure.kafkacat | 2 +- mklove/modules/configure.gitversion | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/configure.kafkacat b/configure.kafkacat index 7bb26b6b..01935d52 100644 --- a/configure.kafkacat +++ b/configure.kafkacat @@ -2,7 +2,7 @@ # mkl_require good_cflags -mkl_require gitversion as KAFKACAT_VERSION +mkl_require gitversion as KAFKACAT_VERSION default 1.3.1 function checks { diff --git a/mklove/modules/configure.gitversion b/mklove/modules/configure.gitversion index b6ac486f..ad42291c 100644 --- a/mklove/modules/configure.gitversion +++ b/mklove/modules/configure.gitversion @@ -6,14 +6,24 @@ # VARIABLE_NAME # # Example: Set version in variable named "MYVERSION": -# mkl_require gitversion as MYVERSION +# mkl_require gitversion as MYVERSION [default DEFVERSION] if [[ $1 == "as" ]]; then - __MKL_GITVERSION_VARNAME="$2" + shift + __MKL_GITVERSION_VARNAME="$1" + shift else __MKL_GITVERSION_VARNAME="VERSION" fi +if [[ $1 == "default" ]]; then + shift + __MKL_GITVERSION_DEFAULT="$1" + shift +fi + + function checks { - mkl_allvar_set "gitversion" "$__MKL_GITVERSION_VARNAME" "$(git describe --abbrev=6 --tags HEAD --always)" + mkl_allvar_set "gitversion" "$__MKL_GITVERSION_VARNAME" \ + "$(git describe --abbrev=6 --tags HEAD --always 2>/dev/null || echo $__MKL_GITVERSION_DEFAULT)" }