Skip to content

Instantly share code, notes, and snippets.

@x1a0
Last active December 25, 2015 04:19
Show Gist options
  • Save x1a0/6916618 to your computer and use it in GitHub Desktop.
Save x1a0/6916618 to your computer and use it in GitHub Desktop.
Git pre-commit script for checking debug codes
# If there are debug codes, print the offending file names and fail.
FILES_PATTERN='\.scala$'
FORBIDDEN='println'
git diff --cached --name-only | \
grep -E $FILES_PATTERN | \
GREP_COLOR='4;5;37;41' xargs grep --color --with-filename -n $FORBIDDEN && echo 'COMMIT REJECTED Found "$FORBIDDEN" references. Please remove them before commiting' && exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment