MCPcopy Create free account
hub / github.com/promptfoo/promptfoo / parseNumstat

Function parseNumstat

src/codeScan/git/diffProcessor.ts:121–142  ·  view source on GitHub ↗

* Parse git diff --numstat output * Format: added\tremoved\tpath

(numstatOutput: string)

Source from the content-addressed store, hash-verified

119 * Format: added\tremoved\tpath
120 */
121function parseNumstat(numstatOutput: string): Map<string, NumstatEntry> {
122 const map = new Map<string, NumstatEntry>();
123
124 for (const line of numstatOutput.split('\n')) {
125 if (!line.trim()) {
126 continue;
127 }
128
129 const parts = line.split('\t');
130 if (parts.length < 3) {
131 continue;
132 }
133
134 const added = parts[0] === '-' ? 0 : Number.parseInt(parts[0], 10);
135 const removed = parts[1] === '-' ? 0 : Number.parseInt(parts[1], 10);
136 const path = parts[2];
137
138 map.set(path, { linesAdded: added, linesRemoved: removed });
139 }
140
141 return map;
142}
143
144async function discoverChangedFiles(
145 repoPath: string,

Callers 1

discoverChangedFilesFunction · 0.85

Calls 2

splitMethod · 0.80
setMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…