Skip to content

feat: add fix-patch-path output variable#378

Merged
2bndy5 merged 1 commit into
mainfrom
output-patch
Jun 21, 2026
Merged

feat: add fix-patch-path output variable#378
2bndy5 merged 1 commit into
mainfrom
output-patch

Conversation

@2bndy5

@2bndy5 2bndy5 commented Jun 20, 2026

Copy link
Copy Markdown
Collaborator

resolves #376

This is the result of

If there are any auto-fixes available, then a patch full of them is created and its path is set to a new output fix-patch-path output variable.

If there were no auto-fixes, then the output variable is not set. Remember, an unset output variable is treated as an empty string (a false value) in steps.linter.outputs.fix-patch-path context.

Summary by CodeRabbit

Release Notes

  • New Features

    • Auto-fix patches are aggregated into a single unified patch file in the repository cache directory.
    • CI/CD now receives an optional fix-patch-path output (with normalized forward slashes) pointing to the generated patch when present.
    • Cached patch aggregation is recorded consistently when producing suggestions.
  • Bug Fixes

    • Clear any previously generated unified patch before starting a new run to prevent stale outputs.
  • Tests

    • Updated test inputs to ignore build/** and added validation for the generated patch file contents.

@2bndy5 2bndy5 added the enhancement New feature or request label Jun 20, 2026
@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@2bndy5, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 49 minutes and 51 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Pro

Run ID: da445678-52e5-481a-b802-ee63fbf1ed19

📥 Commits

Reviewing files that changed from the base of the PR and between 006b65f and 5c0b165.

📒 Files selected for processing (7)
  • cpp-linter/src/cli/structs.rs
  • cpp-linter/src/common_fs.rs
  • cpp-linter/src/error.rs
  • cpp-linter/src/rest_client.rs
  • cpp-linter/src/run.rs
  • cpp-linter/tests/comments.rs
  • cpp-linter/tests/reviews.rs
📝 Walkthrough

Walkthrough

Adds a ClangParams::AUTO_FIX_PATCH constant and three new FileObjError IO variants. Implements FileObj::maybe_append_patch and append_patch methods that compute and append a unified diff into .cpp-linter-cache/auto-fix.patch. Integrates these methods into post_feedback to call them for non-PR-review events and emit a fix-patch-path output variable. Cleans up old patch files before each run and updates test infrastructure to verify patch generation with glob pattern updates from build to build/**.

Changes

Auto-fix patch file generation and output

Layer / File(s) Summary
AUTO_FIX_PATCH constant and FileObjError variants
cpp-linter/src/cli/structs.rs, cpp-linter/src/error.rs
Defines the "auto-fix.patch" filename constant on ClangParams and adds MkDirFailed, OpenPatchFileFailed, and WritePatchFailed variants to FileObjError, each wrapping std::io::Error.
FileObj patch-writing methods
cpp-linter/src/common_fs.rs
Adds std::io::Write and ClangParams imports. Implements maybe_append_patch(repo_root) (reads cached patched file and original, diffs them, normalizes path separators) and private append_patch (creates cache dir via CACHE_DIR, appends unified diff with zero context to AUTO_FIX_PATCH). Updates make_suggestions_from_patch to use to_string_lossy() and invoke append_patch before generating suggestions.
post_feedback integration and fix-patch-path output
cpp-linter/src/rest_client.rs
Imports ClangParams. Extends post_feedback with a non-PR-review branch that calls file.maybe_append_patch(...) per file, then writes a fix-patch-path output variable pointing to the slash-normalized patch path when the file exists.
Initialization cleanup and test setup
cpp-linter/src/run.rs
Deletes the auto-fix patch file from cache before run_main proceeds, ensuring fresh state. Updates test module to import ClangParams and modifies force_debug_output test to create the cache directory and write a dummy patch file for cleanup verification.
Test harness updates
cpp-linter/tests/comments.rs, cpp-linter/tests/reviews.rs
Updates the ignore glob from -i=build to -i=build/** in both test setups. Adds fs import and post-run logic in comments.rs to locate the fix-patch-path= output line, assert the patch file exists, read its content, and print it.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • cpp-linter/cpp-linter-rs#354: Both PRs modify the same patch/suggestion flow in cpp-linter/src/common_fs.rsmake_suggestions_from_patch now records cached patches—so the main PR's auto-fix patch caching builds directly on fetched clang-tidy fixes behavior.
  • cpp-linter/cpp-linter-rs#358: The main PR extends common_fs.rs's make_suggestions_from_patch and FileObj patch handling to append unified auto-fix patches to cache and expose fix-patch-path, building on the retrieved PR's refactor of FileObj/patch-driven suggestion generation for clang-tidy and clang-format merging.
  • cpp-linter/cpp-linter-rs#377: Modifies RestClient::post_feedback control flow around the PR-review path, the same function this PR extends to call maybe_append_patch and emit the fix-patch-path output variable.
🚥 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 directly and clearly describes the main feature: adding a fix-patch-path output variable to expose auto-fix patches.
Linked Issues check ✅ Passed The PR implements all coding objectives from issue #376: saves patch to .cpp-linter-cache/auto-fix.patch, sets fix-patch-path output variable, and integrates with prior auto-fix generation work.
Out of Scope Changes check ✅ Passed All changes directly support the primary objective of exposing auto-fix patches via the fix-patch-path output variable; no unrelated code modifications detected.
Docstring Coverage ✅ Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%.

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


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 and usage tips.

@2bndy5

2bndy5 commented Jun 20, 2026

Copy link
Copy Markdown
Collaborator Author

@shenxianpeng This is the preferred solution to compliment cpp-linter/cpp-linter-action#439

@codecov

codecov Bot commented Jun 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.54%. Comparing base (fc75245) to head (5c0b165).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #378      +/-   ##
==========================================
+ Coverage   92.41%   92.54%   +0.12%     
==========================================
  Files          23       23              
  Lines        3637     3700      +63     
==========================================
+ Hits         3361     3424      +63     
  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 21, 2026 00:15
coderabbitai[bot]

This comment was marked as resolved.

resolves #376

If there are any auto-fixes available, then a patch full of them is created and its path is set to a new output `fix-patch-path` output variable.

If there were no auto-fixes, then the output variable is not set, which is treated as an empty in `steps.linter.outputs.fix-patch-path` context).
@2bndy5 2bndy5 merged commit aa1c380 into main Jun 21, 2026
87 of 88 checks passed
@2bndy5 2bndy5 deleted the output-patch branch June 21, 2026 03:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

provide auto-fix patch file (add fix-patch-path output)

1 participant