Skip to content

Instantly share code, notes, and snippets.

@vochicong
Created March 21, 2018 21:43
Show Gist options
  • Save vochicong/9c58ffbe045772fc2d4010b0b7c63f41 to your computer and use it in GitHub Desktop.
Save vochicong/9c58ffbe045772fc2d4010b0b7c63f41 to your computer and use it in GitHub Desktop.
Overcommit+Pronto+個別チェッカーで変なRubyコード(変更分+新規分)をコミットさせない ref: https://qiita.com/vochicong/items/b63d573dbdc24dfe02ad
PreCommit:
CustomScript:
enabled: true
command: ['bin/precommit.sh']
overcommit --install
#!/usr/bin/env bash
set -x
# Pronto crashes on checking files not yet committed,
# therefore we reset them once and re-add later
newrubies=$(git diff --name-only --diff-filter=A HEAD |\
grep -e '\.\(rb\|rake\)$' | tr '\n' ' ')
[ -z "${newrubies// }" ] && exit
git reset $newrubies
status=0
bin/pronto run --staged || let ++status
git add $newrubies
# Check those new files that not checked by Pronto
bin/flay `echo $newrubies`
bin/flog `echo $newrubies`
bin/reek -s `echo $newrubies` --failure-exit-code 0
bin/rubocop `echo $newrubies` || let ++status
exit $status
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment