Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/55328
**Summary**
The `clang-format` reference hashes committed in #54737 have newlines at
the end but the locally computed ones do not. This commit removes these
newlines so that the `clang-format` binary verification step doesn't
fail.
**Test Plan**
`./tools/clang_format_all.py`, ran successfully.
**Fixes**
This commit fixes#54790.
Test Plan: Imported from OSS
Reviewed By: nikithamalgifb
Differential Revision: D27577398
Pulled By: SplitInfinity
fbshipit-source-id: e30bee58c2eb5ea96ed0a503480dea4f67b86aca
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/55281
## Summary
` python3 tools/clang_format_all.py` is complaining that binary is not what expected. Find out the reference hash include an extra new line comparing with the actual hash. In this pr,
1. Use `expr(hash)` to show the raw string, such that it's easier to compare two string.
2. Remove the extra new line.
3. Run `python3 tools/clang_format_all.py `, and it formats `torch/csrc/jit/runtime/static/passes.h`.
Before the change,
```
(base) chenlai@chenlai-mp pytorch % python3 tools/clang_format_all.py -v
Found pre-existing clang-format binary, skipping download
Reference Hash: '5fde7bccf65032da297dfb1f18e4a95e96e278fa397e9dcaf364dfe23ec46353'
Actual Hash: '5fde7bccf65032da297dfb1f18e4a95e96e278fa397e9dcaf364dfe23ec46353'
The downloaded binary is not what was expected!
(base) chenlai@chenlai-mp pytorch %
```
After the change,
```
(base) chenlai@chenlai-mp pytorch % python3 tools/clang_format_all.py -v
Found pre-existing clang-format binary, skipping download
Reference Hash: '5fde7bccf65032da297dfb1f18e4a95e96e278fa397e9dcaf364dfe23ec46353\n'
Actual Hash: '5fde7bccf65032da297dfb1f18e4a95e96e278fa397e9dcaf364dfe23ec46353'
The downloaded binary is not what was expected!
(base) chenlai@chenlai-mp pytorch %
```
After strip the hash str:
```
(base) chenlai@chenlai-mp pytorch % python3 tools/clang_format_all.py -v
Downloading clang-format to /Users/chenlai/pytorch/.clang-format-bin
0% |################################################################| 100%
Reference Hash: '5fde7bccf65032da297dfb1f18e4a95e96e278fa397e9dcaf364dfe23ec46353'
Actual Hash: '5fde7bccf65032da297dfb1f18e4a95e96e278fa397e9dcaf364dfe23ec46353'
Using clang-format located at /Users/chenlai/pytorch/.clang-format-bin/clang-format
```
Test Plan: Imported from OSS
Reviewed By: iseeyuan
Differential Revision: D27556372
Pulled By: cccclai
fbshipit-source-id: 2fd1ba220733e767ffab41ab31e162f0bf3f1d62
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/37058
We shouldn't add advisory checks to master, because PRs will get
reverted if they fail. This PR makes the following changes:
1. Factor out the binary fetch logic into `clang_format_utils.py`
2. Copypasta the canonical git integration from llvm and modify it to
use our binary fetcher. No more bikeshedding about how to integrate,
we just use the standard integration.
3. Change the CI job to run on pull-requests only and use
`git-clang-format`.
4. The original `clang_format.py` is now renamed `clang_format_all.py`
to reflect its purpose.
5. The pre-commit hook has been changed to use `git-clang-format`.
For pre-commit hook users: no changes required.
For others: add `tools/git-clang-format` to your PATH and you can do `git clang-format` to format your working tree.
Test Plan: Imported from OSS
Differential Revision: D21180893
Pulled By: suo
fbshipit-source-id: f8358fb7ce26f11585226aaac5ed89d379257bfb