1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-18 13:54:36 -05:00
rofi/script/get_git_rev.sh

25 lines
624 B
Bash
Raw Normal View History

#!/usr/bin/env bash
2016-03-12 08:00:19 -05:00
DIR=$1
FILE=$2
GIT=$(command -v git)
SED=$(command -v sed)
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"
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"
echo "\"" >> "${FILE}.tmp"
2016-03-12 08:00:19 -05:00
else
echo "#undef GIT_VERSION" > "${FILE}.tmp"
2016-03-12 08:00:19 -05:00
fi
if [ ! -f "${FILE}" ] || ! diff "${FILE}.tmp" "${FILE}" >/dev/null
2016-03-12 08:00:19 -05:00
then
mv "${FILE}.tmp" "${FILE}"
2016-03-12 08:00:19 -05:00
else
rm "${FILE}.tmp"
2016-03-12 08:00:19 -05:00
fi