logos-messaging-go-bindings/scripts/git_pre_commit_format.sh
Ivan Folgueira Bande 2f6de9187f Squashed 'third-party/nwaku/' content from commit d94cb7c7
git-subtree-dir: third-party/nwaku
git-subtree-split: d94cb7c73631ffd4b934839ba58bc622d331a135
2025-10-02 11:52:12 +02:00

17 lines
434 B
Bash

#!/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