Files
zesdex/apps/interfaces/tui/src/git.ts
T

27 lines
838 B
TypeScript

/**
* Git diff preview helper — shells out to `git diff` over the workspace
* roots and returns the combined output text. Mirrors
* `apps/interfaces/tui/src/action/git.rs`.
*/
import { execSync } from "node:child_process";
/** Run `git diff` across the given workspace roots and return the output. */
export function gitDiffOutput(workspaceRoots: string[]): string {
for (const root of workspaceRoots) {
try {
const out = execSync("git diff --stat && git diff", {
cwd: root,
encoding: "utf8",
maxBuffer: 4 * 1024 * 1024,
stdio: ["ignore", "pipe", "ignore"],
});
if (out.trim().length > 0) {
return out;
}
} catch {
// Not a git repo or git not available — continue to the next root.
}
}
return "No diff available (not a git repository).";
}