diff options
| author | Michael Biebl <biebl@debian.org> | 2024-05-05 00:07:30 +0200 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2024-05-05 00:07:30 +0200 |
| commit | 34bb501be08aa2b313d88e67d6e0a7e0a3f9cfa6 (patch) | |
| tree | 4e6220877828be4c6f261de09ec0cb2d80e32389 /contrib/scripts/code-style-git-post-commit-hook | |
| parent | bba2e4b4de668db525cbfdfc35292e5a0b51671a (diff) | |
New upstream version 1.47.90 upstream/1.47.90
Diffstat (limited to 'contrib/scripts/code-style-git-post-commit-hook')
| -rwxr-xr-x | contrib/scripts/code-style-git-post-commit-hook | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/contrib/scripts/code-style-git-post-commit-hook b/contrib/scripts/code-style-git-post-commit-hook new file mode 100755 index 00000000..8d464842 --- /dev/null +++ b/contrib/scripts/code-style-git-post-commit-hook @@ -0,0 +1,21 @@ +#!/bin/sh + +set -e + +DISABLED=${NM_HOOK_DISABLED:0} + +if [ "$DISABLED" == 1 ]; then + echo "COMMIT HOOK DISABLED" + exit 0 +fi + +FORMATTER=contrib/scripts/nm-code-format.sh + +# Filter only C source files +CHANGED_FILES=$(git log --pretty='' --name-only -n1 | grep -E '\.c$|\.h$' | tr '\n' ' ') + +echo $CHANGED_FILES + +if [ -x "$FORMATTER" ] && [ ! -z "$CHANGED_FILES" ]; then + "$FORMATTER" -n "${CHANGED_FILES}" +fi |