Repository navigation
Commit d4247a4
authored
fix: resolve a relative
<!-- claude-projects-attribution: {"github_login":"shenxianpeng"} -->
As suggested in
#535 (comment):
a relative `--database` path is now resolved against the current working
directory, like cpp-linter v1 (1.15+), instead of against `--repo-root`.
Results only differ when `--repo-root` is not `.`.
- `ClangParams::from(&Cli)` uses `std::path::absolute()` (no filesystem
access, so a missing path still reaches the existing "Failed to read
compilation database" handling).
- New test `cli::structs::test::relative_db_path` (`--repo-root sub
--database build` gives `<cwd>/build`).
- `tests/comments.rs` and `tests/reviews.rs` passed `-p=build` together
with `--repo-root=<tmp dir>`. With this change that path pointed at
`cpp-linter/build`, so the tests still passed but without the meson
database (each run logged "Failed to read compilation database file").
They now pass the absolute `<tmp dir>/build`.
Checked locally (clang 21): `cargo test --all-features --lib db_path`,
`--test comments` (17 passed, single-threaded) and `--test reviews` (16
passed), no "Failed to read compilation database" warning; `cargo clippy
--all-features --all-targets` clean, `cargo fmt`.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## Summary by CodeRabbit
* **Bug Fixes**
* Relative compilation database paths are now resolved from the current
working directory, rather than the repository root. This makes path
handling consistent when the configured repository root differs from the
directory where the command is run.
* If the path cannot be resolved, the supplied path is preserved.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: Xianpeng Shen <3353385+shenxianpeng@users.noreply.github.com>--database against the working directory (#537)1 parent 6c6c2ee commit d4247a4
3 files changed
Lines changed: 18 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
272 | 272 | | |
273 | 273 | | |
274 | 274 | | |
275 | | - | |
| 275 | + | |
| 276 | + | |
276 | 277 | | |
277 | 278 | | |
278 | 279 | | |
279 | 280 | | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
| 281 | + | |
288 | 282 | | |
289 | 283 | | |
290 | 284 | | |
| |||
296 | 290 | | |
297 | 291 | | |
298 | 292 | | |
299 | | - | |
| 293 | + | |
300 | 294 | | |
301 | 295 | | |
302 | 296 | | |
| |||
510 | 504 | | |
511 | 505 | | |
512 | 506 | | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
513 | 517 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
274 | 274 | | |
275 | 275 | | |
276 | 276 | | |
277 | | - | |
| 277 | + | |
| 278 | + | |
278 | 279 | | |
279 | 280 | | |
280 | 281 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
272 | 272 | | |
273 | 273 | | |
274 | 274 | | |
275 | | - | |
| 275 | + | |
| 276 | + | |
276 | 277 | | |
277 | 278 | | |
278 | 279 | | |
| |||
0 commit comments