Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update example to work with latest version of pre-commit #14

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ Usage:

```
repos:
- repo: https://github.com/maltzj/google-style-precommit-hook
sha: b7e9e7fcba4a5aea463e72fe9964c14877bd8130
hooks:
- id: google-style-java
- repo: https://github.com/0x08/google-style-precommit-hook
rev: 503fa7c491becee130be17a10b03b275ce6f2330
hooks:
- id: google-style-java
```

*Note*: this file stores Google's code style formatter jar in a `.cache/`
Expand Down
8 changes: 4 additions & 4 deletions format-code.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/usr/bin/env sh
mkdir -p .cache
cd .cache
if [ ! -f google-java-format-1.7-all-deps.jar ]
if [ ! -f google-java-format-1.22.0-all-deps.jar ]
then
curl -LJO "https://github.com/google/google-java-format/releases/download/google-java-format-1.7/google-java-format-1.7-all-deps.jar"
chmod 755 google-java-format-1.7-all-deps.jar
curl -LJO "https://github.com/google/google-java-format/releases/download/v1.22.0/google-java-format-1.22.0-all-deps.jar"
chmod 755 google-java-format-1.22.0-all-deps.jar
fi
cd ..

changed_java_files=$(git diff --cached --name-only --diff-filter=ACMR | grep ".*java$" )
echo $changed_java_files
java -jar .cache/google-java-format-1.7-all-deps.jar --replace $changed_java_files
java -jar .cache/google-java-format-1.22.0-all-deps.jar --replace $changed_java_files