Guest User

Untitled

a guest
Nov 21st, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. STASH_NAME="pre-commit-$(date +%s)"
  4. git stash save -q --keep-index $STASH_NAME
  5.  
  6. cd backend
  7. ERROR_MSG=`rails test | grep "errors,"`
  8. cd -
  9.  
  10. TASHES=$(git stash list)
  11. if [[ $STASHES == "$STASH_NAME" ]]; then
  12. git stash pop -q
  13. fi
  14.  
  15. ERR_NUM=`echo $ERROR_MSG | awk {'print $7'}`
  16. FAIL_NUM=`echo $ERROR_MSG | awk {'print $5'}`
  17.  
  18. if [ $FAIL_NUM -ne 0 ]
  19. then
  20. echo -e "Can't commit! You've broken fails $FAIL_NUM tests!!!"
  21. exit 1
  22. else
  23. if [ $ERR_NUM -ne 0 ]
  24. then
  25. echo -e "Can't commit! You've broken errors $ERR_NUM tests!!!"
  26. exit 1
  27. fi
  28. fi
  29.  
  30. echo -e "All tests passed. You didn't broke anything. Congrats!\n"
  31. exit 0
Add Comment
Please, Sign In to add comment