Skip to content

Instantly share code, notes, and snippets.

@sondnm
Created May 28, 2019 09:25
Show Gist options
  • Save sondnm/23a6100a6e68c5939cc835e5edd8e5b4 to your computer and use it in GitHub Desktop.
Save sondnm/23a6100a6e68c5939cc835e5edd8e5b4 to your computer and use it in GitHub Desktop.
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