telegram-bot-bash/dev/hooks/pre-push.sh

35 lines
1007 B
Bash
Raw Normal View History

2019-04-18 19:02:06 +00:00
#!/usr/bin/env bash
2019-04-24 15:34:36 +00:00
#### $$VERSION$$ v0.70-dev2-21-g0cfb9f0
2019-04-18 19:02:06 +00:00
# magic to ensure that we're always inside the root of our application,
# no matter from which directory we'll run script
GIT_DIR=$(git rev-parse --git-dir)
cd "$GIT_DIR/.." || exit 1
2019-04-19 08:43:06 +00:00
2019-04-19 11:01:25 +00:00
export HOOKDIR="dev/hooks"
2019-04-19 08:43:06 +00:00
2019-04-18 19:02:06 +00:00
REMOTEVER="$(git ls-remote -t --refs 2>/dev/null | tail -1 | sed 's/.*\/v//')"
VERSION="$(git describe --tags | sed -e 's/-.*//' -e 's/v//')"
# if any command inside script returns error, exit and return that error
set -e
2019-04-22 18:34:43 +00:00
echo "Running pre-push hook"
2019-04-18 19:02:06 +00:00
echo "............................"
unset IFS; set -f
# LOCAL version must greater than latest REMOTE release version
if (( $(echo "${VERSION} > ${REMOTEVER}" | bc -l) )); then
# update version in bashbot files on push
2019-04-22 18:34:43 +00:00
echo -n " "
dev/version.sh 2>/dev/null || exit 1
echo " OK"
2019-04-18 19:02:06 +00:00
else
echo "Error: local version ${VERSION} must be greater than latest release version."
echo "use \"git tag ...\" to create a local version greater than ${REMOTEVER}"
exit 1
fi