fix(hunkHeader): use per-side total count in the fallback @@ header - #696
fix(hunkHeader): use per-side total count in the fallback @@ header#696YuriNachos wants to merge 1 commit into
Conversation
The fallback branch of formatHunkHeader built the @@ -l,s +l,s @@ header from the changed-lines count (*Lines) instead of the per-side total count (*Count). For any hunk carrying context, *Lines undercounts and emits a malformed header. Use *Count (context + changed), matching the unified-diff spec. Co-authored-by: Claude <noreply@anthropic.com>
|
PR author is not in the allowed authors list. |
|
@YuriNachos is attempting to deploy a commit to the Modem Team on Vercel. A member of the Team first needs to authorize it. |
|
Heads-up on the red check, so it doesn't read as a problem with this branch: the failing
and the target URL is Every check a fork PR can actually influence is green here: Nothing on this branch can turn Vercel green — it needs the authorize link clicked on your side. Happy to rebase or re-trigger if that helps. |
Summary
formatHunkHeader's fallback branch emitted a malformed@@ -l,s +l,s @@header for any hunk carrying context lines, because it used the changed-lines count (*Lines) instead of the per-side total count (*Count).Root cause
The fallback built the header from
hunk.deletionLines/hunk.additionLines, which count only the changed+/-lines. The unified-diff@@count is the per-side total (context + changed), so any hunk with context was undercounted and malformed.Fix
Use
hunk.deletionCount/hunk.additionCount(the per-side totals). Hunks with no context are unchanged.Tests
New
hunkHeader.test.tscovers the context-carrying case (was malformed, now correct) and the no-context case (unchanged).