fix(vcs): preserve batched patch boundaries (#25787)

This commit is contained in:
Luke Parker
2026-05-05 10:34:06 +10:00
committed by GitHub
parent 4b65b1e053
commit 6a5e329427
4 changed files with 65 additions and 17 deletions

View File

@@ -85,7 +85,9 @@ const fileFromPatchChunk = (chunk: string) => {
}
const splitGitPatch = (patch: Git.Patch) => {
const starts = [...patch.text.matchAll(/^diff --git /gm)].map((match) => match.index)
const starts = [...patch.text.matchAll(/(?:^|\n)diff --git /g)].map((match) =>
match[0].startsWith("\n") ? match.index + 1 : match.index,
)
const chunks = starts.map((start, index) => patch.text.slice(start, starts[index + 1] ?? patch.text.length))
if (!patch.truncated) return chunks
return chunks.slice(0, -1)