|
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 { getNameWithoutRemote, getReferenceLabel, isRevisionReference } from '../../git/models/reference';
|
6 | 6 | import { Repository } from '../../git/models/repository';
|
7 | 7 | import type { GitWorktree } from '../../git/models/worktree';
|
8 | 8 | import { getWorktreesByBranch } from '../../git/models/worktree';
|
9 |
| -import { showGenericErrorMessage } from '../../messages'; |
| 9 | +import { showGenericErrorMessage, showGitBranchNotFullyMergedPrompt } from '../../messages'; |
10 | 10 | import type { QuickPickItemOfT } from '../../quickpicks/items/common';
|
11 | 11 | import { createQuickPickSeparator } from '../../quickpicks/items/common';
|
12 | 12 | import type { FlagsQuickPickItem } from '../../quickpicks/items/flags';
|
@@ -527,7 +527,23 @@ export class BranchGitCommand extends QuickCommand {
|
527 | 527 | } catch (ex) {
|
528 | 528 | // TODO likely need some better error handling here
|
529 | 529 | Logger.error(ex);
|
530 |
| - return showGenericErrorMessage(ex); |
| 530 | + if (ex instanceof BranchError && ex.reason === BranchErrorReason.BranchNotFullyMerged) { |
| 531 | + const shouldRetryWithForce = await showGitBranchNotFullyMergedPrompt(ref.name); |
| 532 | + if (shouldRetryWithForce) { |
| 533 | + try { |
| 534 | + await state.repo.git.deleteBranch(ref, { |
| 535 | + force: true, |
| 536 | + remote: state.flags.includes('--remotes'), |
| 537 | + }); |
| 538 | + } catch (ex) { |
| 539 | + Logger.error(ex); |
| 540 | + await showGenericErrorMessage(ex); |
| 541 | + } |
| 542 | + } |
| 543 | + continue; |
| 544 | + } |
| 545 | + |
| 546 | + await showGenericErrorMessage(ex); |
531 | 547 | }
|
532 | 548 | }
|
533 | 549 | }
|
|
0 commit comments