MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / parseDiffForDisplay

Function parseDiffForDisplay

src/utils/diff.ts:32–49  ·  view source on GitHub ↗
(unifiedDiff: string)

Source from the content-addressed store, hash-verified

30}
31
32export function parseDiffForDisplay(unifiedDiff: string): ColoredDiffLine[] {
33 const lines = unifiedDiff.split('\n');
34 const result: ColoredDiffLine[] = [];
35 for (const line of lines) {
36 if (line.startsWith('@@')) {
37 result.push({ type: 'hunk', text: line });
38 } else if (line.startsWith('+') && !line.startsWith('+++')) {
39 result.push({ type: 'add', text: line });
40 } else if (line.startsWith('-') && !line.startsWith('---')) {
41 result.push({ type: 'del', text: line });
42 } else if (line.startsWith('---') || line.startsWith('+++')) {
43 continue;
44 } else {
45 result.push({ type: 'context', text: line });
46 }
47 }
48 return result;
49}

Callers 2

diff-stats.test.tsFile · 0.85
DiffViewerFunction · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected