Skip to content

Instantly share code, notes, and snippets.

@n1k0
Created July 7, 2015 13:07
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save n1k0/2ad1dff55520d546110a to your computer and use it in GitHub Desktop.
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.
#!/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
@saurabh-sp-tripathi
Copy link

will it run on windows too? There should be a way as most people have git-bash on their system which can run this.

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