yahely / PreCommitHookPlugin

IntelliJ plugin for pre commit hook
67 stars 20 forks source link

Run lint on specific files #19

Open vsmiari opened 6 years ago

vsmiari commented 6 years ago

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
yahely commented 5 years ago

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