LoginSignup
0
0

More than 5 years have passed since last update.

ciで走るコマンドをgitのpre-commitで全部走らせる

Posted at

git pushしてから、ciで数分後にコケましたってなるのがイライラしすぎたので、gitのpre-commit時点で全部叩くだけ

#!/bin/bash

git diff --cached --name-only --diff-filter=AM | grep '\.rb$' | xargs bundle exec rubocop
cop=$?

git diff --cached --name-only --diff-filter=AM | grep '^app/.*\.rb$' | xargs bundle exec spec
spec=$?

git diff --cached --name-only --diff-filter=AM | grep '^app/assets/stylesheets/.*\.scss$' | xargs bundle exec scss-lint
scss=$?

git diff --cached --name-only --diff-filter=AM | grep '^app/views/.*\.haml$' | xargs bundle exec haml-lint
haml=$?

exit $(($cop || $spec || $scss || $haml))
chmod a+x .git/hooks/pre-commit

あとはgit commit -vして待つだけ

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0