Use alternative revision retrieval if git describe is failing

This happens primarily on Travis. It looks like the shallow clone it makes is missing
tags. So if git describe fails, fall back to only the short commit hash (as we used to do
previously everywhere).
This commit is contained in:
Geert Janssens 2017-10-26 18:13:17 +02:00
parent 998f1185c1
commit 67ae241075

View File

@ -125,8 +125,15 @@ then
exit 0
fi
githead=$("$GIT_CMD" --git-dir "${real_gitdir}" describe)
if test $? = 0 ; then
githead=$("$GIT_CMD" --git-dir "${real_gitdir}" describe 2>/dev/null)
rc=$?
if [ $rc != 0 ]; then
# On travis describe seems to fail due to missing tags in the git clone the system takes
# So specifically to catch those errors, use only the short commit hash as a backup
githead=$("$GIT_CMD" --git-dir "${real_gitdir}" log -1 --pretty=format:"%h" HEAD 2>/dev/null)
rc=$?
fi
if [ $rc = 0 ]; then
/bin/echo -n $githead
# Add a "+" to the hash if there deleted or modified files (not excluded by .gitignore and friends)
# "Ignores" untracked files