Skip to content

Instantly share code, notes, and snippets.

@jvonkluck
Last active May 17, 2016 21:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jvonkluck/09b3bd68247b52bed32488f99070206d to your computer and use it in GitHub Desktop.
Save jvonkluck/09b3bd68247b52bed32488f99070206d to your computer and use it in GitHub Desktop.
Pre-Commit Shell Script Hook
#!/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