diff --git a/apps/server/src/git.ts b/apps/server/src/git.ts index 718cf7e47ed392a5206c8e9554b03e4cf8950d7c..34b3b0a0fac7c6b389ffdf9134a75e9eeaf78408 100644 --- a/apps/server/src/git.ts +++ b/apps/server/src/git.ts @@ -1,4 +1,5 @@ import { spawn } from "node:child_process"; +import fs from "node:fs"; import os from "node:os"; import path from "node:path"; @@ -131,12 +132,14 @@ export async function listGitBranches(input: GitListBranchesInput): Promise(); if (worktreeList.code === 0) { let currentPath: string | null = null; for (const line of worktreeList.stdout.split("\n")) { if (line.startsWith("worktree ")) { currentPath = line.slice("worktree ".length); + if (!fs.existsSync(currentPath)) currentPath = null; } else if (line.startsWith("branch refs/heads/") && currentPath) { worktreeMap.set(line.slice("branch refs/heads/".length), currentPath); } else if (line === "") {