Skip to content

Instantly share code, notes, and snippets.

@rantoniuk
Last active April 30, 2020 18:33
Show Gist options
  • Save rantoniuk/7db70bd3e5e7879f60e68ae1a72b72e1 to your computer and use it in GitHub Desktop.
Save rantoniuk/7db70bd3e5e7879f60e68ae1a72b72e1 to your computer and use it in GitHub Desktop.
Git checkstyle pre-commit hook
#!/bin/bash -e
set -x
DIFF=$(git diff master --name-only | grep java | xargs)
JAR_SRC="https://github.com/checkstyle/checkstyle/releases/download/checkstyle-8.32/checkstyle-8.32-all.jar"
JAR_PATH="checkstyle-8.32-all.jar"
if [ -z "$DIFF" ]; then
exit 0
fi
if [[ ! -f "$JAR_PATH" ]]; then
echo "Downloading $JAR_SRC";
curl -L -o "$JAR_PATH" $JAR_SRC;
fi
java -jar "$JAR_PATH" -c /google_checks.xml $DIFF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment