Skip to content

Instantly share code, notes, and snippets.

@simkesd
Last active March 30, 2017 11:15
Show Gist options
  • Select an option

  • Save simkesd/88819d7de04bafaaaa5815711d3c09a2 to your computer and use it in GitHub Desktop.

Select an option

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`
#!/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
@simkesd

simkesd commented Jan 26, 2017

Copy link
Copy Markdown
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment