Skip to main content

WorktreeManager

Trait WorktreeManager 

Source
pub trait WorktreeManager: Send + Sync {
Show 14 methods // Required methods async fn create( &self, binding: &mut WorktreeBinding, cancel: CancellationToken, ) -> Result<(), GitError>; async fn is_dirty(&self, worktree_path: &Path) -> Result<bool, GitError>; async fn resolve_head( &self, worktree_path: &Path, ) -> Result<String, GitError>; async fn resolve_ref( &self, repo_root: &Path, refspec: &str, ) -> Result<String, GitError>; async fn detect_interrupted( &self, worktree_path: &Path, ) -> Result<Option<InterruptedOp>, GitError>; async fn recover( &self, binding: &mut WorktreeBinding, action: RecoveryAction, cancel: CancellationToken, ) -> Result<(), GitError>; fn validate_path_confinement( &self, path: &Path, worktree_root: &Path, ) -> Result<(), GitError>; async fn validate_git_indirection( &self, worktree_path: &Path, ) -> Result<(), GitError>; async fn submodule_status_hash( &self, worktree_path: &Path, ) -> Result<String, GitError>; async fn submodule_status( &self, worktree_path: &Path, ) -> Result<Vec<SubmoduleEntry>, GitError>; async fn check_uninitialized_submodules( &self, worktree_path: &Path, ) -> Result<Vec<String>, GitError>; async fn check_dirty_submodules( &self, worktree_path: &Path, ) -> Result<Vec<String>, GitError>; fn verify_submodule_policy( &self, mode: SubmoduleMode, before: &[SubmoduleEntry], after: &[SubmoduleEntry], ) -> Result<(), GitError>; async fn cleanup( &self, binding: &mut WorktreeBinding, delete_branch: bool, cancel: CancellationToken, ) -> Result<(), GitError>;
}
Expand description

Trait for managing worktree lifecycles.

All operations respect cancellation via CancellationToken and enforce path confinement to the worktree root.

Required Methods§

Source

async fn create( &self, binding: &mut WorktreeBinding, cancel: CancellationToken, ) -> Result<(), GitError>

Create a worktree from a base ref (Section 12.2).

Steps: verify repo cleanliness, resolve base ref, create branch, create worktree, validate .git indirection, transition to WtBoundHome.

Source

async fn is_dirty(&self, worktree_path: &Path) -> Result<bool, GitError>

Check whether a worktree has uncommitted changes.

Source

async fn resolve_head(&self, worktree_path: &Path) -> Result<String, GitError>

Get the current HEAD SHA for a worktree.

Source

async fn resolve_ref( &self, repo_root: &Path, refspec: &str, ) -> Result<String, GitError>

Resolve a ref (branch name, tag, or SHA) to a full SHA in the repo.

Source

async fn detect_interrupted( &self, worktree_path: &Path, ) -> Result<Option<InterruptedOp>, GitError>

Detect interrupted git operations by checking sentinel files (Section 12.10).

Source

async fn recover( &self, binding: &mut WorktreeBinding, action: RecoveryAction, cancel: CancellationToken, ) -> Result<(), GitError>

Recover from an interrupted operation (Section 12.10).

Source

fn validate_path_confinement( &self, path: &Path, worktree_root: &Path, ) -> Result<(), GitError>

Validate that a path is confined within the worktree root (Section 12.3).

Source

async fn validate_git_indirection( &self, worktree_path: &Path, ) -> Result<(), GitError>

Validate the .git indirection file in a worktree (Section 12.2 step 5).

Source

async fn submodule_status_hash( &self, worktree_path: &Path, ) -> Result<String, GitError>

Compute a hash of git submodule status output for change detection.

Source

async fn submodule_status( &self, worktree_path: &Path, ) -> Result<Vec<SubmoduleEntry>, GitError>

Parse git submodule status into structured entries (Section 12.4).

Source

async fn check_uninitialized_submodules( &self, worktree_path: &Path, ) -> Result<Vec<String>, GitError>

Check for uninitialized submodules. Returns paths of uninitialized submodules.

Source

async fn check_dirty_submodules( &self, worktree_path: &Path, ) -> Result<Vec<String>, GitError>

Check for dirty (modified/conflicted) submodules. Returns paths of dirty submodules.

Source

fn verify_submodule_policy( &self, mode: SubmoduleMode, before: &[SubmoduleEntry], after: &[SubmoduleEntry], ) -> Result<(), GitError>

Verify submodule policy between before/after states (Section 12.4).

Compares submodule status before and after an operation and validates that changes conform to the configured [SubmoduleMode].

Source

async fn cleanup( &self, binding: &mut WorktreeBinding, delete_branch: bool, cancel: CancellationToken, ) -> Result<(), GitError>

Remove the worktree and optionally its branch (Section 12.11).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§