MCPcopy Create free account
hub / github.com/block/buzz / getDiffStats

Function getDiffStats

desktop/src/features/agents/ui/agentSessionFileEditDiff.ts:177–198  ·  view source on GitHub ↗
(
  text: string,
  lines: FileEditDiffLine[],
)

Source from the content-addressed store, hash-verified

175}
176
177function getDiffStats(
178 text: string,
179 lines: FileEditDiffLine[],
180): Pick<FileEditDiffSummary, "additions" | "deletions"> | null {
181 const additions = lines.filter((line) => line.kind === "add").length;
182 const deletions = lines.filter((line) => line.kind === "remove").length;
183
184 if (additions > 0 || deletions > 0) {
185 return { additions, deletions };
186 }
187
188 const statAdditions = text.match(/(\d+)\s+insertions?\(\+\)/);
189 const statDeletions = text.match(/(\d+)\s+deletions?\(-\)/);
190 if (statAdditions || statDeletions) {
191 return {
192 additions: statAdditions ? Number(statAdditions[1]) : 0,
193 deletions: statDeletions ? Number(statDeletions[1]) : 0,
194 };
195 }
196
197 return null;
198}
199
200function basename(path: string) {
201 const parts = path.replace(/\\/g, "/").split("/");

Callers 1

buildFileEditDiffFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected