| 300 | }) |
| 301 | |
| 302 | function parseWorktreeList(text: string) { |
| 303 | return text |
| 304 | .split("\n") |
| 305 | .map((line) => line.trim()) |
| 306 | .reduce<{ path?: string; branch?: string }[]>((acc, line) => { |
| 307 | if (!line) return acc |
| 308 | if (line.startsWith("worktree ")) { |
| 309 | acc.push({ path: line.slice("worktree ".length).trim() }) |
| 310 | return acc |
| 311 | } |
| 312 | const current = acc[acc.length - 1] |
| 313 | if (!current) return acc |
| 314 | if (line.startsWith("branch ")) { |
| 315 | current.branch = line.slice("branch ".length).trim() |
| 316 | } |
| 317 | return acc |
| 318 | }, []) |
| 319 | } |
| 320 | |
| 321 | const locateWorktree = Effect.fnUntraced(function* ( |
| 322 | entries: { path?: string; branch?: string }[], |