MCPcopy
hub / github.com/coder/mux / removeWorktree

Function removeWorktree

src/node/git.ts:242–263  ·  view source on GitHub ↗
(
  projectPath: string,
  workspacePath: string,
  options: { force: boolean } = { force: false }
)

Source from the content-addressed store, hash-verified

240}
241
242export async function removeWorktree(
243 projectPath: string,
244 workspacePath: string,
245 options: { force: boolean } = { force: false }
246): Promise<WorktreeResult> {
247 // Clean up stale lock before git operations on main repo
248 cleanStaleLock(projectPath);
249
250 try {
251 // Remove the worktree (from the main repository context)
252 const args = ["-C", projectPath, "worktree", "remove", workspacePath];
253 if (options.force) {
254 args.push("--force");
255 }
256 using proc = execFileAsync("git", args);
257 await proc.result;
258 return { success: true };
259 } catch (error) {
260 const message = getErrorMessage(error);
261 return { success: false, error: message };
262 }
263}
264
265export async function pruneWorktrees(projectPath: string): Promise<WorktreeResult> {
266 // Clean up stale lock before git operations on main repo

Callers

nothing calls this directly

Calls 4

execFileAsyncFunction · 0.90
getErrorMessageFunction · 0.90
cleanStaleLockFunction · 0.85
pushMethod · 0.65

Tested by

no test coverage detected