Running google java format - robolectric/robolectric GitHub Wiki

If you would like to make a contribution to Robolectric, we generally require the code to be run through google-java-format. To do so, you can run the following commands.

curl -L -o $HOME/google-java-format.jar https://github.com/google/google-java-format/releases/download/v1.15.0/google-java-format-1.15.0-all-deps.jar
curl -L -o $HOME/google-java-format-diff.py https://raw.githubusercontent.com/google/google-java-format/v1.15.0/scripts/google-java-format-diff.py
cd $ROBOLECTRIC_ROOT
git fetch origin master
git diff -U0 $(git merge-base HEAD origin/master) | python3 $HOME/google-java-format-diff.py --google-java-format-jar=$HOME/google-java-format.jar -p1 -i
# commit the changes

Note: the origin is the remote name for official Robolectric git repo link([email protected]:robolectric/robolectric.git or https://github.com/robolectric/robolectric.git), and we should change origin to local remote name that refers to official Robolectric git repo link, if origin is not; otherwise those commands will add unrelated formatting changes sometimes.