Skip to content

Instantly share code, notes, and snippets.

@brendan-donegan
Last active February 26, 2018 16:27
Show Gist options
  • Save brendan-donegan/22c4a02240261669c97a27d036ba6fbe to your computer and use it in GitHub Desktop.
Save brendan-donegan/22c4a02240261669c97a27d036ba6fbe to your computer and use it in GitHub Desktop.
#!/bin/sh
#
# This pre-commit hook looks for `fdescribe`, `fcontext`, `fit`, `fspecify` and `fexample` in the
# staged files and exits with an error code of 1 if there are such changes.
#
STATUS=0
for focus in fdescribe fcontext fit fspecify fexample; do
FILES=$(git diff --staged -G"^\s*$focus\(" --name-only | wc -l)
if [ $FILES -gt 0 ]
then
echo "You forgot to remove a $focus in the following files:"
git diff --staged --name-only -G"^\s*$focus\("
echo ""
STATUS=1
fi
done
exit $STATUS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment