From: Scott Worley Date: Thu, 23 May 2019 08:45:48 +0000 (-0700) Subject: git pre-commit hook X-Git-Tag: v1.0~21 X-Git-Url: http://git.scottworley.com/inverse-tax/commitdiff_plain/9d36e0c2b4cc8229b588b751a04e8119f54034b7?hp=0993d859b81ccc99c56b5ded5ed85067dfe8196f git pre-commit hook --- diff --git a/git-pre-commit-hook b/git-pre-commit-hook new file mode 100755 index 0000000..00bf3d0 --- /dev/null +++ b/git-pre-commit-hook @@ -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