Last active
October 23, 2017 18:20
-
-
Save pristinenoise/910dbd6a73e20d4646962fc272540f5c to your computer and use it in GitHub Desktop.
Precommit hook for eslint and rubocop
This file contains 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 | |
FILE_COUNT=$(git status | grep 'modified:' | wc -l) | |
if [ $FILE_COUNT -gt 100 ] ; then | |
echo "File count is 100+, skipping pre-commit validation" | |
exit 0 | |
fi | |
# Check modified Javascript files with ESLint | |
FAILED=0 | |
bundle exec rake lint | |
if [[ $? != 0 ]] ; then | |
FAILED=1 | |
fi | |
matches=$(git diff --cached | grep -E '\+.*?FIXME') | |
if [ "$matches" != "" ] | |
then | |
echo "'FIXME' tag is detected." | |
echo "Please fix it before committing." | |
echo " ${matches}" | |
FAILED=1 | |
fi | |
if [[ $FAILED != 0 ]] ; then | |
echo "Pre-commit test failed, git commit denied!" | |
exit 1 | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment