pub struct WorktreeGuard { /* private fields */ }Expand description
RAII guard for a temporary git worktree.
Creates a detached worktree on construction, removes it on drop. This provides the language-agnostic foundation — just git checkout, no build steps. Language crates that need build steps (npm install, tsc, mvn compile) should compose with this guard:
ⓘ
// In a language crate:
pub struct TsWorktreeGuard {
inner: semver_analyzer_core::git::WorktreeGuard,
warnings: Vec<ExtractionWarning>,
}Implementations§
Source§impl WorktreeGuard
impl WorktreeGuard
Sourcepub fn new(repo: &Path, git_ref: &str) -> Result<Self>
pub fn new(repo: &Path, git_ref: &str) -> Result<Self>
Create a new worktree for the given git ref.
Validates the repository and ref, then creates a detached worktree
at <repo>/.semver-worktrees/<sanitized-ref>. If a stale worktree
exists at the same path, it is removed first.
On drop, the worktree is automatically removed.
Sourcepub fn cleanup_stale(repo: &Path) -> Result<usize>
pub fn cleanup_stale(repo: &Path) -> Result<usize>
Scan for and remove stale worktrees from previous crashed runs.
Looks in <tmp>/semver-worktrees/<repo-hash>/ for any existing
directories and attempts to clean them up via git worktree remove.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for WorktreeGuard
impl RefUnwindSafe for WorktreeGuard
impl Send for WorktreeGuard
impl Sync for WorktreeGuard
impl Unpin for WorktreeGuard
impl UnsafeUnpin for WorktreeGuard
impl UnwindSafe for WorktreeGuard
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