telegram-bot-bash/dev/install-hooks.sh

27 lines
707 B
Bash
Raw Normal View History

2019-04-18 16:38:20 +00:00
#!/usr/bin/env bash
# this has to run once atfer git clone
# and every time we create new hooks
2020-12-24 11:13:53 +00:00
#### $$VERSION$$ v1.2-dev2-64-gf4d64f7
2019-04-18 16:38:20 +00:00
2019-04-18 16:42:42 +00:00
# magic to ensure that we're always inside the root of our application,
2019-04-18 16:38:20 +00:00
# no matter from which directory we'll run script
GIT_DIR=$(git rev-parse --git-dir 2>/dev/null)
if [ "$GIT_DIR" != "" ] ; then
cd "$GIT_DIR/.." || exit 1
else
echo "Sorry, no git repository $(pwd)" && exit 1
fi
2019-04-18 16:38:20 +00:00
2019-04-19 08:43:06 +00:00
HOOKDIR="dev/hooks"
2019-04-18 16:38:20 +00:00
echo -n "Installing hooks..."
2020-12-24 11:05:10 +00:00
for hook in pre-commit post-commit pre-push
2019-04-18 16:38:20 +00:00
do
2019-04-19 11:01:25 +00:00
rm -f "${GIT_DIR}/hooks/${hook}"
2019-04-19 08:43:06 +00:00
if [ -f "${HOOKDIR}/${hook}.sh" ]; then
2019-04-18 16:38:20 +00:00
echo -n " $hook"
2019-04-19 08:43:06 +00:00
ln -s "../../${HOOKDIR}/${hook}.sh" "${GIT_DIR}/hooks/${hook}"
2019-04-18 16:38:20 +00:00
fi
done
echo " Done!"