MCPcopy Index your code
hub / github.com/coder/mux / deleteWorktree

Method deleteWorktree

src/node/services/workspaceService.ts:5750–5774  ·  view source on GitHub ↗
(workspaceId: string)

Source from the content-addressed store, hash-verified

5748 }
5749
5750 async deleteWorktree(workspaceId: string): Promise<Result<void>> {
5751 try {
5752 const allMetadata = await this.config.getAllWorkspaceMetadata();
5753 const workspaceMetadata = allMetadata.find((metadata) => metadata.id === workspaceId);
5754 if (!workspaceMetadata) {
5755 return Err("Workspace not found");
5756 }
5757
5758 if (!isWorkspaceArchived(workspaceMetadata.archivedAt, workspaceMetadata.unarchivedAt)) {
5759 return Err("Only archived workspaces can delete their managed worktree");
5760 }
5761
5762 if (!isWorktreeRuntime(workspaceMetadata.runtimeConfig)) {
5763 return Err("Deleting a managed worktree is only supported for worktree runtimes");
5764 }
5765
5766 const managedPath = workspaceMetadata.namedWorkspacePath;
5767 await removeManagedGitWorktree(workspaceMetadata.projectPath, managedPath);
5768 await this.emitCurrentWorkspaceMetadata(workspaceId);
5769 return Ok(undefined);
5770 } catch (error) {
5771 const message = getErrorMessage(error);
5772 return Err(`Failed to delete managed worktree: ${message}`);
5773 }
5774 }
5775
5776 async stopRuntime(workspaceId: string): Promise<Result<void>> {
5777 const metadataResult = await this.aiService.getWorkspaceMetadata(workspaceId);

Callers 5

handleBulkDeleteWorktreeFunction · 0.80
handleDeleteWorktreeFunction · 0.80
routerFunction · 0.80

Calls 8

ErrFunction · 0.90
isWorkspaceArchivedFunction · 0.90
removeManagedGitWorktreeFunction · 0.90
OkFunction · 0.90
getErrorMessageFunction · 0.90
isWorktreeRuntimeFunction · 0.85

Tested by

no test coverage detected