pre-push 813 B

123456789101112131415161718192021222324252627
  1. #!/bin/sh -e
  2. # To use this script as a Git hook:
  3. #
  4. # cd .git/hooks # from repo root
  5. # ln -s ../../tools/pre-push .
  6. if ! git diff HEAD --quiet; then
  7. if git diff --cached --quiet; then
  8. echo 'Local changes exist and none is staged; stashing.'
  9. git stash
  10. trap 'r=$?; git stash pop; trap - EXIT; exit $r' EXIT INT HUP TERM
  11. else
  12. echo 'Local changes exist and some are staged; not stashing.'
  13. echo 'Make a commit, stash all the changes, or unstage all the changes.'
  14. exit 1
  15. fi
  16. fi
  17. make test checkstyle lint codespell
  18. make -C website check-rellinks
  19. # A quick cross compilation test. Not exhaustive, but will catch most issues.
  20. if test `go env GOOS` = windows; then
  21. GOOS=linux GOARCH=amd64 go build ./...
  22. else
  23. GOOS=windows GOARCH=amd64 go build ./...
  24. fi