From d2d9efeffd9867660166926c6ac3262b8d22e111 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Thu, 28 May 2020 23:52:53 -0700 Subject: [PATCH 1/1] Run tests on commit --- git-pre-commit-hook | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 git-pre-commit-hook 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 -- 2.44.1