The pre-commit hook as-is displays a lot (arguably) irrelevant stuff if other files than changed ones trigger warnings. A possible solution would be to use the output of the following:
git diff --cached --name-only --diff-filter=ACM
Only staged changes would then trigger the dialplan-check.
The full pre-commit file:
#!/bin/sh
export ALINT_IGNORE= # adjust as needed
for c in $(git diff --cached --name-only --diff-filter=ACM);
do
asterisklint dialplan-check /PATH/TO/extensions.conf/$c
done
ret=$?
if test $ret -ne 0; then
echo >&2
echo 'One or more dialplan syntax errors. Please fix before committing.' >&2
exit $ret
fi
exit 0
The pre-commit hook as-is displays a lot (arguably) irrelevant stuff if other files than changed ones trigger warnings. A possible solution would be to use the output of the following:
git diff --cached --name-only --diff-filter=ACM
Only staged changes would then trigger the
dialplan-check
.The full pre-commit file: