Fix clang-tidy error in pre-commit script (#61918)

Summary:
Fixes a clang-tidy error in the git-pre-commit script. See log below for the error it fixes.

```
Running pre-commit flake8
Running pre-commit clang-tidy
usage: clang_tidy [-h] [-e CLANG_TIDY_EXE] [-g GLOB] [-x REGEX] [-c COMPILE_COMMANDS_DIR] [--diff-file DIFF_FILE] [-p PATHS [PATHS ...]] [-n] [-v] [-q] [--config-file CONFIG_FILE] [--print-include-paths] [-I INCLUDE_DIR] [-s]
                  [--disable-progress-bar]
                  [extra_args [extra_args ...]]
clang_tidy: error: unrecognized arguments: -j
```

It gets rid of the redundant binary check because `tools.linter.clang_tidy` already does this.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/61918

Test Plan: Run `tools/git-pre-commit`. It should not show a clang-tidy error.

Reviewed By: driazati

Differential Revision: D29796383

Pulled By: 1ntEgr8

fbshipit-source-id: b804b0170747f04e84d21e03d1c4985748d78cf2
This commit is contained in:
Elton Leander Pinto 2021-07-20 12:35:19 -07:00 committed by Facebook GitHub Bot
parent f6446802c7
commit 91bc285084

View File

@ -2,25 +2,12 @@
set -e
echo "Running pre-commit flake8"
python tools/linter/flake8_hook.py
python3 tools/linter/flake8_hook.py
if [ $(which clang-tidy) ]
then
echo "Running pre-commit clang-tidy"
git diff HEAD > pr.diff
python tools/linter/clang_tidy \
--paths torch/csrc \
--diff-file "pr.diff" \
-g"-torch/csrc/jit/passes/onnx/helper.cpp" \
-g"-torch/csrc/jit/passes/onnx/shape_type_inference.cpp" \
-g"-torch/csrc/jit/serialization/onnx.cpp" \
-g"-torch/csrc/jit/serialization/export.cpp" \
-g"-torch/csrc/jit/serialization/import.cpp" \
-j
else
echo "WARNING: Couldn't find clang-tidy executable."
echo " Please install it if you want local clang-tidy checks."
fi
echo "Running pre-commit clang-tidy"
git diff HEAD > pr.diff
python3 -m tools.linter.clang_tidy --diff-file "pr.diff"
rm pr.diff
echo "Running pre-commit clang-format"
tools/linter/git-clang-format HEAD~ --force