Skip to content

Instantly share code, notes, and snippets.

@ubaierbhat
Last active July 28, 2017 16:02
Show Gist options
  • Save ubaierbhat/0117b002158bb1b08ea98f262e7f2e86 to your computer and use it in GitHub Desktop.
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
#!/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
@ubaierbhat
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment