Last active
August 29, 2015 14:08
-
-
Save mehulkar/6964b68b3e2302e81f9b to your computer and use it in GitHub Desktop.
git precommit hook for rspec
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 | |
# Add this file to .git/hooks/pre-commit | |
# and make it executable. | |
# 1. greps the repo for "focus: true" | |
# 2. counts number of results | |
# 3. Strips the whitespace from the resulting number string | |
num=$(git grep "focus: true" | wc -l | xargs) | |
# 4. assumes that spec_helper has the string for | |
# turning on that configuration, so the hook will abort | |
# commit only if there are more than 1 mentions of "focus: true" | |
if [[ "$num" -gt 1 ]]; then | |
echo "git commit error: Remove all 'focus: true' directives from spec suite" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment