MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / applyDiff

Function applyDiff

sdk/src/tools/apply-patch.ts:448–461  ·  view source on GitHub ↗
(
  input: string,
  diff: string,
  mode: DiffMode = 'default',
)

Source from the content-addressed store, hash-verified

446}
447
448function applyDiff(
449 input: string,
450 diff: string,
451 mode: DiffMode = 'default',
452): { result: string; fuzz: number } {
453 const diffLines = normalizeDiffLines(diff)
454
455 if (mode === 'create') {
456 return { result: parseCreateDiff(diffLines), fuzz: 0 }
457 }
458
459 const { chunks, fuzz } = parseUpdateDiff(diffLines, input)
460 return { result: applyChunks(input, chunks), fuzz }
461}
462
463function isConsistentlyCrlf(input: string): boolean {
464 const hasCrlf = /\r\n/.test(input)

Callers 2

applyPatchToolFunction · 0.85

Calls 4

normalizeDiffLinesFunction · 0.85
parseCreateDiffFunction · 0.85
parseUpdateDiffFunction · 0.85
applyChunksFunction · 0.85

Tested by

no test coverage detected