Skip to main content

create_worktree_in

Function create_worktree_in 

Source
pub fn create_worktree_in(
    repo_path: &Path,
    branch_name: Option<&str>,
) -> Result<WorktreeGuard>
Expand description

Create a git worktree for one agent run.

Shells git worktree add <dir> -b <branch> from repo_path. The new worktree lives under <repo_root>/.ryu-worktrees/ryu-run-<id> (inside the repo, below .gitignore). When branch_name is Some, it is sanitized and used as the branch (with a short uuid suffix appended on collision); when None (or unusable), the branch is auto-named ryu/run-<id>. Returns a WorktreeGuard whose Drop cleans up the worktree directory and its branch automatically.