(worktreePath: string)
| 220 | * @returns Path to the main repository, or null if not found |
| 221 | */ |
| 222 | export async function getMainWorktreeFromWorktree(worktreePath: string): Promise<string | null> { |
| 223 | try { |
| 224 | // Get the worktree list from the worktree itself |
| 225 | using proc = execFileAsync("git", ["-C", worktreePath, "worktree", "list", "--porcelain"]); |
| 226 | const { stdout } = await proc.result; |
| 227 | const lines = stdout.split("\n"); |
| 228 | |
| 229 | // The first worktree in the list is always the main worktree |
| 230 | for (const line of lines) { |
| 231 | if (line.startsWith("worktree ")) { |
| 232 | return line.slice("worktree ".length); |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | return null; |
| 237 | } catch { |
| 238 | return null; |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | export async function removeWorktree( |
| 243 | projectPath: string, |
nothing calls this directly
no test coverage detected