Skip to content

Instantly share code, notes, and snippets.

@soszilla
Created June 21, 2019 13:51
Show Gist options
  • Save soszilla/5b9d69eabd2c31149ff8775b6f86d5d1 to your computer and use it in GitHub Desktop.
Save soszilla/5b9d69eabd2c31149ff8775b6f86d5d1 to your computer and use it in GitHub Desktop.
stupidity check
#!/bin/sh
FILES_PATTERN='\.(js|py)(\..+)?$'
FORBIDDEN='TODO|console.log|print'
git diff --cached --name-only | \
grep -E $FILES_PATTERN | \
GREP_COLOR='4;5;37;41' xargs egrep --color --with-filename -n $FORBIDDEN && echo "Found $FORBIDDEN references, commit canceled." && exit 1
echo "pre-commit scan succeeded"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment