2016-04-27 12:13:19 -04:00
|
|
|
#!/usr/bin/env sh
|
2016-03-12 08:00:19 -05:00
|
|
|
|
|
|
|
DIR=$1
|
|
|
|
FILE=$2
|
2016-04-10 07:22:49 -04:00
|
|
|
GIT=$(which git)
|
2016-03-12 08:00:19 -05:00
|
|
|
|
2016-04-10 07:22:49 -04:00
|
|
|
if [ -d "${DIR}/.git/" ] && [ -n "${GIT}" ]
|
2016-03-12 08:00:19 -05:00
|
|
|
then
|
|
|
|
echo -n "#define GIT_VERSION \"" > ${FILE}.tmp
|
2016-04-10 07:22:49 -04:00
|
|
|
REV="$(${GIT} describe --tags --always --dirty) ($(${GIT} describe --tags --always --all | sed -e 's:heads/::'))"
|
2016-03-12 08:00:19 -05:00
|
|
|
echo -n "${REV}" >> ${FILE}.tmp
|
|
|
|
echo "\"" >> ${FILE}.tmp
|
|
|
|
else
|
|
|
|
echo "#undef GIT_VERSION" > ${FILE}.tmp
|
|
|
|
fi
|
|
|
|
|
2016-04-10 07:22:49 -04:00
|
|
|
if [ ! -f ${FILE} ] || ! diff ${FILE}.tmp ${FILE} > /dev/null
|
2016-03-12 08:00:19 -05:00
|
|
|
then
|
|
|
|
mv ${FILE}.tmp ${FILE}
|
|
|
|
else
|
|
|
|
rm ${FILE}.tmp
|
|
|
|
fi
|