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.
This commit is contained in:
Andrea Mazzoleni 2016-01-05 10:56:34 +01:00
parent f277bf24b1
commit 51f064dbbd

View file

@ -3,12 +3,17 @@
if [ -d .git ]; then if [ -d .git ]; then
# Get version from git tags, removing the 'v' prefix # Get version from git tags, removing the 'v' prefix
VERSION=`git describe --match 'v*' | sed 's/^v//'` VERSION=`git describe --match 'v*' 2>/dev/null | sed 's/^v//'`
elif [ -f .version ]; then fi
if [ -f .version ]; then
# Get version from the .version file # Get version from the .version file
VERSION=`cat .version` VERSION=`cat .version`
else fi
if [ -z $VERSION ]; then
VERSION="none" VERSION="none"
fi fi
printf '%s' "$VERSION" printf '%s' "$VERSION"