Skip to content

Commit e13faa9

Browse files
Copilotalexr00
andcommitted
Skip worktree deletion when worktree is a workspace folder
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
1 parent fb1e543 commit e13faa9

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/github/pullRequestReviewCommon.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ export interface ReviewContext {
2929
getTimeline(): Promise<TimelineEvent[]>;
3030
}
3131

32+
function isWorktreeInWorkspace(worktreePath: string): boolean {
33+
const workspaceFolders = vscode.workspace.workspaceFolders;
34+
if (!workspaceFolders) {
35+
return false;
36+
}
37+
return workspaceFolders.some(folder => folder.uri.fsPath === worktreePath);
38+
}
39+
3240
/**
3341
* Utility functions for handling pull request reviews.
3442
* These are shared between PullRequestOverviewPanel and PullRequestViewProvider.
@@ -337,7 +345,7 @@ export namespace PullRequestReviewCommon {
337345
}
338346

339347
const worktreePath = folderRepositoryManager.getWorktreeForBranch(branchInfo.branch);
340-
if (worktreePath) {
348+
if (worktreePath && !isWorktreeInWorkspace(worktreePath)) {
341349
const preferredWorktreeDeletion = vscode.workspace
342350
.getConfiguration(PR_SETTINGS_NAMESPACE)
343351
.get<boolean>(`${DEFAULT_DELETION_METHOD}.${SELECT_WORKTREE}`);
@@ -527,7 +535,7 @@ export namespace PullRequestReviewCommon {
527535
.get<boolean>(`${DEFAULT_DELETION_METHOD}.${SELECT_WORKTREE}`, false);
528536
if (branchInfo && deleteWorktree) {
529537
const worktreePath = folderRepositoryManager.getWorktreeForBranch(branchInfo.branch);
530-
if (worktreePath) {
538+
if (worktreePath && !isWorktreeInWorkspace(worktreePath)) {
531539
selectedActions.push({ type: 'worktree', worktreePath });
532540
}
533541
}

0 commit comments

Comments
 (0)