fix: Fix clang-tidy pre-commit hook to locate compile_commands.json from repo root - #7325
Conversation
…repo root Signed-off-by: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com>
| return 0 | ||
|
|
||
| repo_root = Path(__file__).parent.parent | ||
| repo_root = Path( |
There was a problem hiding this comment.
nit: I would probably put it as REPO_ROOT in the top of the file
There was a problem hiding this comment.
I can, wrap it in a cached accessor, not let it be a const, change the signatures of functions needing it. It will need more efforts for you guys to review. I would rather leave be for now.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #7325 +/- ##
=========================================
- Coverage 82.4% 82.3% -0.0%
=========================================
Files 1011 1011
Lines 76330 76330
Branches 7318 7316 -2
=========================================
- Hits 62874 62850 -24
- Misses 13456 13480 +24 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Copilot wasn't able to review any files in this pull request.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…rom repo root (XRPLF#7325) Signed-off-by: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com>
High Level Overview of Change
Fix the
bin/pre-commit/clang_tidy_check.pypre-commit hook so it correctly locates the repo root when searching forbuild/compile_commands.json. Previously the script computed the repo root asPath(__file__).parent.parent, which resolves tobin/rather than the repository root, causing the hook to fail to find the compile database.Also marks
.github/scripts/levelization/generate.pyas executable (mode change only).Context of Change
The pre-commit hook needs
compile_commands.json(generated under<repo_root>/build/) to driveclang-tidy. The previous path computation was off by one directory level, so the hook never found the compile database when invoked from the project. The fix usesgit rev-parse --show-toplevel(withcwdpinned to the script's directory) to obtain the true repo root regardless of where the hook is invoked from.API Impact
libxrplchange (any change that may affectlibxrplor dependents oflibxrpl)Test Plan
TIDY=1; confirm the hook now locatesbuild/compile_commands.jsonand runsclang-tidyagainst staged files.git rev-parselookup still resolves the repo root correctly.