Fixed hooks

This commit is contained in:
Jakob Meier 2024-02-22 15:32:55 +01:00
parent a897d4c4af
commit b013964615
No known key found for this signature in database
GPG key ID: 66BDC7E6A01A6152

View file

@ -1,4 +1,12 @@
git_dir=$(git rev-parse --git-dir) #!/bin/sh
project_dir=$(dirname $git_dir) # adapted from https://prettier.io/docs/en/precommit.html#option-5-shell-script
FILES=$(git diff --cached --name-only --diff-filter=ACMR | sed 's| |\\ |g' | grep '.dart$')
[ -z "$FILES" ] && exit 0
dart format $project_dir # Format all selected files
echo "$FILES" | xargs dart format
# Add back the formatted files to staging
echo "$FILES" | xargs git add
exit 0