ossobv / asterisklint

Asterisk PBX configuration syntax checker
GNU General Public License v3.0
63 stars 12 forks source link

pre-commit hook extension #2

Closed pvanagtmaal closed 8 years ago

pvanagtmaal commented 8 years ago

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
pvanagtmaal commented 8 years ago

Causes more than it fixes, closing

wdoekes commented 8 years ago

Heh, okay :)