1
1
import { QuickInputButtons } from 'vscode' ;
2
2
import type { Container } from '../../container' ;
3
- import { BranchError } from '../../git/errors' ;
3
+ import { BranchError , BranchErrorReason } from '../../git/errors' ;
4
4
import type { GitBranchReference , GitReference } from '../../git/models/reference' ;
5
5
import {
6
6
getNameWithoutRemote ,
@@ -11,7 +11,7 @@ import {
11
11
import { Repository } from '../../git/models/repository' ;
12
12
import type { GitWorktree } from '../../git/models/worktree' ;
13
13
import { getWorktreesByBranch } from '../../git/models/worktree' ;
14
- import { showGenericErrorMessage } from '../../messages' ;
14
+ import { showGenericErrorMessage , showGitBranchNotFullyMergedPrompt } from '../../messages' ;
15
15
import type { QuickPickItemOfT } from '../../quickpicks/items/common' ;
16
16
import { createQuickPickSeparator } from '../../quickpicks/items/common' ;
17
17
import type { FlagsQuickPickItem } from '../../quickpicks/items/flags' ;
@@ -540,7 +540,23 @@ export class BranchGitCommand extends QuickCommand {
540
540
} catch ( ex ) {
541
541
// TODO likely need some better error handling here
542
542
Logger . error ( ex ) ;
543
- return showGenericErrorMessage ( ex ) ;
543
+ if ( ex instanceof BranchError && ex . reason === BranchErrorReason . BranchNotFullyMerged ) {
544
+ const shouldRetryWithForce = await showGitBranchNotFullyMergedPrompt ( ref . name ) ;
545
+ if ( shouldRetryWithForce ) {
546
+ try {
547
+ await state . repo . git . deleteBranch ( ref , {
548
+ force : true ,
549
+ remote : state . flags . includes ( '--remotes' ) ,
550
+ } ) ;
551
+ } catch ( ex ) {
552
+ Logger . error ( ex ) ;
553
+ await showGenericErrorMessage ( ex ) ;
554
+ }
555
+ }
556
+ continue ;
557
+ }
558
+
559
+ await showGenericErrorMessage ( ex ) ;
544
560
}
545
561
}
546
562
}
0 commit comments