mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-07-21 02:04:17 +00:00
contrib: add git-hook to verify code-style
Signed-off-by: Antonio Cardace <acardace@redhat.com>
This commit is contained in:
parent
5119d00374
commit
eebed47257
21
contrib/scripts/code-style-git-post-commit-hook
Executable file
21
contrib/scripts/code-style-git-post-commit-hook
Executable file
|
@ -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" "${CHANGED_FILES}"
|
||||
fi
|
Loading…
Reference in a new issue