Improve git hook output

This commit is contained in:
Talia 2022-06-14 15:46:48 +02:00
parent 802e57791e
commit dcd8307c54
1 changed files with 13 additions and 5 deletions

View File

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
filter=$(git config hooks.filter) filter=$(git config hooks.filter)
validation=$(git config hooks.validation) validate=$(git config hooks.validate)
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
@ -32,19 +32,27 @@ if [ -n "$filter" ]; then
rm .git rm .git
fi fi
if [ -n "$validation" ]; then if [ -n "$validate" ]; then
$validation || error=1 /bin/echo -e "\x1b[33mValidating commit\x1b[0m"
/bin/echo -e "\x1b[2mλ $validate\x1b[0m"
if $validate
then
/bin/echo -e "\x1b[32mValidation Passed!\x1b[0m"
else
error=1
/bin/echo -e "\x1b[1;31mValidation Failed!\x1b[0m"
fi
fi fi
case $indentation in case $indentation in
tab|tabs) tab|tabs)
echo "Checking tab indentation" /bin/echo -e "\x1b[2mChecking tab indentation"
for file in $(new); do for file in $(new); do
check '\t' $file || error=1 check '\t' $file || error=1
done done
;; ;;
space|spaces) space|spaces)
echo "Checking space indentation" /bin/echo -e "\x1b[2mChecking space indentation"
for file in $(new); do for file in $(new); do
check ' ' $file || error=1 check ' ' $file || error=1
done done