Created
May 23, 2018 15:18
-
-
Save bnd5k/e025b594453d694d192653e0aeffed53 to your computer and use it in GitHub Desktop.
An example of a pre-commit hook that ensure's nothing too silly get's saved to git history.
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)|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 "$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 console.log 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