MCPcopy Create free account
hub / github.com/ReviewStage/stage-cli / buildUntrackedPatch

Function buildUntrackedPatch

packages/cli/src/routes/diff.ts:20–52  ·  view source on GitHub ↗
(cwd: string)

Source from the content-addressed store, hash-verified

18const MAX_DIFF_BYTES = 50 * 1024 * 1024;
19
20async function buildUntrackedPatch(cwd: string): Promise<string> {
21 const { stdout } = await execFileAsync("git", ["ls-files", "--others", "--exclude-standard"], {
22 cwd,
23 encoding: "utf8",
24 });
25 const files = stdout.trim() ? stdout.trim().split("\n") : [];
26 if (files.length === 0) return "";
27
28 const patches = await Promise.all(
29 files.map(async (file) => {
30 try {
31 await execFileAsync(
32 "git",
33 [
34 "diff",
35 "--no-index",
36 "--no-color",
37 "--src-prefix=a/",
38 "--dst-prefix=b/",
39 "--",
40 "/dev/null",
41 file,
42 ],
43 { cwd, encoding: "utf8", maxBuffer: MAX_DIFF_BYTES },
44 );
45 return "";
46 } catch (err: unknown) {
47 return hasStringStdout(err) ? err.stdout : "";
48 }
49 }),
50 );
51 return patches.filter(Boolean).join("\n");
52}
53
54export function diffRoutes(db: StageDb): Route[] {
55 return [

Callers 1

diffRoutesFunction · 0.85

Calls 1

hasStringStdoutFunction · 0.85

Tested by

no test coverage detected