mirror of
https://github.com/0xWheatyz/handler.git
synced 2026-08-30 10:06:24 +00:00
40390c0568
`git worktree add <path> <branch>` only checks out an existing ref, so spawning an agent on a fresh feature branch failed with `fatal: invalid reference` (exit 128) — the branch spawn asks for never exists yet, since spawn starts from the remote's latest state. - Detect whether the branch exists; use `git worktree add -b` to create it when it doesn't, and a plain checkout (git DWIMs remote tracking) when it does. - Slugify the agent name for the worktree directory so free-form names (a PR title) no longer put spaces/colons/parens in repo-root paths. - Surface git's stderr via a WorktreeError instead of a bare "exit status 128"; spawn re-raises it as SpawnError. Adds tests/test_worktree.py covering new-branch creation, existing-branch checkout, slugification, the isolation guard, and the clear-error path.