()
| 684 | * The main worktree is not listed there, so add 1. |
| 685 | */ |
| 686 | export async function getWorktreeCountFromFs(): Promise<number> { |
| 687 | try { |
| 688 | const gitDir = await resolveGitDir() |
| 689 | if (!gitDir) { |
| 690 | return 0 |
| 691 | } |
| 692 | const commonDir = (await getCommonDir(gitDir)) ?? gitDir |
| 693 | const entries = await readdir(join(commonDir, 'worktrees')) |
| 694 | return entries.length + 1 |
| 695 | } catch { |
| 696 | // No worktrees directory means only the main worktree |
| 697 | return 1 |
| 698 | } |
| 699 | } |
no test coverage detected