-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enforce Google Java Format for PiranhaJava (#34)
This patch: 1. Runs GJF on all existing Java files under `java/` 2. Updates the sample app original and expected output under `sample/src/main/resources/com/uber/mylib/` 3. Sets up the build so that GJF is added as a git pre-commit hook whenever `./gradlew` is run under `java/` 4. Adds `verGJF` to the travis build for PiranhaJava, which will fail the build on any non-GJF formatted java files.
- Loading branch information
1 parent
c8c5965
commit dd050f8
Showing
16 changed files
with
651 additions
and
532 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
REPO_ROOT_DIR="$(git rev-parse --show-toplevel)" | ||
|
||
pushd "${REPO_ROOT_DIR}/java" > /dev/null | ||
files=$((git diff --cached --name-only --diff-filter=ACMR | grep -Ei "\.java$" | sed -e 's/^java\///') || true) | ||
if [ ! -z "${files}" ]; then | ||
comma_files=$(echo "$files" | paste -s -d "," -) | ||
"${REPO_ROOT_DIR}/java/gradlew" goJF -DgoogleJavaFormat.include="$comma_files" &>/dev/null | ||
git add $(echo "$files" | paste -s -d " " -) | ||
fi | ||
popd > /dev/null |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/env bash | ||
|
||
# stub pre-commit hook | ||
# just a runner for the real pre-commit script | ||
# if script cannot be found, exit without error | ||
# (to not block local commits) | ||
|
||
set -e | ||
|
||
REPO_ROOT_DIR="$(git rev-parse --show-toplevel)" | ||
PRE_COMMIT_SCRIPT="${REPO_ROOT_DIR}/java/config/hooks/pre-commit" | ||
|
||
if [ -f $PRE_COMMIT_SCRIPT ]; then | ||
source $PRE_COMMIT_SCRIPT | ||
fi |
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
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
Oops, something went wrong.