fix(server): new worktree threads work in repos with no commits yet #15580
Closedt3dotgg(GitHub profile, opens in a new tab)wants to merge 5 commits into
main fromt3code/fix-worktree-creation-failureopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
juliusmarminge added labelsmacroscope-review
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
- apps/server/src/orchestration-v2/ThreadLaunchService.ts line 236OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -224,3 +224,13 @@224224 }225225 });226226227+ // `git worktree add` needs a commit to start from. True when neither HEAD228+ // nor the base ref has one and no origin fetch could bring the base ref.229+ const hasNothingToCheckOut = Effect.fn("ThreadLaunchService.hasNothingToCheckOut")(function* (230+ cwd: string,231+ strategy: Extract<ThreadLaunchWorkspaceStrategy, { readonly type: "worktree" }>,232+ ) {233+ if (yield* git.hasCommit({ cwd, refName: "HEAD" })) return false;234+ if (yield* git.hasCommit({ cwd, refName: strategy.baseRef })) return false;235+ return !(236+ strategy.startFromOrigin === true && (yield* git.remoteExists({ cwd, remoteName: "origin" }))
- apps/server/src/orchestration-v2/ThreadLaunchService.ts lines 235 to 236OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -224,3 +224,13 @@224224 }225225 });226226227+ // `git worktree add` needs a commit to start from. True when neither HEAD228+ // nor the base ref has one and no origin fetch could bring the base ref.229+ const hasNothingToCheckOut = Effect.fn("ThreadLaunchService.hasNothingToCheckOut")(function* (230+ cwd: string,231+ strategy: Extract<ThreadLaunchWorkspaceStrategy, { readonly type: "worktree" }>,232+ ) {233+ if (yield* git.hasCommit({ cwd, refName: "HEAD" })) return false;234+ if (yield* git.hasCommit({ cwd, refName: strategy.baseRef })) return false;235+ return !(236+ strategy.startFromOrigin === true && (yield* git.remoteExists({ cwd, remoteName: "origin" }))
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
Yash-Singh1(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed