]> git.scottworley.com Git - pinch/blob - git-pre-commit-hook
ce476144f4f5a6d9c2e7ed8a018b7b14b7692f73
[pinch] / git-pre-commit-hook
1 #!/usr/bin/env bash
2
3 # Copy me to .git/hooks/pre-commit
4
5 set -e
6
7 cleanup() {
8 if [[ "$D" && -e "$D" ]];then
9 rm -rf "$D"
10 fi
11 }
12 trap cleanup EXIT
13
14 D=$(mktemp -d)
15 [[ "$D" && -d "$D" ]]
16
17 git checkout-index --prefix="$D/" -a
18 pushd "$D"
19
20 # So we don't confuse the inner git invocations inside the tests with
21 # the outer git invocation that's trying to commit a change.
22 unset GIT_AUTHOR_DATE
23 unset GIT_AUTHOR_EMAIL
24 unset GIT_AUTHOR_NAME
25 unset GIT_CONFIG_PARAMETERS
26 unset GIT_EXEC_PATH
27 unset GIT_INDEX_FILE
28 unset GIT_PREFIX
29
30 nix-shell --arg lint true --run './test.sh lint'
31
32 popd