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' ;
@@ -554,7 +554,23 @@ export class BranchGitCommand extends QuickCommand {
554
554
} catch ( ex ) {
555
555
// TODO likely need some better error handling here
556
556
Logger . error ( ex ) ;
557
- return showGenericErrorMessage ( ex ) ;
557
+ if ( ex instanceof BranchError && ex . reason === BranchErrorReason . BranchNotFullyMerged ) {
558
+ const shouldRetryWithForce = await showGitBranchNotFullyMergedPrompt ( ref . name ) ;
559
+ if ( shouldRetryWithForce ) {
560
+ try {
561
+ await state . repo . git . deleteBranch ( ref , {
562
+ force : true ,
563
+ remote : state . flags . includes ( '--remotes' ) ,
564
+ } ) ;
565
+ } catch ( ex ) {
566
+ Logger . error ( ex ) ;
567
+ await showGenericErrorMessage ( ex ) ;
568
+ }
569
+ }
570
+ continue ;
571
+ }
572
+
573
+ await showGenericErrorMessage ( ex ) ;
558
574
}
559
575
}
560
576
}
0 commit comments