Created
December 14, 2016 21:33
-
-
Save kimniche/67ee898f348d68004869294ceaad71e8 to your computer and use it in GitHub Desktop.
Error if your commit includes any `console` mentions
This file contains hidden or 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 | |
| LOG="[pre-commit]" | |
| console=`grep -n console $(git diff --name-only --cached) -H --color` | |
| if [ -z "$console" ]; then | |
| tput setaf 2; echo "$LOG no \`console\` left in commit" | |
| tput sgr0 | |
| exit 0 | |
| else | |
| num=`grep -o console $(git diff --name-only --cached) -H | wc -l` | |
| num="${num// /}" | |
| tput setaf 1; echo "$LOG found $(tput bold)$num$(tput sgr0)$(tput setaf 1) instances of \`console\` in files below, not committing" | |
| tput sgr0; echo -e "$console" | |
| exit 1 # Error out and prevent commit | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment