@@ -3397,8 +3397,36 @@ export class CommandCenter {
3397
3397
}
3398
3398
}
3399
3399
3400
- @command ( 'git.createWorktree' , { repository : true , repositoryFilter : [ 'repository' , 'submodule' ] } )
3401
- async createWorktree ( repository : Repository ) : Promise < void > {
3400
+ @command ( 'git.createWorktree' )
3401
+ async createWorktree ( repository : any ) : Promise < void > {
3402
+ repository = this . model . getRepository ( repository ) ;
3403
+
3404
+ if ( ! repository ) {
3405
+ // Single repository/submodule/worktree
3406
+ if ( this . model . repositories . length === 1 ) {
3407
+ repository = this . model . repositories [ 0 ] ;
3408
+ }
3409
+ }
3410
+
3411
+ if ( ! repository ) {
3412
+ // Single repository/submodule
3413
+ const repositories = this . model . repositories
3414
+ . filter ( r => r . kind === 'repository' || r . kind === 'submodule' ) ;
3415
+
3416
+ if ( repositories . length === 1 ) {
3417
+ repository = repositories [ 0 ] ;
3418
+ }
3419
+ }
3420
+
3421
+ if ( ! repository ) {
3422
+ // Multiple repositories/submodules
3423
+ repository = await this . model . pickRepository ( [ 'repository' , 'submodule' ] ) ;
3424
+ }
3425
+
3426
+ if ( ! repository ) {
3427
+ return ;
3428
+ }
3429
+
3402
3430
await this . _createWorktree ( repository ) ;
3403
3431
}
3404
3432
@@ -3640,7 +3668,7 @@ export class CommandCenter {
3640
3668
}
3641
3669
}
3642
3670
3643
- @command ( 'git.openWorktree' , { repository : true , repositoryFilter : [ 'worktree' ] } )
3671
+ @command ( 'git.openWorktree' , { repository : true } )
3644
3672
async openWorktreeInCurrentWindow ( repository : Repository ) : Promise < void > {
3645
3673
if ( ! repository ) {
3646
3674
return ;
@@ -3650,7 +3678,7 @@ export class CommandCenter {
3650
3678
await commands . executeCommand ( 'vscode.openFolder' , uri , { forceReuseWindow : true } ) ;
3651
3679
}
3652
3680
3653
- @command ( 'git.openWorktreeInNewWindow' , { repository : true , repositoryFilter : [ 'worktree' ] } )
3681
+ @command ( 'git.openWorktreeInNewWindow' , { repository : true } )
3654
3682
async openWorktreeInNewWindow ( repository : Repository ) : Promise < void > {
3655
3683
if ( ! repository ) {
3656
3684
return ;
0 commit comments