Fix pre commit hook

This commit is contained in:
Laura Hausmann 2023-02-08 23:31:06 +01:00
parent ec710177e8
commit 135a4619bc
Signed by: zotan
GPG Key ID: D044E84C5BE01605
1 changed files with 8 additions and 0 deletions

View File

@ -24,6 +24,8 @@ do
git show ":$file" > "$tmpfile"
# Format it
"$formatter" --no-backup -c AfRApay.MateCard/.uncrustify.cfg "$tmpfile"
# Format the non-tmp file too, to prevent loops
"$formatter" --no-backup -c AfRApay.MateCard/.uncrustify.cfg "$file"
# Create a blob object from the formatted file
hash=`git hash-object -w "$tmpfile"`
# Add it back to index
@ -32,6 +34,12 @@ do
rm "$tmpfile"
done
# If amend - force succeed
IS_AMEND=$(ps -ocommand= -p $PPID | grep -e '--amend');
if [ -n "$IS_AMEND" ]; then
exit 0
fi
# If no files left in index after formatting - fail
ret=0
if [ ! "`git diff --cached --name-only`" ]; then