From 811b1624505768ad2bbc4f99effe440130649fc7 Mon Sep 17 00:00:00 2001 From: Christian Murphy Date: Tue, 9 Jun 2020 17:04:03 -0700 Subject: [PATCH] build: setup pre commit hook to check java format * updates gradle wrapper to latest version to enable ghooks to be used. * enables ghooks plugin for gradle * adds google java format pre commit hook * adds test check file output to gitignore resolves #25 --- .githooks/pre-commit | 11 +++++++++++ .gitignore | 1 + build.gradle | 1 + gradle/wrapper/gradle-wrapper.jar | Bin 54783 -> 54783 bytes gradle/wrapper/gradle-wrapper.properties | 4 ++-- 5 files changed, 15 insertions(+), 2 deletions(-) create mode 100755 .githooks/pre-commit diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100755 index 0000000..ec76c76 --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,11 @@ +#!/bin/sh +# +# An example hook script to verify proper formatting. + +files=$(git diff --cached --name-only --diff-filter=ACM | paste -s -d",") +# this only works if ignoreFailures is set to false (which it is by default) +./gradlew verifyGJF -DverifyGoogleJavaFormat.include="$files" &>/dev/null && exit 0 + +echo "Some files are not formatted properly. Please run:" +echo "./gradlew gJF -DgoogleJavaFormat.include=\"$files\"" +exit 1 \ No newline at end of file diff --git a/.gitignore b/.gitignore index cbe2fae..be46261 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ test*.properties test*.xml *.log !src/test/**/*.log +test-check-files-output/ diff --git a/build.gradle b/build.gradle index d4e139d..0f6376f 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,6 @@ plugins { id 'com.github.sherter.google-java-format' version '0.8' + id 'com.gtramontina.ghooks.gradle' version '1.1.0' } apply plugin: 'eclipse' diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 21d09658792d545f59475bd42be112b26a6a0744..2812ffaeec5cd3930c2c048efd2b6c7ca610cb52 100644 GIT binary patch delta 28 hcmeyrn)&}~<_*?ISTfsB25h!JQXmLsP2POf2LQ|*4Z;8b delta 28 hcmeyrn)&}~<_*?ISkj{2_-(d7QXmLsP2POf2LQ@&4Ws}7 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 2bad1db..b0434c1 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Fri Jul 12 11:19:13 CDT 2019 +#Tue Jun 09 16:59:18 MST 2020 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip