Skip to content

Instantly share code, notes, and snippets.

@mmyoji
Last active June 17, 2022 01:44
Show Gist options
  • Save mmyoji/03225a5b48232b8b72f3c37d88d3d05c to your computer and use it in GitHub Desktop.
Save mmyoji/03225a5b48232b8b72f3c37d88d3d05c to your computer and use it in GitHub Desktop.
pre-commit
#!/bin/sh
# http://qiita.com/yuku_t/items/ad072418290a2b01a35a
# A: Added
# M: Modified
files=$(git diff --cached --name-only --diff-filter=AM | grep '\.rb$')
if [ -n "$files" ]; then
bundle exec rubocop --force-exclusion ${files}
# For docker:
# docker-compose run --rm <service-name> rubocop --force-exclusion ${files}
exit $?
fi
exit 0
@mmyoji
Copy link
Author

mmyoji commented Mar 23, 2017

$ chmod +x .git/hooks/pre-commit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment