MCPcopy Index your code
hub / github.com/Waishnav/devspace / parseNumstat

Function parseNumstat

src/review-checkpoints.ts:148–178  ·  view source on GitHub ↗
(output: string)

Source from the content-addressed store, hash-verified

146}
147
148function parseNumstat(output: string): ReviewFile[] {
149 const fields = output.split("\0").filter((field) => field.length > 0);
150 const files: ReviewFile[] = [];
151
152 for (let index = 0; index < fields.length;) {
153 const header = fields[index++] ?? "";
154 const parts = header.split("\t");
155 const additions = parseStatNumber(parts[0]);
156 const removals = parseStatNumber(parts[1]);
157
158 if (parts.length >= 3) {
159 const path = parts[2] ?? "";
160 if (path) files.push({ path, type: fileType(path, undefined, additions, removals), additions, removals });
161 continue;
162 }
163
164 const previousPath = fields[index++];
165 const path = fields[index++];
166 if (!path) continue;
167
168 files.push({
169 path,
170 previousPath,
171 type: fileType(path, previousPath, additions, removals),
172 additions,
173 removals,
174 });
175 }
176
177 return files;
178}
179
180function parseStatNumber(value: string | undefined): number {
181 if (!value || value === "-") return 0;

Callers 1

reviewChangesFunction · 0.85

Calls 2

parseStatNumberFunction · 0.85
fileTypeFunction · 0.85

Tested by

no test coverage detected