-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: lock in nph version and add pre-commit hook (#2938)
- Loading branch information
1 parent
e8bce67
commit d63e343
Showing
5 changed files
with
76 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |