Skip to content
This repository has been archived by the owner on Aug 16, 2024. It is now read-only.

Commit

Permalink
Fix clang-tidy error in pre-commit script (pytorch#61918)
Browse files Browse the repository at this point in the history
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: pytorch#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
  • Loading branch information
1ntEgr8 authored and facebook-github-bot committed Jul 20, 2021
1 parent f644680 commit 91bc285
Showing 1 changed file with 5 additions and 18 deletions.
23 changes: 5 additions & 18 deletions tools/git-pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 91bc285

Please sign in to comment.