Add filter and validation functions to pre-commit hook
This commit is contained in:
parent
1726d4e8c8
commit
4c74a58aac
1 changed files with 14 additions and 0 deletions
|
@ -1,5 +1,7 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
|
filter=$(git config hooks.filter)
|
||||||
|
validation=$(git config hooks.validation)
|
||||||
indentation=$(git config hooks.indentation)
|
indentation=$(git config hooks.indentation)
|
||||||
temp=$(mktemp -p /dev/shm -d -t git-hook.XXXX)
|
temp=$(mktemp -p /dev/shm -d -t git-hook.XXXX)
|
||||||
export GIT_DIR=$(git rev-parse --show-toplevel)/.git
|
export GIT_DIR=$(git rev-parse --show-toplevel)/.git
|
||||||
|
@ -22,6 +24,18 @@ check() {
|
||||||
git checkout-index --prefix="$temp/index/" --all
|
git checkout-index --prefix="$temp/index/" --all
|
||||||
|
|
||||||
cd $temp/index/
|
cd $temp/index/
|
||||||
|
|
||||||
|
if [ -n "$filter" ]; then
|
||||||
|
ln -s $GIT_DIR/ .git
|
||||||
|
$filter
|
||||||
|
git add --all
|
||||||
|
rm -rf .git
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$validation" ]; then
|
||||||
|
$validation || error=1
|
||||||
|
fi
|
||||||
|
|
||||||
case $indentation in
|
case $indentation in
|
||||||
tab|tabs)
|
tab|tabs)
|
||||||
echo "Checking tab indentation"
|
echo "Checking tab indentation"
|
||||||
|
|
Loading…
Reference in a new issue