Created
May 28, 2019 09:25
-
-
Save sondnm/23a6100a6e68c5939cc835e5edd8e5b4 to your computer and use it in GitHub Desktop.
Simple git hook to run Rubocop before committing
This file contains hidden or 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
# .git/hooks/pre-commit | |
#! /bin/sh | |
inspected_files=$(git diff --diff-filter=ACMR --name-only HEAD) | |
if [ $(echo $inspected_files | wc -w) -gt "0" ]; | |
then | |
bundle exec rubocop $inspected_files --force-exclusion --auto-correct | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment