Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/main/services/GitHubService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -915,9 +915,21 @@ export class GitHubService {

try {
await this.execGH(
`gh pr checkout ${JSON.stringify(String(prNumber))} --branch ${JSON.stringify(safeBranch)} --force --detach`,
`gh pr checkout ${JSON.stringify(String(prNumber))} --branch ${JSON.stringify(safeBranch)} --force`,
{ cwd: projectPath }
);
// Some gh/fork combinations can leave HEAD detached without a local branch ref.
// Ensure the requested local branch exists for downstream worktree creation.
try {
await execAsync(
`git show-ref --verify --quiet ${JSON.stringify(`refs/heads/${safeBranch}`)}`,
{ cwd: projectPath }
);
} catch {
await execAsync(`git branch --force ${JSON.stringify(safeBranch)} HEAD`, {
cwd: projectPath,
});
}
} catch (error) {
console.error('Failed to checkout pull request branch via gh:', error);
throw error;
Expand Down
Loading