( git: ReturnType<typeof simpleGit>, currentWorktreePath: string, )
| 316 | } |
| 317 | |
| 318 | async function getCheckedOutBranches( |
| 319 | git: ReturnType<typeof simpleGit>, |
| 320 | currentWorktreePath: string, |
| 321 | ): Promise<Record<string, string>> { |
| 322 | const checkedOutBranches: Record<string, string> = {}; |
| 323 | |
| 324 | try { |
| 325 | const worktreeList = await git.raw(["worktree", "list", "--porcelain"]); |
| 326 | const lines = worktreeList.split("\n"); |
| 327 | let currentPath: string | null = null; |
| 328 | |
| 329 | for (const line of lines) { |
| 330 | if (line.startsWith("worktree ")) { |
| 331 | currentPath = line.substring(9).trim(); |
| 332 | } else if (line.startsWith("branch ")) { |
| 333 | const branch = line.substring(7).trim().replace("refs/heads/", ""); |
| 334 | if (currentPath && currentPath !== currentWorktreePath) { |
| 335 | checkedOutBranches[branch] = currentPath; |
| 336 | } |
| 337 | } |
| 338 | } |
| 339 | } catch {} |
| 340 | |
| 341 | return checkedOutBranches; |
| 342 | } |
no outgoing calls
no test coverage detected