MCPcopy Create free account
hub / github.com/cloudflare/computer / countChanges

Function countChanges

packages/computer/src/git/diff.ts:238–252  ·  view source on GitHub ↗

* Count added / removed content lines in a unified patch. Only * count lines inside hunks (after an `@@` header) so file headers * are ignored while real content that begins with `+++` / `---` * is still counted. Good enough for `--stat`'s numeric column, * which is all the CLI needs.

(patch: string)

Source from the content-addressed store, hash-verified

236 * which is all the CLI needs.
237 */
238function countChanges(patch: string): { insertions: number; deletions: number } {
239 let insertions = 0;
240 let deletions = 0;
241 let inHunk = false;
242 for (const line of patch.split("\n")) {
243 if (line.startsWith("@@")) {
244 inHunk = true;
245 continue;
246 }
247 if (!inHunk) continue;
248 if (line.startsWith("+")) insertions++;
249 else if (line.startsWith("-")) deletions++;
250 }
251 return { insertions, deletions };
252}
253
254async function listFilesAt(
255 git: IsomorphicGitDiffClient,

Callers 1

diffSummaryWithFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected