Last active
November 25, 2015 16:47
-
-
Save kvendrik/3365296574fe7ecb47a6 to your computer and use it in GitHub Desktop.
pre-push hook example for running tests before pushing to master
This file contains hidden or 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
| # Allows us to read user input below, assigns stdin to keyboard | |
| exec < /dev/tty | |
| printf "About to push to remote...\n" | |
| # read user input with <message>, continue when input length is <n> | |
| read -p "Run some checks first? [Y/n] " -n 1 cont | |
| printf "\n" | |
| if [ "$cont" == "n" ] || [ "$cont" == "N" ]; then | |
| exit 0 | |
| else | |
| grunt jshint | |
| fi | |
| exit 0 |
This file contains hidden or 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
| # creates symlinks for all git hooks in ./hooks | |
| # from .git/hooks/<HOOK_NAME> to ./hooks/<HOOK_NAME> | |
| SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | |
| GIT_HOOK_DIR="$(git rev-parse --show-toplevel)/.git/hooks" | |
| HOOK_DIR="$SCRIPT_DIR/hooks" | |
| cd $HOOK_DIR | |
| for hook in * | |
| do | |
| SYMLINK_PATH="$GIT_HOOK_DIR/$hook" | |
| echo "Symlinking $SYMLINK_PATH to $HOOK_DIR/$hook..." | |
| ln -s -f $HOOK_DIR/$hook $SYMLINK_PATH | |
| chmod 755 $SYMLINK_PATH | |
| done | |
| exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment