Last active
July 28, 2017 16:02
-
-
Save ubaierbhat/0117b002158bb1b08ea98f262e7f2e86 to your computer and use it in GitHub Desktop.
Example of pre-commit hook to test your code before making a commit
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
#!/usr/bin/env bash | |
# pre-commit.sh | |
git stash -q --keep-index | |
./gradlew test | |
RESULT=$? | |
echo "Result = " $RESULT | |
git stash pop -q | |
[ $RESULT -ne 0 ] && echo "Tests failed -- commit aborted" && exit 1 | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Tips for using a git pre-commit hook