Last active
September 27, 2015 00:47
-
-
Save UnderpantsGnome/1184743 to your computer and use it in GitHub Desktop.
My pre-commit hook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
debug=`git diff --cached | grep -C 2 -E '+\s*And (open|show me the page|save_and_open_page)'` | |
pry=`git diff --cached | grep -C 2 -E 'binding.pry'` | |
debugger=`git diff --cached | grep -C 2 debugger` | |
console_log=`git diff --cached | grep -C 2 console.log` | |
conflicts=`git diff --cached | grep -C 2 -E '<<<|>>>'` | |
if [ -n "$debug" ]; then | |
echo "debugging statements added in this commit" | |
echo $debug | |
fi | |
if [ -n "$pry" ]; then | |
echo "binding.pry added in this commit" | |
echo $debug | |
fi | |
if [ -n "$conflicts" ]; then | |
echo "unresolved merge conflicts added in this commit" | |
echo $conflicts | |
fi | |
if [ -n "$debugger" ]; then | |
echo "JS debugging statements added in this commit" | |
echo $debugger | |
fi | |
if [ -n "$console_log" ]; then | |
echo "JS debugging statements added in this commit" | |
echo $console_log | |
fi | |
if [[ -n "$conflicts" || -n "$debug" || -n "$debugger" || -n "$console_log" ]]; then | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://book.git-scm.com/5_git_hooks.html
GIT_DIR in that link is a git repo, each repo will have its own hooks.