Skip to content

Instantly share code, notes, and snippets.

@chrisvoo
Created May 5, 2021 12:24
Show Gist options
  • Save chrisvoo/03f937314d89765b6a1214901bbdaab5 to your computer and use it in GitHub Desktop.
Save chrisvoo/03f937314d89765b6a1214901bbdaab5 to your computer and use it in GitHub Desktop.
Avoit to commit tests with `only`
# Redirect output to stderr.
exec 1>&2
# prevent it.only or describe.only commited
if [ "$allowonlytests" != "true" ] &&
test $(git diff --cached | grep -E "\b(it|describe).only\(" | wc -l) != 0
then
cat <<\EOF
Error: Attempt to add it.only or describe.only - which may disable all other tests
If you know what you are doing you can disable this check using:
git config hooks.allowonlytests true
EOF
exit 1
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment