pub struct WorktreeManager { /* private fields */ }Expand description
Manages git worktrees for pool slots.
Implementations§
Source§impl WorktreeManager
impl WorktreeManager
Sourcepub fn new(repo_dir: impl Into<PathBuf>, base_dir: Option<PathBuf>) -> Self
pub fn new(repo_dir: impl Into<PathBuf>, base_dir: Option<PathBuf>) -> Self
Create a new worktree manager.
repo_dir: The source repository to create worktrees from.base_dir: Directory where worktrees will be created. IfNone, uses a temp directory under the system temp dir.
Sourcepub async fn new_validated(
repo_dir: impl Into<PathBuf>,
base_dir: Option<PathBuf>,
) -> Result<Self>
pub async fn new_validated( repo_dir: impl Into<PathBuf>, base_dir: Option<PathBuf>, ) -> Result<Self>
Create a worktree manager after verifying the repo directory is a git repository.
Returns an error if repo_dir is not inside a git working tree.
Sourcepub async fn create(&self, slot_id: &SlotId) -> Result<PathBuf>
pub async fn create(&self, slot_id: &SlotId) -> Result<PathBuf>
Create a worktree for a slot.
Creates a git worktree at {base_dir}/{slot_id} branched from
the current HEAD.
Sourcepub async fn remove(&self, slot_id: &SlotId) -> Result<()>
pub async fn remove(&self, slot_id: &SlotId) -> Result<()>
Remove a slot’s worktree and its branch.
Sourcepub async fn cleanup_all(&self, slot_ids: &[SlotId]) -> Result<()>
pub async fn cleanup_all(&self, slot_ids: &[SlotId]) -> Result<()>
Remove all worktrees managed by this pool.
Sourcepub fn worktree_path(&self, slot_id: &SlotId) -> PathBuf
pub fn worktree_path(&self, slot_id: &SlotId) -> PathBuf
Get the worktree path for a slot (may not exist yet).
Sourcepub async fn create_for_chain(&self, task_id: &TaskId) -> Result<PathBuf>
pub async fn create_for_chain(&self, task_id: &TaskId) -> Result<PathBuf>
Create a worktree for a chain execution.
Creates a git worktree at {base_dir}/chains/{task_id} branched from
the current HEAD.
Sourcepub async fn remove_chain(&self, task_id: &TaskId) -> Result<()>
pub async fn remove_chain(&self, task_id: &TaskId) -> Result<()>
Remove a chain’s worktree and its branch.
Sourcepub fn chain_worktree_path(&self, task_id: &TaskId) -> PathBuf
pub fn chain_worktree_path(&self, task_id: &TaskId) -> PathBuf
Get the worktree path for a chain (may not exist yet).
Sourcepub async fn create_clone_for_chain(&self, task_id: &TaskId) -> Result<PathBuf>
pub async fn create_clone_for_chain(&self, task_id: &TaskId) -> Result<PathBuf>
Create a full clone for a chain execution using git clone --local --shared.
Creates a clone at {base_dir}/clones/{task_id} with no shared .git directory.
Sourcepub async fn remove_clone(&self, task_id: &TaskId) -> Result<()>
pub async fn remove_clone(&self, task_id: &TaskId) -> Result<()>
Remove a chain’s clone directory.
Sourcepub fn clone_path(&self, task_id: &TaskId) -> PathBuf
pub fn clone_path(&self, task_id: &TaskId) -> PathBuf
Get the clone path for a chain (may not exist yet).