src.elv.sh@v0.21.0-dev.0.20240515223629-06979efb9a2a/tools/pre-push (about) 1 #!/bin/sh -e 2 3 # To use this script as a Git hook: 4 # 5 # cd .git/hooks # from repo root 6 # ln -s ../../tools/pre-push . 7 8 if ! git diff HEAD --quiet; then 9 if git diff --cached --quiet; then 10 echo 'Local changes exist and none is staged; stashing.' 11 git stash 12 trap 'r=$?; git stash pop; trap - EXIT; exit $r' EXIT INT HUP TERM 13 else 14 echo 'Local changes exist and some are staged; not stashing.' 15 echo 'Make a commit, stash all the changes, or unstage all the changes.' 16 exit 1 17 fi 18 fi 19 20 # go.work is needed for gopls to function correctly when working on Go code 21 # inside website/ from VS Code (and possibly other development environments), 22 # but it changes the behavior of "go test", so force disable it. 23 export GOWORK=off 24 make test all-checks 25 make -C website check-rellinks 26 # A quick cross compilation test. Not exhaustive, but will catch most issues. 27 if test `go env GOOS` = windows; then 28 GOOS=linux GOARCH=amd64 go build ./... 29 GOOS=linux GOARCH=amd64 go test -o NUL -c ./... 30 else 31 GOOS=windows GOARCH=amd64 go build ./... 32 GOOS=windows GOARCH=amd64 go test -o /dev/null -c ./... 33 fi