Last active
March 30, 2017 11:15
-
-
Save simkesd/88819d7de04bafaaaa5815711d3c09a2 to your computer and use it in GitHub Desktop.
Pre commit script for preventing stupid mistakes like commiting code with `alert('something')` or `exit()`. If you want to commit code with this content you can just do `git commit --no-verify`
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/sh | |
| diff="git diff HEAD"; | |
| result=$($diff | egrep -i 'alert|test|console|exit|var_dump|print_r') | |
| RED='\033[0;31m' | |
| GREEN='\033[0;32m' | |
| NC='\033[0m' # No Color | |
| if [ -z "$result" ] ; then | |
| echo "\n${GREEN}All hail to omnipotent master of universe!!!\n${NC}"; | |
| exit 0; | |
| else | |
| echo "\n${RED}************"; | |
| echo "${RED}*${NC} STUPIDO! ${RED}*${NC}"; | |
| echo "${RED}************${NC}\n"; | |
| echo $result; | |
| exit 1; | |
| fi |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Pre commit script for preventing stupid mistakes like commiting code with
alert('something')orexit(). If you want to commit code with this content you can just dogit commit --no-verify