- Avoids files with debugger/binding.pry to be commited
- Avoids files with spaces in the end of the line to be commited
- 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 |
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 ?