2021-02-04 19:25:29 +00:00
|
|
|
#!/bin/sh
|
2022-01-14 16:06:00 +00:00
|
|
|
# Depends on: scripts/checks.sh
|
2021-02-04 19:25:29 +00:00
|
|
|
|
2022-01-14 22:21:32 +00:00
|
|
|
# Style helpers
|
|
|
|
act="\e[1;32m"
|
|
|
|
err="\e[1;31m"
|
|
|
|
pos="\e[32m"
|
|
|
|
neg="\e[31m"
|
|
|
|
res="\e[0m"
|
|
|
|
|
2022-01-14 16:06:00 +00:00
|
|
|
echo "-- Pre-commit checks --"
|
|
|
|
echo "To ignore these checks next time, run: git commit --no-verify"
|
|
|
|
echo ""
|
2022-05-13 12:35:25 +00:00
|
|
|
if scripts/checks.sh --git-staged; then
|
2021-02-04 19:25:29 +00:00
|
|
|
echo ""
|
2022-01-14 22:21:32 +00:00
|
|
|
echo -e "Pre-commit checks result: ${pos}ok${res}"
|
2022-01-14 16:06:00 +00:00
|
|
|
elif [[ $? -eq 2 ]]; then
|
2022-01-14 22:21:32 +00:00
|
|
|
echo ""
|
2022-01-14 16:06:00 +00:00
|
|
|
echo "A missing dependency was found"
|
|
|
|
echo ""
|
|
|
|
echo "y: Skip checks and proceed with commit"
|
|
|
|
echo "N: Abort commit"
|
2021-06-22 07:03:29 +00:00
|
|
|
echo ""
|
|
|
|
while true
|
|
|
|
do
|
2022-01-14 16:06:00 +00:00
|
|
|
echo -n "Skip the pre-commit checks? [y/N]: "; read yn < /dev/tty
|
2021-02-04 19:25:29 +00:00
|
|
|
case $yn in
|
2022-01-14 16:06:00 +00:00
|
|
|
[Yy]* )
|
2022-01-14 22:21:32 +00:00
|
|
|
echo -e " ${act}Skipping${res} checks"
|
2022-01-14 16:06:00 +00:00
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
[Nn]* | "" )
|
2022-01-14 22:21:32 +00:00
|
|
|
echo -e " ${err}Aborting${res} commit"
|
2022-01-14 16:06:00 +00:00
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
* )
|
2022-01-14 22:21:32 +00:00
|
|
|
echo -e "${neg}Invalid input${res}"
|
2022-01-14 16:06:00 +00:00
|
|
|
;;
|
2021-02-04 19:25:29 +00:00
|
|
|
esac
|
|
|
|
done
|
|
|
|
else
|
2022-01-14 22:21:32 +00:00
|
|
|
echo ""
|
|
|
|
echo -e "Pre-commit checks result: ${neg}fail${res}"
|
|
|
|
echo ""
|
|
|
|
echo -e " ${err}Aborting${res} commit"
|
2022-01-14 16:06:00 +00:00
|
|
|
exit 1
|
2022-05-13 12:35:25 +00:00
|
|
|
fi
|