PreCommitHookPlugin icon indicating copy to clipboard operation
PreCommitHookPlugin copied to clipboard

Run lint on specific files

Open vsmiari opened this issue 6 years ago • 1 comments

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

vsmiari avatar Jun 25 '18 14:06 vsmiari

Yes, the plugin calls your script with the changed files as arguments.

yahely avatar Jul 13 '18 06:07 yahely