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

Test of applying clang-format to whole repo #843

Closed
wants to merge 6 commits into from

Conversation

pmolodo
Copy link
Contributor

@pmolodo pmolodo commented Oct 16, 2020

So that we can preview what code will look like with latest changes to .clang-format, and for use with testing of merging into existing PRs / branches.

Instructions for applying clang-format to an outstanding branch / PR

These instructions assume that:

  • $MAYA_USD_REPO points to the root directory of a checkout of the maya-usd source repository
  • $COMMIT_BEFORE_FORMAT points at the commit in the dev branch immediately before clang-format is applied (322f102 in my example clang_format_test branch)
  • $FORMAT_COMMIT points at the commit in the dev branch where clang-format was applied (eb6c346 in my example clang_format_test branch)
  • $FORMAT_BRANCH points at the head of the branch, containing any commits after $FORMAT_COMMIT (once we do this for real, this would just be dev, but is clang_format_test in my example branch)
  • $YOUR_BRANCH is the name of the branch which does not have clang-format applied, but want to merge dev (with clang-format) into

Download and install clang-tools 10.0 (generally included as part of llvm):

Merge + apply clang format to your branch (these instructions assume Linux, you may need to adapt to other OSes):

cd $MAYA_USD_REPO
git checkout $YOUR_BRANCH
git merge $COMMIT_BEFORE_FORMAT
# resolve any merge errors that may have resulted from previous command
# this will technically create a merge in git, but won't actually change the
# state of any files
git merge -s ours $FORMAT_COMMIT
# now, apply the formatting to your branch...
find . -regextype posix-egrep -regex "$(echo '.*('$(echo $(cat .clang-format-include) | tr ' ' '\|')')')" -exec clang-format -i {} \+
# ...then ammend the commit, to make this the new "merged" result
git commit -a --amend --no-edit
# now merge in any of the latest stuff, that came AFTER the clang-format changes
git merge $FORMAT_BRANCH
# OPTIONAL: do a sanity check, to make sure that the diff of your branch to
#           the format branch now only contains "substantive" changes (ie, not a
#           bunch of formatting changes!)
git diff $FORMAT_BRANCH
# ...or, if you have a gui difftool set up in your .gitconfig:
git difftool $FORMAT_BRANCH

@kxl-adsk kxl-adsk added the build Related to building maya-usd repository label Oct 17, 2020
Paul Molodowitch added 6 commits October 22, 2020 09:54
...because using a macro with no "namespace" caused problems with clang-format
command run (on linux):

find . -regextype posix-egrep -regex "$(echo '.*('$(echo $(cat .clang-format-include) | tr ' ' '\|')')')" -exec clang-format -i {} \+
@kxl-adsk kxl-adsk mentioned this pull request Nov 4, 2020
@kxl-adsk
Copy link

kxl-adsk commented Nov 4, 2020

Closing this one since it was just a test and the final PR is now ready - #890

@kxl-adsk kxl-adsk closed this Nov 4, 2020
@kxl-adsk kxl-adsk mentioned this pull request Nov 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Related to building maya-usd repository
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants