From: Scott Worley Date: Fri, 29 May 2020 06:52:53 +0000 (-0700) Subject: Run tests on commit X-Git-Tag: 1.3~2 X-Git-Url: http://git.scottworley.com/pinch/commitdiff_plain/d2d9efeffd9867660166926c6ac3262b8d22e111?ds=sidebyside Run tests on commit --- diff --git a/git-pre-commit-hook b/git-pre-commit-hook new file mode 100755 index 0000000..7db6818 --- /dev/null +++ b/git-pre-commit-hook @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +# Copy me to .git/hooks/pre-commit + +set -e + +cleanup() { + if [[ "$D" && -e "$D" ]];then + rm -rf "$D" + fi +} +trap cleanup EXIT + +D=$(mktemp -d) +[[ "$D" && -d "$D" ]] + +git checkout-index --prefix="$D/" -a +pushd "$D" + +nix-shell --run ./test.sh + +popd