]> git.scottworley.com Git - inverse-tax/commitdiff
git pre-commit hook
authorScott Worley <scottworley@scottworley.com>
Thu, 23 May 2019 08:45:48 +0000 (01:45 -0700)
committerScott Worley <scottworley@scottworley.com>
Thu, 23 May 2019 08:45:48 +0000 (01:45 -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..00bf3d0
--- /dev/null
@@ -0,0 +1,22 @@
+#!/bin/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"
+
+./test.sh
+
+popd