Browse Source

hooks: Skip checks when missing a dependency in a non-interactive shell.

merge-requests/1327/merge
Kévin Commaille 3 years ago
parent
commit
cafc56e14a
No known key found for this signature in database
GPG Key ID: DD507DAE96E8245C
  1. 45
      hooks/pre-commit.hook

45
hooks/pre-commit.hook

@ -18,26 +18,31 @@ elif [[ $? -eq 2 ]]; then
echo ""
echo "A missing dependency was found"
echo ""
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
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}"

Loading…
Cancel
Save