MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / generateSyntheticDiff

Function generateSyntheticDiff

source code/utils/gitDiff.ts:506–534  ·  view source on GitHub ↗
(
  gitPath: string,
  absoluteFilePath: string,
)

Source from the content-addressed store, hash-verified

504}
505
506async function generateSyntheticDiff(
507 gitPath: string,
508 absoluteFilePath: string,
509): Promise<Omit<ToolUseDiff, 'repository'> | null> {
510 try {
511 if (!isFileWithinReadSizeLimit(absoluteFilePath, MAX_DIFF_SIZE_BYTES)) {
512 return null
513 }
514 const content = await readFile(absoluteFilePath, 'utf-8')
515 const lines = content.split('\n')
516 // Remove trailing empty line from split if file ends with newline
517 if (lines.length > 0 && lines.at(-1) === '') {
518 lines.pop()
519 }
520 const lineCount = lines.length
521 const addedLines = lines.map(line => `+${line}`).join('\n')
522 const patch = `@@ -0,0 +1,${lineCount} @@\n${addedLines}`
523 return {
524 filename: gitPath,
525 status: 'added',
526 additions: lineCount,
527 deletions: 0,
528 changes: lineCount,
529 patch,
530 }
531 } catch {
532 return null
533 }
534}

Callers 1

fetchSingleFileGitDiffFunction · 0.85

Calls 2

readFileFunction · 0.85

Tested by

no test coverage detected