Last active
August 29, 2015 14:21
-
-
Save connesc/50257ea06c6b04b18cc6 to your computer and use it in GitHub Desktop.
Git pre-commit hook for launching a test suite
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 | |
# Clean the working tree if needed | |
before="$(git rev-parse --verify --quiet refs/stash)" | |
git stash save --keep-index --include-untracked --quiet 'Git pre-commit hook' | |
after="$(git rev-parse --verify --quiet refs/stash)" | |
# Run tests | |
grunt jshint | |
status=$? | |
# Restore the working tree if needed | |
if [ "$after" != "$before" ] | |
then | |
git reset --hard --quiet | |
git stash pop --index --quiet | |
fi | |
# Exit with the relevant status | |
exit $status |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment