mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-01 22:12:26 +01:00
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:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user