MCPcopy Index your code
hub / github.com/codeaashu/claude-code / getEditsForPatch

Function getEditsForPatch

src/tools/FileEditTool/utils.ts:495–524  ·  view source on GitHub ↗
(patch: StructuredPatchHunk[])

Source from the content-addressed store, hash-verified

493}
494
495export function getEditsForPatch(patch: StructuredPatchHunk[]): FileEdit[] {
496 return patch.map(hunk => {
497 // Extract the changes from this hunk
498 const contextLines: string[] = []
499 const oldLines: string[] = []
500 const newLines: string[] = []
501
502 // Parse each line and categorize it
503 for (const line of hunk.lines) {
504 if (line.startsWith(' ')) {
505 // Context line - appears in both versions
506 contextLines.push(line.slice(1))
507 oldLines.push(line.slice(1))
508 newLines.push(line.slice(1))
509 } else if (line.startsWith('-')) {
510 // Deleted line - only in old version
511 oldLines.push(line.slice(1))
512 } else if (line.startsWith('+')) {
513 // Added line - only in new version
514 newLines.push(line.slice(1))
515 }
516 }
517
518 return {
519 old_string: oldLines.join('\n'),
520 new_string: newLines.join('\n'),
521 replace_all: false,
522 }
523 })
524}
525
526/**
527 * Contains replacements to de-sanitize strings from Claude

Callers 1

computeEditsFromContentsFunction · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected