2016-08-14 02:18:32 -04:00
|
|
|
#!/usr/bin/env bash
|
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
|
2021-08-14 07:03:16 -04:00
|
|
|
echo -n "#define GIT_VERSION \"" > "${FILE}.tmp"
|
2017-03-21 03:37:07 -04: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')"
|
2021-08-14 07:03:16 -04:00
|
|
|
echo -n "${REV} (${BRTG})" >> "${FILE}.tmp"
|
|
|
|
echo "\"" >> "${FILE}.tmp"
|
2016-03-12 08:00:19 -05:00
|
|
|
else
|
2021-08-14 07:03:16 -04:00
|
|
|
echo "#undef GIT_VERSION" > "${FILE}.tmp"
|
2016-03-12 08:00:19 -05:00
|
|
|
fi
|
|
|
|
|
2021-08-14 07:03:16 -04:00
|
|
|
if [ ! -f "${FILE}" ] || ! diff "${FILE}.tmp" "${FILE}" >/dev/null
|
2016-03-12 08:00:19 -05:00
|
|
|
then
|
2021-08-14 07:03:16 -04:00
|
|
|
mv "${FILE}.tmp" "${FILE}"
|
2016-03-12 08:00:19 -05:00
|
|
|
else
|
2021-08-14 07:03:16 -04:00
|
|
|
rm "${FILE}.tmp"
|
2016-03-12 08:00:19 -05:00
|
|
|
fi
|