-
-
Save lluft/3d9d013b5c00c616e35e to your computer and use it in GitHub Desktop.
Git pre-commit hook that fails for changes introducing Jasmine's exclusive tests using "ddescribe" or "iit"
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 | |
# A git pre-commit hook that verifies that the change does not introduce | |
# the use of a Jasmine exclusive test via 'iit(..)' or 'ddescribe(..)', which would | |
# prevent most other tests from being run without any clear indication thereof | |
# Redirect output to stderr. | |
exec 1>&2 | |
ADDED_EXCLUSIVE_TEST=$(git diff -U0 --staged -S"(\W|^)(ddescribe|iit))\s+?\(" --pickaxe-regex | egrep "(^\+.*(ddescribe|iit))|\+{3}") | |
if [ -n "$ADDED_EXCLUSIVE_TEST" ]; then | |
echo "PRE-COMIT CHECK FAILED: You have added calls to either iit(..) or ddescribe(..) thus preventing other tests from running, please fix: $ADDED_EXCLUSIVE_TEST" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment