Skip to content

feat: add --gen-patch-path to choose where the patch is written - #538

Merged
2bndy5 merged 5 commits into
mainfrom
claude/project-thread-a3krfd-patch-path
Oct 31, 2026
Merged

2bndy5 merged 5 commits into
mainfrom
claude/project-thread-a3krfd-patch-path

Conversation

@shenxianpeng

@shenxianpeng shenxianpeng commented Oct 31, 2026 •

Copy link
Copy Markdown
Member

As suggested in #535 (comment): a new --gen-patch-path <PATH> option (also read from the GEN_PATCH_PATH env var) sets where the combined fix patch is written, so users can run git apply "$GEN_PATCH_PATH" without copying the path from the logs.

  • Setting it implies --gen-patch.
  • A relative path is relative to the current working directory (same as --database in fix: resolve a relative --database against the working directory #537, and what git apply expects). Note that --summary-output-file and --sarif-file still resolve against --repo-root; happy to switch this one to match those if you prefer.
  • Without it, the patch stays at <repo-root>/.cpp-linter-cache/auto-fix.patch, and fix-patch-path reports whichever path was used.
  • A stale patch at the chosen path is removed at the start of a run, like the default one.

Implementation:

  • FeedbackInput::patch_path holds the resolved path; ClangParams::default_patch_path() builds the default.
  • FileObj::maybe_append_patch() and make_suggestions_from_patch() take the patch path instead of building it from repo_root (both are pub, so this changes their signatures).
  • Workspace clap enables the env feature (no new crates in Cargo.lock).
  • Tests: cli::structs::test::{default_patch_path, gen_patch_path_implies_gen_patch, gen_patch_path_from_env} and run::test::custom_patch_path (stale file replaced, nothing written to the default path).

Checked locally with clang 21: all cpp-linter lib tests (120), --test comments (17) and --test reviews (16) pass single-threaded (plain cargo test races on env vars, nextest doesn't); cargo clippy --all-features --all-targets clean; the generated CLI doc renders the option and its example block.

@coderabbitai

coderabbitai Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 41 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI (base), Organization UI (inherited)
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c61eac9e-7430-4724-9bd3-aca2c02149c7
Commits

Reviewing files that changed from the base of the PR and between aecd3fd and 3231e55.

Files selected for processing: 6
  • Cargo.toml
  • cpp-linter/src/cli/mod.rs
  • cpp-linter/src/cli/structs.rs
  • cpp-linter/src/common_fs.rs
  • cpp-linter/src/rest_client.rs
  • cpp-linter/src/run.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@codecov

codecov Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.82%. Comparing base (aecd3fd) to head (3231e55).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #538   +/-   ##
=======================================
  Coverage   99.82%   99.82%           
=======================================
  Files          29       29           
  Lines        7360     7432   +72     
=======================================
+ Hits         7347     7419   +72     
  Misses         13       13           

☔ 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 commented Oct 31, 2026

Copy link
Copy Markdown
Collaborator

Note that --summary-output-file and --sarif-file still resolve against --repo-root; happy to switch this one to match those if you prefer.

Yeah, let's do that as a followup.

Comment thread cpp-linter/src/cli/mod.rs Resolved
@2bndy5
2bndy5 merged commit 940d4b6 into main Oct 31, 2026
73 checks passed
@2bndy5
2bndy5 deleted the claude/project-thread-a3krfd-patch-path branch October 31, 2026 15:23
2bndy5 pushed a commit that referenced this pull request Oct 31, 2026
…nst the working directory (#541)

Follow-up to #538, as discussed there: `--gen-patch-path` resolves a
relative path against the current working directory, so the other output
paths now do the same instead of resolving against `--repo-root`.

## Changes

- `FeedbackInput::from(&Cli)` makes `summary_output_file` and
`sarif_file` absolute (against the cwd), sharing a small
`absolute_or_given()` helper with `patch_path`.
- `RestClient::post_feedback()` writes to those paths as given (no more
`repo_root.join()`).
- Help text for both options now says a relative path is relative to the
current working directory.
- Tests:
- new unit test `relative_output_files` (relative paths resolve against
the cwd even with `--repo-root sub`).
- the `relative_out_files` integration test now writes into a temp dir
made in the cwd and passes a path relative to the cwd.

This changes behavior for anyone passing a relative
`--summary-output-file`/`--sarif-file` together with a `--repo-root`
that isn't the cwd. I'll note it in the migration guide (#535).

<!-- claude-projects-attribution: {"github_login":"shenxianpeng"} -->

Co-authored-by: Xianpeng Shen <3353385+shenxianpeng@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants