Loading repository data…
Loading repository data…
avi-sanwal / repository
Reformats modified Java source code to comply with Google Java Style using pre-commit hook
A transparent discovery signal based on current public GitHub metadata.
This score does not audit code, security, maintainers, documentation quality, or suitability. Verify the repository and its current documentation before adoption.
A pre-commit hook for automatically formatting only the modified lines of Java files using google-java-format.
.java files using google-java-format.gitpython3Install pre-commit:
pip install pre-commit
Add this repo as a hook in your project's .pre-commit-config.yaml:
- repo: https://github.com/avi-sanwal/google-java-format-hook.git
rev: main # or the latest release/tag
hooks:
- id: google-java-format-hook
Install the pre-commit hook:
pre-commit install
On commit, the hook will:
google-java-format and the diff script if not present..java files.VERBOSE=1 environment variable. E.g. VERBOSE=1 git commit ....To manually format only the changed lines in .java files, run:
git diff -U0 --no-color | python3 format.py
VERSION variable in format.py.To run tests, ensure you have pytest installed, and then run:
VERBOSE=1 pytest --capture=sys
See LICENSE.