Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Simple git hook to run Rubocop before committing
# .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
You can’t perform that action at this time.