Last active
May 17, 2016 21:22
-
-
Save jvonkluck/09b3bd68247b52bed32488f99070206d to your computer and use it in GitHub Desktop.
Pre-Commit Shell Script Hook
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
#!/usr/bin/env /bin/bash | |
# Copy this into .git/hooks/pre-commit | |
# TODO: Filter by git status --porcelain ~= \A|AM|^M\ once all repos rubocop compliant | |
# TODO: Capture files in commit and add updates after auto-correct | |
INSTALL_RUBOCOP="Rubocop not found in this project's bundle. Please add it." | |
CORRECT_VIOLATIONS="Rubocop detected violations. Please resolve them, re-add files and try again." | |
bundle show rubocop || (echo $INSTALL_RUBOCOP && exit 1) | |
bundle exec rubocop --auto-correct --fail-level autocorrect || (echo $CORRECT_VIOLATIONS && exit 1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment