Skip to content

Instantly share code, notes, and snippets.

@timoschilling
Last active December 14, 2015 16:48
Show Gist options
  • Save timoschilling/5117201 to your computer and use it in GitHub Desktop.
Save timoschilling/5117201 to your computer and use it in GitHub Desktop.
#!/bin/sh
#
# Lives in .git/hooks.
# To enable this hook, rename this file to "pre-commit".
# Redirect output to stderr.
exec 1>&2
# works, but is slow. try with ack!
# LANG=C find . -name '*_spec.rb' | xargs egrep -q '^\s*(describe|it|context)\b.*focus'
# much faster, but not as portable
ack -G '_spec.rb' '^\s*(describe|it|context|should)\b.*focus'
if [ $? -eq 0 ]
then
echo "Error: attempted to check in an rspec *_spec.rb file which contains a focus."
echo "Do \"find . -name '*_spec.rb' | xargs egrep '^\s*(describe|it|context)\b.*focus'\" to find out."
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment