Skip to content

Instantly share code, notes, and snippets.

@lluft
Forked from holyjak/pre-commit
Last active October 14, 2015 21:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lluft/3d9d013b5c00c616e35e to your computer and use it in GitHub Desktop.
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"
#!/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