Skip to content

Commit 4a485b8

Browse files
committed
Fixes #3378 worktree delete double confirm prompt
1 parent 305d406 commit 4a485b8

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
3030

3131
- Fixes [#3344](https://github.com/gitkraken/vscode-gitlens/issues/3344) - Make changing the AI key easier
3232
- Fixes [#3377](https://github.com/gitkraken/vscode-gitlens/issues/3377) - Cannot read properties of undefined (reading 'start')
33+
- Fixes [#3377](https://github.com/gitkraken/vscode-gitlens/issues/3378) - Deleting a worktree (without force) with working changes causes double prompts
3334
- Fixes fixes issue with Jira integration not refreshing
3435

3536
## [15.1.0] - 2024-06-05

src/commands/git/worktree.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,7 @@ export class WorktreeGitCommand extends QuickCommand<State> {
861861

862862
for (const uri of state.uris) {
863863
let retry = false;
864+
let skipHasChangesPrompt = false;
864865
do {
865866
retry = false;
866867
const force = state.flags.includes('--force');
@@ -873,7 +874,7 @@ export class WorktreeGitCommand extends QuickCommand<State> {
873874
status = await worktree?.getStatus();
874875
} catch {}
875876

876-
if (status?.hasChanges ?? false) {
877+
if ((status?.hasChanges ?? false) && !skipHasChangesPrompt) {
877878
const confirm: MessageItem = { title: 'Force Delete' };
878879
const cancel: MessageItem = { title: 'Cancel', isCloseAffordance: true };
879880
const result = await window.showWarningMessage(
@@ -889,6 +890,8 @@ export class WorktreeGitCommand extends QuickCommand<State> {
889890

890891
await state.repo.deleteWorktree(uri, { force: force });
891892
} catch (ex) {
893+
skipHasChangesPrompt = false;
894+
892895
if (WorktreeDeleteError.is(ex)) {
893896
if (ex.reason === WorktreeDeleteErrorReason.MainWorkingTree) {
894897
void window.showErrorMessage('Unable to delete the main worktree');
@@ -907,6 +910,7 @@ export class WorktreeGitCommand extends QuickCommand<State> {
907910
if (result === confirm) {
908911
state.flags.push('--force');
909912
retry = true;
913+
skipHasChangesPrompt = ex.reason === WorktreeDeleteErrorReason.HasChanges;
910914
}
911915
}
912916
} else {

0 commit comments

Comments
 (0)