Skip to content

fix: make repo-root path absolute#387

Merged
2bndy5 merged 2 commits into
mainfrom
mk-repo-root-abs
Jun 23, 2026
Merged

fix: make repo-root path absolute#387
2bndy5 merged 2 commits into
mainfrom
mk-repo-root-abs

Conversation

@2bndy5

@2bndy5 2bndy5 commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

Keeping the repo-root path relative breaks parsing of absolute paths in clang-tidy output.

This didn't surface in the tests because they all use a compilation database generated for ninja (which uses relative paths). But in the test repo, we are using CMake which generates absolute paths in the compilation database.

Remember, clang-tidy outputs filenames however they are stated in the compilation database. If not using a compilation database, then clang-tidy just outputs the filename as it was given in the CLI.

I also removed an artifact debug log from developing the solution for #386

Summary by CodeRabbit

  • Improvements
    • Enhanced error handling for repository root paths with improved error messages when invalid paths are provided.

Keeping the repo-root path relative breaks parsing of absolute paths in clang-tidy output.

This didn't surface in the tests because they all use a compilation database generated for ninja (which uses relative paths).
But in the test repo, we are using CMake which generates absolute paths in the compilation database.

Remember, clang-tidy outputs filenames however they are stated in the compilation database. If not using a compilation database, then clang-tidy just outputs the filename as it was given in the CLI.

---

I also removed an artifact debug log from developing solution in #386
@2bndy5 2bndy5 added the bug Something isn't working label Jun 23, 2026
@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 3db02df0-8cf5-4974-8e42-a816f2116b82

📥 Commits

Reviewing files that changed from the base of the PR and between 89f7b3d and caf7b2f.

📒 Files selected for processing (4)
  • cpp-linter/src/clang_tools/clang_tidy.rs
  • cpp-linter/src/common_fs.rs
  • cpp-linter/src/git.rs
  • cpp-linter/src/run.rs
💤 Files with no reviewable changes (1)
  • cpp-linter/src/clang_tools/clang_tidy.rs

📝 Walkthrough

Walkthrough

Introduces a mk_path_abs crate-level helper in common_fs.rs that canonicalizes a path and strips the Windows \\?\ extended-path prefix. Migrates git.rs and run.rs to use this helper, adds --repo-root canonicalization in run_main, removes a debug log from run_clang_tidy, and adds/updates related tests.

Changes

Path canonicalization refactor

Layer / File(s) Summary
mk_path_abs helper and unit test
cpp-linter/src/common_fs.rs
Adds pub(crate) fn mk_path_abs that calls canonicalize, strips a leading \\?\ from the result string, and returns a PathBuf. A new canonical_path test verifies the result is an existing file without the Windows extended-path prefix.
repo-root canonicalization in run_main
cpp-linter/src/run.rs
Imports mk_path_abs, changes cli to mut, and inserts a canonicalization block that rewrites cli.source_options.repo_root to an absolute path and derives .gitmodules from it; returns an error with context when canonicalization fails.
git.rs migration, test updates, and debug log removal
cpp-linter/src/git.rs, cpp-linter/src/run.rs, cpp-linter/src/clang_tools/clang_tidy.rs
Replaces manual fs::canonicalize + Windows-prefix trimming in clone_repo with mk_path_abs; removes the now-unused std::fs import. Drops a stale CLI argument from no_version_input and pre_commit_env tests. Adds bad_repo_root test asserting run_main errors on a non-existent --repo-root. Removes the parsed-notification-count debug log from run_clang_tidy.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • cpp-linter/cpp-linter-rs#347: Touches run.rs handling of --repo-root and the project cache directory, directly adjacent to the repo-root canonicalization added in this PR.
  • cpp-linter/cpp-linter-rs#386: Adds the parsed-notifications debug log in run_clang_tidy that this PR removes.
  • cpp-linter/cpp-linter-rs#358: Refactors run_clang_tidy and TidyAdvice caching in the same module where this PR removes the notification-count log.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: make repo-root path absolute' clearly and concisely summarizes the main change—converting the repo-root path to an absolute path to fix parsing issues.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Jun 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.59%. Comparing base (89f7b3d) to head (caf7b2f).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #387      +/-   ##
==========================================
+ Coverage   92.56%   92.59%   +0.03%     
==========================================
  Files          23       23              
  Lines        3710     3729      +19     
==========================================
+ Hits         3434     3453      +19     
  Misses        276      276              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@2bndy5 2bndy5 marked this pull request as ready for review June 23, 2026 22:12
@2bndy5 2bndy5 merged commit 5f4030f into main Jun 23, 2026
73 checks passed
@2bndy5 2bndy5 deleted the mk-repo-root-abs branch June 23, 2026 22:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant