Last active
April 30, 2020 18:33
-
-
Save rantoniuk/7db70bd3e5e7879f60e68ae1a72b72e1 to your computer and use it in GitHub Desktop.
Git checkstyle pre-commit hook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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