From 51f064dbbd66a3da20ef0e8849940c43ff52fac7 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Tue, 5 Jan 2016 10:56:34 +0100 Subject: [PATCH] Get the version even if no tag is present If not tag is present, git cannot describe the commit. In this case we want "none" version. --- autover.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/autover.sh b/autover.sh index 79256402..48f08ebb 100755 --- a/autover.sh +++ b/autover.sh @@ -3,12 +3,17 @@ if [ -d .git ]; then # Get version from git tags, removing the 'v' prefix - VERSION=`git describe --match 'v*' | sed 's/^v//'` -elif [ -f .version ]; then + VERSION=`git describe --match 'v*' 2>/dev/null | sed 's/^v//'` +fi + +if [ -f .version ]; then # Get version from the .version file VERSION=`cat .version` -else +fi + +if [ -z $VERSION ]; then VERSION="none" fi printf '%s' "$VERSION" +