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§
Sourceasync fn create(
&self,
binding: &mut WorktreeBinding,
cancel: CancellationToken,
) -> Result<(), GitError>
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.
Sourceasync fn is_dirty(&self, worktree_path: &Path) -> Result<bool, GitError>
async fn is_dirty(&self, worktree_path: &Path) -> Result<bool, GitError>
Check whether a worktree has uncommitted changes.
Sourceasync fn resolve_head(&self, worktree_path: &Path) -> Result<String, GitError>
async fn resolve_head(&self, worktree_path: &Path) -> Result<String, GitError>
Get the current HEAD SHA for a worktree.
Sourceasync fn resolve_ref(
&self,
repo_root: &Path,
refspec: &str,
) -> Result<String, GitError>
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.
Sourceasync fn detect_interrupted(
&self,
worktree_path: &Path,
) -> Result<Option<InterruptedOp>, GitError>
async fn detect_interrupted( &self, worktree_path: &Path, ) -> Result<Option<InterruptedOp>, GitError>
Detect interrupted git operations by checking sentinel files (Section 12.10).
Sourceasync fn recover(
&self,
binding: &mut WorktreeBinding,
action: RecoveryAction,
cancel: CancellationToken,
) -> Result<(), GitError>
async fn recover( &self, binding: &mut WorktreeBinding, action: RecoveryAction, cancel: CancellationToken, ) -> Result<(), GitError>
Recover from an interrupted operation (Section 12.10).
Sourcefn validate_path_confinement(
&self,
path: &Path,
worktree_root: &Path,
) -> Result<(), GitError>
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).
Sourceasync fn validate_git_indirection(
&self,
worktree_path: &Path,
) -> Result<(), GitError>
async fn validate_git_indirection( &self, worktree_path: &Path, ) -> Result<(), GitError>
Validate the .git indirection file in a worktree (Section 12.2 step 5).
Sourceasync fn submodule_status_hash(
&self,
worktree_path: &Path,
) -> Result<String, GitError>
async fn submodule_status_hash( &self, worktree_path: &Path, ) -> Result<String, GitError>
Compute a hash of git submodule status output for change detection.
Sourceasync fn submodule_status(
&self,
worktree_path: &Path,
) -> Result<Vec<SubmoduleEntry>, GitError>
async fn submodule_status( &self, worktree_path: &Path, ) -> Result<Vec<SubmoduleEntry>, GitError>
Parse git submodule status into structured entries (Section 12.4).
Sourceasync fn check_uninitialized_submodules(
&self,
worktree_path: &Path,
) -> Result<Vec<String>, GitError>
async fn check_uninitialized_submodules( &self, worktree_path: &Path, ) -> Result<Vec<String>, GitError>
Check for uninitialized submodules. Returns paths of uninitialized submodules.
Sourceasync fn check_dirty_submodules(
&self,
worktree_path: &Path,
) -> Result<Vec<String>, GitError>
async fn check_dirty_submodules( &self, worktree_path: &Path, ) -> Result<Vec<String>, GitError>
Check for dirty (modified/conflicted) submodules. Returns paths of dirty submodules.
Sourcefn verify_submodule_policy(
&self,
mode: SubmoduleMode,
before: &[SubmoduleEntry],
after: &[SubmoduleEntry],
) -> Result<(), GitError>
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].
Sourceasync fn cleanup(
&self,
binding: &mut WorktreeBinding,
delete_branch: bool,
cancel: CancellationToken,
) -> Result<(), GitError>
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.