pre-commit.sh 831 B

12345678910111213141516171819202122232425262728293031323334
  1. #!/bin/sh
  2. #
  3. #
  4. # Our "pre-commit" hook.
  5. # save current config
  6. echo "\n\nSaving current config\n\n"
  7. cp config.status tmp.status
  8. # stash modified files not part of this commit, don't test them
  9. echo "\n\nStashing any modified files not part of commit\n\n"
  10. git stash -q --keep-index
  11. # do the commit tests
  12. echo "\n\nRunning commit tests...\n\n"
  13. ./commit-tests.sh
  14. RESULT=$?
  15. # restore modified files not part of this commit
  16. echo "\n\nPopping any stashed modified files not part of commit\n"
  17. git stash pop -q
  18. # restore current config
  19. echo "\nRestoring current config\n"
  20. mv tmp.status config.status
  21. # don't show output incase error from above
  22. ./config.status >/dev/null 2>&1
  23. make clean >/dev/null 2>&1
  24. make -j 8 >/dev/null 2>&1
  25. [ $RESULT -ne 0 ] && echo "\nOops, your commit failed\n" && exit 1
  26. echo "\nCommit tests passed!\n"
  27. exit 0