1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
#!/bin/bash
if ! cd "${0%/*}"; then
echo "failed to change working directory"
exit 1
fi
if ! type git > /dev/null; then
echo "git not available."
exit 0
fi
if ! type g++ > /dev/null; then
echo "g++ not available."
exit 0
fi
REPO=$(git rev-parse --show-toplevel)
if ! g++ -I"$REPO"/include -o current_version \
current_version.cc "$REPO"/src/version.cpp; then
echo "failed to compile current_version.cc"
exit 1
fi
if ! version=$(./current_version); then
echo "failed to execute current_version"
exit 1
fi
if ! [[ "$version" ]]; then
echo "empty version info"
exit 1
fi
rm ./current_version
if ! git rev-parse "$version" &>/dev/null; then
# already updated
exit 0
fi
head_ts=$(git show -s --format=%ct HEAD)
vers_ts=$(git show -s --format=%ct "$version")
if ((head_ts > vers_ts)); then
echo "version tag is outdated and needs an update"
exit 1
fi
|