You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.2 KiB

#!/bin/bash
# Depends on: hooks/checks.sh
# Style helpers
act="\e[1;32m"
err="\e[1;31m"
pos="\e[32m"
neg="\e[31m"
res="\e[0m"
echo "-- Pre-commit checks --"
echo "To ignore these checks next time, run: git commit --no-verify"
echo ""
if hooks/checks.sh --git-staged; then
echo ""
echo -e "Pre-commit checks result: ${pos}ok${res}"
elif [[ $? -eq 2 ]]; then
echo ""
if [ ! -t 1 ]; then
echo "This is a non-interactive shell, skipping checks."
exit 0
else
echo "y: Skip checks and proceed with commit"
echo "N: Abort commit"
echo ""
while true
do
echo -n "Skip the pre-commit checks? [y/N]: "; read yn < /dev/tty
case $yn in
[Yy]* )
echo -e " ${act}Skipping${res} checks"
exit 0
;;
[Nn]* | "" )
echo -e " ${err}Aborting${res} commit"
exit 1
;;
* )
echo -e "${neg}Invalid input${res}"
;;
esac
done
fi
else
echo ""
echo -e "Pre-commit checks result: ${neg}fail${res}"
echo ""
echo -e " ${err}Aborting${res} commit"
exit 1
fi