Last active
July 27, 2017 04:09
-
-
Save hiroki-uchida/f8a4663ca049ae96fc1aef710bd0936e to your computer and use it in GitHub Desktop.
RuboCop違反のファイルのコミットを阻止する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# 参考記事 | |
# Gitフックを使っておかしいRubyコードをコミットできないようにする - Qiita | |
# http://qiita.com/yuku_t/items/ad072418290a2b01a35a | |
# 使い方 | |
# このコードを `~/.git_template/hooks/pre-commit` に保存して以下のコマンドを実行します。 | |
# `$ git config --global init.templatedir '~/.git_template'` | |
# 新しく作られたリポジトリやcloneしたリポジトリに反映されます。 | |
# 既存のリポジトリには反映されないので、 `$ git init` を実行する必要があります。 | |
which bundle exec rubocop && git diff --cached --name-only --diff-filter=AM | grep '\.rb$' | xargs bundle exec rubocop --parallel | |
exit $? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment