chore: lock in nph version and add pre-commit hook (#2938)

This commit is contained in:
fryorcraken
2024-08-20 15:14:35 +10:00
committed by GitHub
parent 4b9bee99a8
commit a4c71f01e5
5 changed files with 76 additions and 6 deletions
+16
View File
@@ -0,0 +1,16 @@
#!/bin/sh
echo "Running pre-commit hook"
# Regexp for grep to only choose some file extensions for formatting
exts="\.\(nim\|nims\)$"
# Build nph lazily
make build-nph || (1>&2 echo "failed to build nph. Pre-commit formatting will not be done."; exit 0)
# Format staged files
git diff --cached --name-only --diff-filter=ACMR | grep "$exts" | while read file; do
echo "Formatting $file"
make nph/"$file"
git add "$file"
done