pytorch
52787388 - [tools] Add clang_format_new.py to download, verify and run clang-format binary (#34566)

Commit
4 years ago
[tools] Add clang_format_new.py to download, verify and run clang-format binary (#34566) Summary: **Summary** This commit adds `tools/clang_format_new.py`, which downloads a platform-appropriate clang-format binary to a `.gitignored` location, verifies the binary by comparing its SHA1 hash to a reference hash (also included in this commit), and runs it on all files matched a specific regex in a list of whitelisted subdirectories of pytorch. This script will eventually replace `tools/clang_format.py`. **Testing** Ran the script. *No Args* ``` pytorch > ./tools/clang_format.py Downloading clang-format to /Users/<user>/Desktop/pytorch/.clang-format-bin 0% |################################################################| 100% Using clang-format located at /Users/<user>/Desktop/pytorch/.clang-format-bin/clang-format > echo $? 0 > git status <bunch of files> ``` `--diff` *mode* ``` > ./tools/clang_format.py --diff Using clang-format located at /Users/<user>/Desktop/pytorch/.clang-format-bin/clang-format Some files are not formatted correctly > echo $? 1 <format files using the script> > ./tools/clang_format.py --diff Using clang-format located at /Users/<user>/Desktop/pytorch/.clang-format-bin/clang-format All files are formatted correctly > echo $? 0 ``` Pull Request resolved: https://github.com/pytorch/pytorch/pull/34566 Differential Revision: D20431290 Pulled By: SplitInfinity fbshipit-source-id: 3966f769cfb923e58ead9376d85e97127415bdc6
Author
Meghan Lele
Parents
Loading