Skip to content

fix: add context lines to generated patch#390

Open
2bndy5 wants to merge 1 commit into
mainfrom
fix-patch-gen
Open

fix: add context lines to generated patch#390
2bndy5 wants to merge 1 commit into
mainfrom
fix-patch-gen

Conversation

@2bndy5

@2bndy5 2bndy5 commented Jun 27, 2026

Copy link
Copy Markdown
Collaborator

Apparently, git apply uses context lines in the patch to find a match for changed lines. Previously, we weren't adding context lines to keep the patch size minimal.

As a bonus, git apply does not require being used in a git repository. This means I can git apply any generated patch in the integration tests about thread comments.

Summary by CodeRabbit

  • Bug Fixes
    • Improved the generated patch output so it may include more surrounding context when applied.
    • The test workflow now verifies that generated patches can be applied successfully, helping catch issues earlier.

Apparently, `git apply` uses context lines in the patch to find a match for changed lines.
Previously, we weren't adding context lines to keep the patch size minimal.

As a bonus, `git apply` does not require being used in a git repository.
This means I can `git apply` any generated patch in the integration tests about thread comments.
@2bndy5 2bndy5 added the bug Something isn't working label Jun 27, 2026
@codecov

codecov Bot commented Jun 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.38%. Comparing base (339337a) to head (feb3123).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #390      +/-   ##
==========================================
- Coverage   92.38%   92.38%   -0.01%     
==========================================
  Files          23       23              
  Lines        3796     3795       -1     
==========================================
- Hits         3507     3506       -1     
  Misses        289      289              

☔ 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 28, 2026 02:44
@coderabbitai

coderabbitai Bot commented Jun 28, 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: a7e26f6e-cfc5-42b1-b5ba-f98912d7adc7

📥 Commits

Reviewing files that changed from the base of the PR and between 339337a and feb3123.

📒 Files selected for processing (2)
  • cpp-linter/src/common_fs.rs
  • cpp-linter/tests/comments.rs

📝 Walkthrough

Walkthrough

append_patch in common_fs.rs now uses UnifiedDiffConfig::default() instead of context_len(0), changing the context included in generated unified diffs. The comments.rs test is extended to run git apply on the generated patch file and assert it succeeds.

Changes

Patch context and test validation

Layer / File(s) Summary
Unified diff context change and git apply test
cpp-linter/src/common_fs.rs, cpp-linter/tests/comments.rs
append_patch drops context_len(0) and uses UnifiedDiffConfig::default(); the test now runs git apply on the produced patch file and asserts the command succeeds.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: generated patches now include context lines so they can be applied with git apply.
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.

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.

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