Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@aviflax
Created August 17, 2015 21:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aviflax/f18a7a67ac13d114a71b to your computer and use it in GitHub Desktop.
Save aviflax/f18a7a67ac13d114a71b to your computer and use it in GitHub Desktop.
pre-commit script to prevent stupid commits that break builds
#!/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