Skip to content

Instantly share code, notes, and snippets.

@tscolari
Created July 26, 2013 09:07
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 tscolari/6087449 to your computer and use it in GitHub Desktop.
Save tscolari/6087449 to your computer and use it in GitHub Desktop.
Work in progress
  • Avoids files with debugger/binding.pry to be commited
  • Avoids files with spaces in the end of the line to be commited

Instalation

  • Copy the file to .git/hooks/pre-commit
  • Make it executable chmod + x .git/hooks/pre-commit
  • Have fun
#!/bin/sh
ABORT=0
if [ "git diff --check > /dev/null" ]
then
echo $(git --no-pager diff --check | egrep trailing)
ABORT=1
fi
for FILE in `git diff-index --name-only HEAD` ; do
if [ "grep 'debugger|binding\.pry' $FILE" ]
then
echo $FILE ' -> INVALID'
ABORT=1
fi
done
if (( $ABORT ))
then
exit 1
fi
exit 0
@hubb
Copy link

hubb commented Jul 26, 2013

Avoids files with spaces in the end of the line to be commited

Not a big fan of my commit being aborted because I have trailing whitespaces, why not removing them for me if I haven't configured my editor properly ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment