(worktreePath: string)
| 79 | * Returns a unified diff patch string. |
| 80 | */ |
| 81 | export function captureWorktreeDiff(worktreePath: string): string { |
| 82 | try { |
| 83 | // Add all new files so they show up in the diff |
| 84 | execSync(`git -C "${worktreePath}" add -A`, { |
| 85 | stdio: ["pipe", "pipe", "pipe"], |
| 86 | }); |
| 87 | return execSync(`git -C "${worktreePath}" diff --cached`, { |
| 88 | encoding: "utf-8", |
| 89 | maxBuffer: 10 * 1024 * 1024, |
| 90 | stdio: ["pipe", "pipe", "pipe"], |
| 91 | }); |
| 92 | } catch { |
| 93 | return ""; |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | /** |
| 98 | * Remove a git worktree. |