修正したファイルのみチェック
修正したファイルのみチェック
修正したファイルのみチェック
ブランチ全体に対して rubocop や rspec を実行すると時間がかかりすぎるとき、変更したファイルだけに絞って実行するために使う。git diff origin/master <ブランチ名> で差分のあるファイル一覧を取り出し、その一覧を bundle exec rubocop / bundle exec rspec の引数に渡すことで、修正箇所だけを対象にチェックできる。
For rubocop
$ echo $(git diff origin/master `git branch | grep '*' | cut -d' ' -f2` | grep 'diff --git' | sed -E 's#diff --git a\/(.+) b\/.+#\1#') | { read FILES; bundle exec rubocop $FILES; }For rspec
$ echo $(git diff origin/master `git branch | grep '*' | cut -d' ' -f2` | grep 'diff --git' | sed -E 's#diff --git a\/(.+) b\/.+#\1#' | grep spec) | { read FILES; bundle exec rspec $FILES; }