Repository navigation
fix: reject stray lines between file sections instead of silently dropping them - #46
Conversation
…pping them Between file sections the parser skipped every line that did not start with '*** ', so a file header indented by a space was dropped together with its hunk lines and the patch still reported success. File headers are now recognized after trimming, as in Codex, and any other non-blank line between sections rejects the patch with "is not a valid hunk header". Fixes #45
|
Lead in-session review at 0598319: PASS. File headers are recognized after trimming (Codex behavior), and a non-header, non-blank line between file sections now reaches the header parser and is rejected before anything is applied, instead of being skipped together with the section it introduced (the silent dropped edit). Add-file body lines start with '+', so the trimmed |
The parser now accepts indented file headers, so the exported path extractor must report them too; a consumer that gates writes per file (a permission prompt, the pending-path display) would otherwise not see a file the patch is about to change. Refs #45
|
Lead re-review of b3efd4c (extractPatchedPaths): right direction, one P1 left. The parser recognizes headers with Fix: make the extractor use exactly the parser's notion of whitespace, e.g. derive both from one helper (split lines, |
…tchedPaths The parser trimmed headers with String.prototype.trim, but the extractor's regex only allowed spaces and tabs, so a header indented with a no-break space was written but not listed, and a trailing one made the listed path differ from the written one. Both now read headers through parseFileHeader and parseMoveTo (Move to is trimmed at the end, as in Codex), so the listed paths are exactly the paths the patch writes. Refs #45
|
Lead re-review of 36388ed: PASS. Parser and extractPatchedPaths now share |
Fixes #45.
Summary
***. An indented file header was therefore dropped along with its hunk lines, and the patch reported success. As the first section, the same header failed with a misleading "no hunks found".streaming_parser.rsprocess_line). Any other non-blank line between sections rejects the whole patch with'<line>' is not a valid hunk header, before anything is applied. Indented markers inside an update hunk stay context lines, as in Codex.Verification
bun run check(typecheck + biome)bun run test: 67/67test/patch-headers.test.ts: 6 user-facing cases. The 5 that exercise the fix fail onmainand pass here. The sixth (an indented marker inside a hunk stays context) passes on both and guards against over-trimming.codex-rs/apply-patch/tests/fixtures/scenarios, 26 cases) replayed against this branch:017_whitespace_padded_hunk_headernow passes. The remaining two failures (023/024, line endings) are a separate fix.apply_patch impact
[Unreleased]