pre-commit.sh 904 B

123456789101112131415161718192021222324252627282930313233343536
  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. cp wolfssl/options.h tmp.options.h
  9. # stash modified files not part of this commit, don't test them
  10. echo "\n\nStashing any modified files not part of commit\n\n"
  11. git stash -q --keep-index
  12. # do the commit tests
  13. echo "\n\nRunning commit tests...\n\n"
  14. ./commit-tests.sh
  15. RESULT=$?
  16. # restore modified files not part of this commit
  17. echo "\n\nPopping any stashed modified files not part of commit\n"
  18. git stash pop -q
  19. # restore current config
  20. echo "\nRestoring current config\n"
  21. mv tmp.status config.status
  22. # don't show output in case error from above
  23. ./config.status >/dev/null 2>&1
  24. mv tmp.options.h wolfssl/options.h
  25. make clean >/dev/null 2>&1
  26. make -j 8 >/dev/null 2>&1
  27. [ $RESULT -ne 0 ] && echo "\nOops, your commit failed\n" && exit 1
  28. echo "\nCommit tests passed!\n"
  29. exit 0