@@ -847,6 +847,9 @@ export function registerCommands(
847847 return vscode . window . showErrorMessage ( vscode . l10n . t ( 'Unable to checkout pull request: missing head branch information.' ) ) ;
848848 }
849849
850+ // Store validated head to avoid non-null assertions later
851+ const prHead = pullRequestModel . head ;
852+
850853 // Get the folder manager to access the repository
851854 const folderManager = reposManager . getManagerForIssueModel ( pullRequestModel ) ;
852855 if ( ! folderManager ) {
@@ -867,15 +870,16 @@ export function registerCommands(
867870 } ,
868871 async ( progress ) => {
869872 // Generate a branch name for the worktree
870- const branchName = pullRequestModel . head ! . ref ;
873+ const branchName = prHead . ref ;
871874 const remoteName = pullRequestModel . remote . remoteName ;
872875
873876 // Fetch the PR branch first
874877 progress . report ( { message : vscode . l10n . t ( 'Fetching branch {0}...' , branchName ) } ) ;
875878 try {
876879 await repositoryToUse . fetch ( { remote : remoteName , ref : branchName } ) ;
877880 } catch ( e ) {
878- Logger . appendLine ( `Failed to fetch branch ${ branchName } : ${ e } ` , logId ) ;
881+ const errorMessage = e instanceof Error ? e . message : String ( e ) ;
882+ Logger . appendLine ( `Failed to fetch branch ${ branchName } : ${ errorMessage } ` , logId ) ;
879883 // Continue even if fetch fails - the branch might already be available locally
880884 }
881885
@@ -900,7 +904,7 @@ export function registerCommands(
900904 progress . report ( { message : vscode . l10n . t ( 'Creating worktree at {0}...' , worktreePath ) } ) ;
901905
902906 const trackedBranchName = `${ remoteName } /${ branchName } ` ;
903- const localBranchName = `pr-${ pullRequestModel . number } / ${ branchName } ` ;
907+ const localBranchName = `pr-${ pullRequestModel . number } - ${ branchName } ` ;
904908
905909 try {
906910 // Create a VS Code task to execute the git worktree command
0 commit comments