MCPcopy Create free account
hub / github.com/agentforce314/clawcodex / remove_agent_worktree

Function remove_agent_worktree

src/bridge/worktree.py:201–220  ·  view source on GitHub ↗

Best-effort remove. No-op if ``paths.created`` is ``False``. Uses ``--force`` so uncommitted edits in the session's worktree don't block cleanup — the entire point of an agent worktree is that we don't care about its working state after the session ends.

(paths: WorktreePaths)

Source from the content-addressed store, hash-verified

199
200
201async def remove_agent_worktree(paths: WorktreePaths) -> None:
202 """Best-effort remove. No-op if ``paths.created`` is ``False``.
203
204 Uses ``--force`` so uncommitted edits in the session's worktree
205 don't block cleanup — the entire point of an agent worktree is
206 that we don't care about its working state after the session ends.
207 """
208 if not paths.created:
209 return
210 rc, stderr = await _run_git(
211 'worktree', 'remove', '--force', paths.working_dir,
212 cwd=paths.base_dir,
213 )
214 if rc != 0:
215 logger.warning(
216 '[worktree] git worktree remove failed (rc=%d): %s',
217 rc, stderr.strip(),
218 )
219 return
220 logger.info('[worktree] Removed %s', paths.working_dir)

Calls 1

_run_gitFunction · 0.70