MCPcopy Create free account
hub / github.com/ds300/patch-package / verifyHunkIntegrity

Function verifyHunkIntegrity

src/patch/parse.ts:436–463  ·  view source on GitHub ↗
(hunk: Hunk)

Source from the content-addressed store, hash-verified

434}
435
436export function verifyHunkIntegrity(hunk: Hunk) {
437 // verify hunk integrity
438 let originalLength = 0
439 let patchedLength = 0
440 for (const { type, lines } of hunk.parts) {
441 switch (type) {
442 case "context":
443 patchedLength += lines.length
444 originalLength += lines.length
445 break
446 case "deletion":
447 originalLength += lines.length
448 break
449 case "insertion":
450 patchedLength += lines.length
451 break
452 default:
453 assertNever(type)
454 }
455 }
456
457 if (
458 originalLength !== hunk.header.original.length ||
459 patchedLength !== hunk.header.patched.length
460 ) {
461 throw new Error("hunk header integrity check failed")
462 }
463}

Callers 2

reverseHunkFunction · 0.90
parsePatchLinesFunction · 0.85

Calls 1

assertNeverFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…