Last active
January 13, 2020 23:34
-
-
Save bdurand/014e3fc7608db7e5fdaf92cdcc72b400 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
# Run rubocop with automatic fixes on any new or modified git files | |
set -o errexit | |
# set -o xtrace | |
changed_files=`git diff --cached --name-only --diff-filter=ACM | grep -e '\.rb$' | cat` | |
if [ "$changed_files" != "" ]; then | |
ruby_version=`cat .ruby-version | tr -d '[:space:]'` | |
if RBENV_VERSION=$ruby_version ~/.rbenv/shims/rubocop $changed_files; then | |
exit 0 | |
else | |
RBENV_VERSION=$ruby_version ~/.rbenv/shims/rubocop -a $changed_files | |
exit 1 | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment