|
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 { 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';
|
@@ -531,7 +531,23 @@ export class BranchGitCommand extends QuickCommand {
|
531 | 531 | } catch (ex) {
|
532 | 532 | // TODO likely need some better error handling here
|
533 | 533 | Logger.error(ex);
|
534 |
| - return showGenericErrorMessage(ex); |
| 534 | + if (ex instanceof BranchError && ex.reason === BranchErrorReason.BranchNotFullyMerged) { |
| 535 | + const shouldRetryWithForce = await showGitBranchNotFullyMergedPrompt(ref.name); |
| 536 | + if (shouldRetryWithForce) { |
| 537 | + try { |
| 538 | + await state.repo.git.deleteBranch(ref, { |
| 539 | + force: true, |
| 540 | + remote: state.flags.includes('--remotes'), |
| 541 | + }); |
| 542 | + } catch (ex) { |
| 543 | + Logger.error(ex); |
| 544 | + await showGenericErrorMessage(ex); |
| 545 | + } |
| 546 | + } |
| 547 | + continue; |
| 548 | + } |
| 549 | + |
| 550 | + await showGenericErrorMessage(ex); |
535 | 551 | }
|
536 | 552 | }
|
537 | 553 | }
|
|
0 commit comments