rework deletion flow (#256415)

* rework deletion flow

* change delete label

* Revise deletion of worktree

* reopen correct repo

* clean up

* Refactor deleteWorkspace command

* Do not show deleteWorktree command in the command palette

---------

Co-authored-by: Ladislau Szomoru <3372902+lszomoru@users.noreply.github.com>
This commit is contained in:
Christy 😺
2025-07-18 07:06:08 -07:00
committed by GitHub
parent 4d63b40906
commit dd052e8d44
7 changed files with 55 additions and 39 deletions

View File

@@ -349,6 +349,8 @@ function getGitErrorCode(stderr: string): string | undefined {
return GitErrorCodes.DirtyWorkTree;
} else if (/detected dubious ownership in repository at/.test(stderr)) {
return GitErrorCodes.NotASafeGitRepository;
} else if (/contains modified or untracked files|use --force to delete it/.test(stderr)) {
return GitErrorCodes.WorktreeContainsChanges;
}
return undefined;
@@ -2038,8 +2040,14 @@ export class Repository {
await this.exec(args);
}
async deleteWorktree(path: string): Promise<void> {
const args = ['worktree', 'remove', path];
async deleteWorktree(path: string, options?: { force?: boolean }): Promise<void> {
const args = ['worktree', 'remove'];
if (options?.force) {
args.push('--force');
}
args.push(path);
await this.exec(args);
}