]> git.scottworley.com Git - pinch/commitdiff
Run tests on commit
authorScott Worley <scottworley@scottworley.com>
Fri, 29 May 2020 06:52:53 +0000 (23:52 -0700)
committerScott Worley <scottworley@scottworley.com>
Fri, 29 May 2020 06:52:53 +0000 (23:52 -0700)
git-pre-commit-hook [new file with mode: 0755]

diff --git a/git-pre-commit-hook b/git-pre-commit-hook
new file mode 100755 (executable)
index 0000000..7db6818
--- /dev/null
@@ -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