MCPcopy Create free account
hub / github.com/anthropics/claude-code / parseFileDiff

Function parseFileDiff

mods/diff/hooks/git/parse/parse-file-diff.ts:19–41  ·  view source on GitHub ↗
(stdout: string)

Source from the content-addressed store, hash-verified

17 * @returns the parsed body
18 */
19export function parseFileDiff(stdout: string): Types.FileHunks {
20 if (stdout.length > Limits.MAX_DIFF_BYTES) {
21 return LARGE_FILE_HUNKS
22 }
23
24 const rows = stdout.split('\n')
25
26 const headerRows = rows.flatMap((row, at) =>
27 HUNK_HEADER.test(row) ? [at] : [],
28 )
29
30 return {
31 ...cutHunks(
32 headerRows.map((at, ordinal) =>
33 hunkOf(
34 HUNK_HEADER.exec(rows[at] ?? '')?.groups,
35 rows.slice(at + 1, headerRows[ordinal + 1]).filter(isBodyLine),
36 ),
37 ),
38 ),
39 isLarge: false,
40 }
41}

Callers

nothing calls this directly

Calls 2

cutHunksFunction · 0.90
hunkOfFunction · 0.90

Tested by

no test coverage detected