(cwd: string)
| 18 | const MAX_DIFF_BYTES = 50 * 1024 * 1024; |
| 19 | |
| 20 | async 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 | |
| 54 | export function diffRoutes(db: StageDb): Route[] { |
| 55 | return [ |
no test coverage detected