-
-
Save aviflax/f18a7a67ac13d114a71b to your computer and use it in GitHub Desktop.
pre-commit script to prevent stupid commits that break builds
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Based on the script at http://stackoverflow.com/a/10015707/7012 | |
# Allows us to read user input below, assigns stdin to keyboard | |
exec < /dev/tty | |
while true; do | |
read -p "[pre-commit hook] Have you run the tests? (Y/n) " yn | |
if [ "$yn" = "" ]; then | |
yn='N' | |
fi | |
case $yn in | |
[Yy] ) exit 0;; | |
[Nn] ) exit 1;; | |
* ) echo "Please answer y or n for yes or no.";; | |
esac | |
done | |
# Close STDIN again | |
exec <&- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment