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).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for WorktreeManager
impl RefUnwindSafe for WorktreeManager
impl Send for WorktreeManager
impl Sync for WorktreeManager
impl Unpin for WorktreeManager
impl UnsafeUnpin for WorktreeManager
impl UnwindSafe for WorktreeManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more