From 9d36e0c2b4cc8229b588b751a04e8119f54034b7 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Thu, 23 May 2019 01:45:48 -0700 Subject: [PATCH] git pre-commit hook --- 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..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 -- 2.44.1