Skip to content

Commit 811b162

Browse files
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 openequella#25
1 parent 5962179 commit 811b162

File tree

5 files changed

+15
-2
lines changed

5 files changed

+15
-2
lines changed

.githooks/pre-commit

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/sh
2+
#
3+
# An example hook script to verify proper formatting.
4+
5+
files=$(git diff --cached --name-only --diff-filter=ACM | paste -s -d",")
6+
# this only works if ignoreFailures is set to false (which it is by default)
7+
./gradlew verifyGJF -DverifyGoogleJavaFormat.include="$files" &>/dev/null && exit 0
8+
9+
echo "Some files are not formatted properly. Please run:"
10+
echo "./gradlew gJF -DgoogleJavaFormat.include=\"$files\""
11+
exit 1

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ test*.properties
1616
test*.xml
1717
*.log
1818
!src/test/**/*.log
19+
test-check-files-output/

build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
plugins {
22
id 'com.github.sherter.google-java-format' version '0.8'
3+
id 'com.gtramontina.ghooks.gradle' version '1.1.0'
34
}
45

56
apply plugin: 'eclipse'

gradle/wrapper/gradle-wrapper.jar

0 Bytes
Binary file not shown.
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Fri Jul 12 11:19:13 CDT 2019
1+
#Tue Jun 09 16:59:18 MST 2020
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-bin.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip

0 commit comments

Comments
 (0)