2016-08-14 06:18:32 +00:00
|
|
|
#!/usr/bin/env bash
|
2016-03-12 13:00:19 +00:00
|
|
|
|
|
|
|
DIR=$1
|
|
|
|
FILE=$2
|
2016-04-10 11:22:49 +00:00
|
|
|
GIT=$(which git)
|
2016-03-12 13:00:19 +00:00
|
|
|
|
2016-04-10 11:22:49 +00:00
|
|
|
if [ -d "${DIR}/.git/" ] && [ -n "${GIT}" ]
|
2016-03-12 13:00:19 +00:00
|
|
|
then
|
|
|
|
echo -n "#define GIT_VERSION \"" > ${FILE}.tmp
|
2017-03-21 07:37:07 +00:00
|
|
|
BRTG="$(${GIT} describe --tags --always --all | sed -e 's:heads/::')"
|
|
|
|
REV="$(${GIT} describe --tags --always --dirty| sed -e 's:-g\([a-f0-9]\{7\}\):-git-\1:g')"
|
|
|
|
echo -n "${REV} (${BRTG})" >> ${FILE}.tmp
|
2016-03-12 13:00:19 +00:00
|
|
|
echo "\"" >> ${FILE}.tmp
|
|
|
|
else
|
|
|
|
echo "#undef GIT_VERSION" > ${FILE}.tmp
|
|
|
|
fi
|
|
|
|
|
2016-04-10 11:22:49 +00:00
|
|
|
if [ ! -f ${FILE} ] || ! diff ${FILE}.tmp ${FILE} > /dev/null
|
2016-03-12 13:00:19 +00:00
|
|
|
then
|
|
|
|
mv ${FILE}.tmp ${FILE}
|
|
|
|
else
|
|
|
|
rm ${FILE}.tmp
|
|
|
|
fi
|