Last active
February 1, 2019 13:10
-
-
Save timuruski/5c263c14dad21b39ce3a to your computer and use it in GitHub Desktop.
Pre-Commit Rubocop check
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 | |
# Simplified from this script, (less robust and more to the point): | |
# http://gmodarelli.com/2015/02/code-reviews-rubocop-git-pre-commit/ | |
# Installation: copy this code into <REPO>.git/hooks/pre-commit.sh | |
# Select only staged Ruby files | |
FILES="$(git diff --cached --name-only --diff-filter=AMC | grep "\.rb$" | tr '\n' ' ')" | |
# Check for ruby style errors | |
if [ -n "$FILES" ]; then | |
exec rubocop --force-exclusion --format=simple ${FILES} | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this one… I just needed something like it and remembered you have done it! 🍻