diff options
Diffstat (limited to 'script')
-rwxr-xr-x | script/get_git_rev.sh | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/script/get_git_rev.sh b/script/get_git_rev.sh new file mode 100755 index 00000000..c5ef9457 --- /dev/null +++ b/script/get_git_rev.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +DIR=$1 +FILE=$2 + +if [ -d "${DIR}/.git/" ] +then + echo -n "#define GIT_VERSION \"" > ${FILE}.tmp + REV=$(git log -1 --pretty=tformat:%h) + echo -n "${REV}" >> ${FILE}.tmp + echo "\"" >> ${FILE}.tmp +else + echo "#undef GIT_VERSION" > ${FILE}.tmp +fi + +if ! diff ${FILE}.tmp ${FILE} > /dev/null +then + mv ${FILE}.tmp ${FILE} +else + rm ${FILE}.tmp +fi |