Created
July 7, 2015 13:07
-
-
Save n1k0/2ad1dff55520d546110a to your computer and use it in GitHub Desktop.
This git pre-commit hook checks for .only remaining in js mocha test files and prevent commiting if any.
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 | |
# This checks for .only remaining in js mocha test files and prevent | |
# commiting if any. | |
if git rev-parse --verify HEAD >/dev/null 2>&1 | |
then | |
against=HEAD | |
else | |
# Initial commit: diff against an empty tree object | |
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 | |
fi | |
for FILE in `git diff --name-only $against`; do | |
grep '.only' $FILE 2>&1 >/dev/null | |
if [ $? -eq 0 ]; then | |
echo "$FILE contains .only, aborted commit." | |
exit 1 | |
fi | |
done | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
will it run on windows too? There should be a way as most people have git-bash on their system which can run this.