Change: Include the full raw git revision hash in rev.cpp

This commit is contained in:
Niels Martin Hansen
2019-01-27 14:04:49 +01:00
parent cca952d94b
commit 67c6f945fb
5 changed files with 37 additions and 20 deletions

View File

@@ -67,20 +67,25 @@ if [ -d "$ROOT_DIR/.git" ]; then
MODIFIED="2"
fi
HASH=`LC_ALL=C git rev-parse --verify HEAD 2>/dev/null`
SHORTHASH=`echo ${HASH} | cut -c1-8`
SHORTHASH=`echo ${HASH} | cut -c1-10`
ISODATE=`LC_ALL=C git show -s --pretty='format:%ci' HEAD | "$AWK" '{ gsub("-", "", $1); print $1 }'`
BRANCH="`git symbolic-ref -q HEAD 2>/dev/null | sed 's@.*/@@'`"
TAG="`git name-rev --name-only --tags --no-undefined HEAD 2>/dev/null | sed 's@\^0$@@'`"
if [ "$MODIFIED" -eq "0" ]; then
hashprefix="-g"
elif [ "$MODIFIED" -eq "2" ]; then
hashprefix="-m"
else
hashprefix="-u"
fi
if [ -n "$TAG" ]; then
VERSION="${TAG}"
else
VERSION="${ISODATE}-${BRANCH}-g${SHORTHASH}"
VERSION="${ISODATE}-${BRANCH}${hashprefix}${SHORTHASH}"
fi
if [ "$MODIFIED" -eq "2" ]; then
VERSION="${VERSION}M"
fi
elif [ -f "$ROOT_DIR/.ottdrev" ]; then
# We are an exported source bundle
cat $ROOT_DIR/.ottdrev