Documentation
¶
Index ¶
- Constants
- func Acquire(repoRoot, poolDir string, poolSize int, postCreate []string) (string, error)
- func Destroy(repoRoot, poolDir, worktreePath string, force bool, preDestroy []string) error
- func DestroyAll(repoRoot, poolDir string, force bool, preDestroy []string) error
- func Release(poolDir, worktreePath string) error
- func WithStateLock(poolDir string, fn func() error) error
- func WriteState(poolDir string, s State) error
- type PruneAllResult
- type PruneOptions
- type PrunePoolResult
- type PruneResult
- func Prune(repoRoot, poolDir string, dryRun bool, preDestroy []string) (PruneResult, error)
- func PrunePool(poolDir string, dryRun bool, preDestroy []string) (PruneResult, error)
- func PrunePoolWithOptions(poolDir string, options PruneOptions) (PruneResult, error)
- func PruneWithOptions(repoRoot, poolDir string, options PruneOptions) (PruneResult, error)
- type PruneSkipped
- type PruneWorktree
- type State
- type WorktreeEntry
- type WorktreeStatus
Constants ¶
const ( StatusAvailable = "available" StatusDirty = "dirty" StatusInUse = "in-use" StatusHere = "you're here" )
const ( // PruneSkipUncommitted means a worktree has tracked or untracked changes. PruneSkipUncommitted = "uncommitted changes" // PruneSkipUnmerged means HEAD is not merged into the selected default ref. PruneSkipUnmerged = "unmerged" // PruneSkipOrphanedBackingRepo means the linked worktree's gitdir is gone. PruneSkipOrphanedBackingRepo = "orphaned (backing repository missing)" // PruneSkipOriginUnreachable means origin could not be reached for verification. PruneSkipOriginUnreachable = "origin unreachable (cannot verify)" )
Variables ¶
This section is empty.
Functions ¶
func WithStateLock ¶
func WriteState ¶
Types ¶
type PruneAllResult ¶ added in v1.6.0
type PruneAllResult struct {
PoolRoot string
Pools []PrunePoolResult
Result PruneResult
}
PruneAllResult records per-pool and aggregate prune results under a pool root.
func PruneAll ¶ added in v1.6.0
func PruneAll(poolRoot string, dryRun bool, preDestroy []string) (PruneAllResult, error)
PruneAll prunes every managed pool directly under poolRoot and aggregates the results. When dryRun is false, all pools are planned before any worktree is deleted. Backing-repository-missing orphans are reported as skipped; use PruneAllWithOptions with PruneOptions.PruneOrphans to include them as candidates.
func PruneAllWithOptions ¶ added in v1.7.0
func PruneAllWithOptions(poolRoot string, options PruneOptions) (PruneAllResult, error)
PruneAllWithOptions prunes every managed pool directly under poolRoot and applies options for dry-run behavior, orphan handling, and pre-destroy hooks.
type PruneOptions ¶ added in v1.7.0
type PruneOptions struct {
// DryRun reports candidates and byte counts without deleting worktrees.
DryRun bool
// PruneOrphans includes backing-repository-missing linked worktrees as
// unverified prune candidates.
PruneOrphans bool
// PreDestroy is the hook command list to run before deleting each candidate.
PreDestroy []string
}
PruneOptions controls dry-run, orphan, and hook behavior for prune operations.
type PrunePoolResult ¶ added in v1.6.0
type PrunePoolResult struct {
PoolDir string
Result PruneResult
}
PrunePoolResult records the prune result for one managed pool directory.
type PruneResult ¶ added in v1.5.0
type PruneResult struct {
Candidates []PruneWorktree
Pruned []PruneWorktree
Skipped []PruneSkipped
ReclaimableBytes int64
FreedBytes int64
}
PruneResult describes dry-run candidates, removed worktrees, skipped worktrees, and the corresponding byte counts.
func Prune ¶ added in v1.5.0
func Prune(repoRoot, poolDir string, dryRun bool, preDestroy []string) (PruneResult, error)
Prune finds stale idle managed worktrees and optionally deletes them. A stale worktree is clean, unused, unreserved, and merged into the default branch ref selected by git.DefaultBranchMergeRef. In dryRun mode Prune reports candidates and reclaimable bytes without deleting. Backing-repository-missing orphans are reported as skipped; use PruneWithOptions with PruneOptions.PruneOrphans to include them as candidates.
func PrunePool ¶ added in v1.6.0
func PrunePool(poolDir string, dryRun bool, preDestroy []string) (PruneResult, error)
PrunePool prunes one pool by deriving each worktree's repository context from git metadata. Worktrees whose repository or default branch cannot be resolved are reported as skipped. Backing-repository-missing orphans are reported as skipped; use PrunePoolWithOptions with PruneOptions.PruneOrphans to include them as candidates.
func PrunePoolWithOptions ¶ added in v1.7.0
func PrunePoolWithOptions(poolDir string, options PruneOptions) (PruneResult, error)
PrunePoolWithOptions prunes one pool by deriving each worktree's repository context from git metadata and applying the supplied options.
func PruneWithOptions ¶ added in v1.7.0
func PruneWithOptions(repoRoot, poolDir string, options PruneOptions) (PruneResult, error)
PruneWithOptions finds prune candidates in one repository pool and applies options for dry-run behavior, orphan handling, and pre-destroy hooks.
type PruneSkipped ¶ added in v1.5.0
type PruneSkipped struct {
Name string
Path string
// Category is the stable group label for prune skip reporting.
Category string
// Reason is the short user-facing explanation for this specific worktree.
Reason string
// Detail carries raw diagnostics intended for verbose output.
Detail string
}
PruneSkipped describes a worktree that prune left in place for safety.
type PruneWorktree ¶ added in v1.5.0
type PruneWorktree struct {
Name string
Path string
Bytes int64
// Orphaned marks a backing-repository-missing worktree that was explicitly
// included by PruneOptions.PruneOrphans.
Orphaned bool
// Warning describes safety information that should be shown with the entry.
Warning string
}
PruneWorktree describes a stale or explicitly selected orphaned worktree that prune can remove or did remove.
type State ¶
type State struct {
Worktrees []WorktreeEntry `json:"worktrees"`
}
type WorktreeEntry ¶
type WorktreeEntry struct {
Name string `json:"name"`
Path string `json:"path"`
CreatedAt time.Time `json:"created_at"`
Destroying bool `json:"destroying,omitempty"`
OwnerPID int32 `json:"owner_pid,omitempty"`
OwnerStartedAt int64 `json:"owner_started_at,omitempty"`
}
func FindByPath ¶
func FindByPath(poolDir, path string) (*WorktreeEntry, error)
type WorktreeStatus ¶
type WorktreeStatus struct {
Name string
Path string
Status string
Processes []process.ProcessInfo
}
func List ¶
func List(poolDir string) ([]WorktreeStatus, error)