Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Clean ¶
Clean prunes any zero-owned git worktrees older than maxAge to prevent disk space leaks.
func Release ¶
Release unlocks a worktree that Prepare locked, via `git worktree unlock`, making it eligible for Clean's staleness check again. Zero itself only knows a worktree's use is over when its own process created it and is now exiting (zero exec --worktree calls this via defer); zero worktrees prepare hands the path to an external caller with no defined end-of-life, so that caller must run `zero worktrees release <path>` itself once done. Until it does, the worktree stays locked and Clean will never touch it, which is the safe default over silently guessing at liveness from mtimes.
Types ¶
type CommandResult ¶
type Options ¶
type Options struct {
Cwd string
Name string
BaseDir string
Env map[string]string
Now func() time.Time
RunGit GitRunner
// LeasePID, when positive, records the owning process in the worktree
// lock reason. A lease carrying a PID is recoverable: if that process
// dies without releasing (SIGKILL, crash, power loss), Clean can expire
// the lease instead of skipping the locked worktree forever. Callers
// whose worktree outlives their process (zero worktrees prepare hands
// the path to an external owner) leave it zero for a persistent lock
// that only an explicit release clears.
LeasePID int
}
type Result ¶
type Result struct {
Name string `json:"name"`
Path string `json:"path"`
RepoRoot string `json:"repoRoot"`
SourceBranch string `json:"sourceBranch,omitempty"`
SourceCommit string `json:"sourceCommit,omitempty"`
Reused bool `json:"reused"`
// LockAcquired reports whether this Prepare call took the worktree lock.
// It is false when a reused worktree was already locked by another live
// caller; releasing that lease is that caller's responsibility, not ours.
LockAcquired bool `json:"lockAcquired"`
}