[Wala-wala] reformatting of WALA source

8 views
Skip to first unread message

Manu Sridharan

unread,
Mar 10, 2019, 12:46:19 PM3/10/19
to WALA discussion and Q&A
Hi all,

I wanted to let you know that on WALA master we have reformatted the Java source code using Google Java Format (GJF), and we have added a check on CI to ensure the code stays formatted.  If you are on WALA master and would like your code to be automatically reformatted correctly whenever you do a local commit, you can install a git pre-commit hook to do so by running:

./gradlew installGitHooks

If you have existing branches with WALA modifications, the reformatting may cause conflicts if you want to pull in the latest changes from master.  Here are some instructions for rebasing any outstanding branches over the reformatting change.  Note that 6b57dbd2eaca95a7ab7d095be73e54041529b9e5 is the git SHA of the re-formatting commit.

  1. Ensure your workspace is clean, with no unstaged / uncommitted changes.

  2. Pull the latest master branch (git checkout master; git pull)

  3. Checkout your branch (git checkout my_branch)

  4. Rebase until just before the reformat commit and fix any conflicts manually:
    git rebase 6b57dbd2eaca95a7ab7d095be73e54041529b9e5^

  5. Download Google Java Format manually with wget https://repo1.maven.org/maven2/com/google/googlejavaformat/google-java-format/1.7/google-java-format-1.7-all-deps.jar -P ~

  6. Reformat any changed Java files on your branch by running the following command:
    git diff --name-only 6b57dbd2eaca95a7ab7d095be73e54041529b9e5^ | xargs java -jar  ~/google-java-format-1.7-all-deps.jar --replace

  7. Commit your reformat changes:
    git commit -am “formatting

  8. Rebase over the reformat commit on master, always taking the changes from your branch:
    git rebase -X theirs 6b57dbd2eaca95a7ab7d095be73e54041529b9e5
    There is no need to manually resolve conflicts for this command since we know the commit on master is just the reformatting.

  9. Finally, rebase over the latest master and manually fix conflicts: git rebase master


The instructions are not bullet-proof but they should mostly automate the rebase.

Thanks, and let us know if you have questions.

Best,
Manu
 
Reply all
Reply to author
Forward
0 new messages