Advertisement
Guest User

Untitled

a guest
May 19th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. failed=false
  4.  
  5. ruby_files_modified=`git diff --staged --name-only --diff-filter=ACRM | grep -E '(\.rb|\.ruby|\.rake)' | xargs`
  6.  
  7. if ! [ -z "$ruby_files_modified" ]; then
  8. printf '\e[1m\e[34m========= reek ============\n\e[0m'
  9. bundle exec reek $ruby_files_modified
  10. if [ $? != 0 ]; then
  11. failed=true
  12. fi
  13. printf '\n'
  14.  
  15. printf '\e[1m\e[34m========= rubocop =========\n\e[0m'
  16. bundle exec rubocop --force-exclusion $ruby_files_modified
  17. if [ $? != 0 ]; then
  18. failed=true
  19. fi
  20. printf '\n'
  21. fi
  22.  
  23. #
  24. # If your test suite takes much time to run, consider removing the step below, as it
  25. # will run on any file update ( like README.md update, for example ).
  26. #
  27. files_modified=`git diff --staged`
  28.  
  29. if ! [ -z "$files_modified" ]; then
  30. printf '\e[1m\e[34m========= rspec ===========\n\e[0m'
  31. bundle exec rspec
  32. if [ $? != 0 ]; then
  33. failed=true
  34. fi
  35. printf '\n'
  36. fi
  37.  
  38. if $failed; then
  39. printf "\e[31m [!] Commit rejected, see the errors above. If you want to continue anyway use flag '--no-verify'. \e[0m \n"
  40.  
  41. exit 1
  42. fi
  43.  
  44. exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement