pub struct WorktreeManager { /* private fields */ }Expand description
Worktree manager for parallel execution
Implementations§
Source§impl WorktreeManager
impl WorktreeManager
Sourcepub fn new_with_discovery(
worktree_base_name: Option<&str>,
max_concurrency: usize,
) -> Result<Self>
pub fn new_with_discovery( worktree_base_name: Option<&str>, max_concurrency: usize, ) -> Result<Self>
Create a new WorktreeManager with automatic Git repository discovery
This is the recommended constructor. It automatically discovers the Git repository root from the current directory, even if running from a subdirectory.
§Arguments
worktree_base_name- Name of the worktree base directory (default: “.worktrees”)max_concurrency- Maximum number of concurrent worktrees
§Examples
use miyabi_worktree::WorktreeManager;
// Works from any subdirectory within a Git repository
let manager = WorktreeManager::new_with_discovery(Some(".worktrees"), 3)?;Sourcepub fn new(
repo_path: impl AsRef<Path>,
worktree_base: impl AsRef<Path>,
max_concurrency: usize,
) -> Result<Self>
pub fn new( repo_path: impl AsRef<Path>, worktree_base: impl AsRef<Path>, max_concurrency: usize, ) -> Result<Self>
Create a new WorktreeManager
§Arguments
repo_path- Path to the main repositoryworktree_base- Base directory for worktreesmax_concurrency- Maximum number of concurrent worktrees
§Note
Consider using new_with_discovery() instead, which automatically
finds the Git repository root even when running from a subdirectory.
Sourcepub async fn create_worktree(&self, issue_number: u64) -> Result<WorktreeInfo>
pub async fn create_worktree(&self, issue_number: u64) -> Result<WorktreeInfo>
Create a new worktree for an issue
Returns the path to the created worktree
Sourcepub async fn remove_worktree(&self, worktree_id: &str) -> Result<()>
pub async fn remove_worktree(&self, worktree_id: &str) -> Result<()>
Remove worktree after task completion with safety checks
This method implements the safe worktree deletion protocol:
- Check if current directory is inside the worktree to be deleted
- If yes, change to repository root first
- Verify worktree exists
- Execute git worktree remove
- Run git worktree prune
This prevents “Unable to read current working directory” errors that occur when deleting a worktree while the shell is inside it.
Sourcepub async fn push_worktree(&self, worktree_id: &str) -> Result<()>
pub async fn push_worktree(&self, worktree_id: &str) -> Result<()>
Push worktree changes to remote
Sourcepub async fn merge_worktree(&self, worktree_id: &str) -> Result<()>
pub async fn merge_worktree(&self, worktree_id: &str) -> Result<()>
Merge worktree branch into main
Sourcepub async fn update_status(
&self,
worktree_id: &str,
status: WorktreeStatus,
) -> Result<()>
pub async fn update_status( &self, worktree_id: &str, status: WorktreeStatus, ) -> Result<()>
Update worktree status
Sourcepub async fn get_worktree(&self, worktree_id: &str) -> Result<WorktreeInfo>
pub async fn get_worktree(&self, worktree_id: &str) -> Result<WorktreeInfo>
Get worktree information
Sourcepub async fn list_worktrees(&self) -> Vec<WorktreeInfo>
pub async fn list_worktrees(&self) -> Vec<WorktreeInfo>
List all worktrees
Sourcepub async fn stats(&self) -> WorktreeStats
pub async fn stats(&self) -> WorktreeStats
Get worktree statistics
Sourcepub async fn cleanup_all(&self) -> Result<()>
pub async fn cleanup_all(&self) -> Result<()>
Cleanup all worktrees
Sourcepub async fn telemetry_report(&self) -> String
pub async fn telemetry_report(&self) -> String
Get telemetry report (human-readable)
Sourcepub async fn telemetry_stats(&self) -> TelemetryStats
pub async fn telemetry_stats(&self) -> TelemetryStats
Get telemetry statistics
Trait Implementations§
Source§impl Clone for WorktreeManager
impl Clone for WorktreeManager
Source§fn clone(&self) -> WorktreeManager
fn clone(&self) -> WorktreeManager
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for WorktreeManager
impl !RefUnwindSafe for WorktreeManager
impl Send for WorktreeManager
impl Sync for WorktreeManager
impl Unpin 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more