PreCommitHookPlugin
PreCommitHookPlugin copied to clipboard
Run lint on specific files
Is there a way to create a pre-commit git hook that will run lint only on the files that are about to be commited and abort the commit if there are any errors? So far I have accomplished this but it checks every file in my project and not just the files that have changes and are about to be commited. This is my code so far:
#!/bin/sh
echo "Running static analysis..."
./gradlew app:lint --daemon
status=$?
if [ "$status" = 0 ] ; then
echo "Static analysis found no problems."
exit 0
else
echo 1>&2 "Static analysis found violations it could not fix."
exit 1
fi
Yes, the plugin calls your script with the changed files as arguments.