Skip to main content

Module effective_target

Module effective_target 

Source
Expand description

Worktree target classification for worktree-enforcing policies. What: Classify the worktree an invocation targets for worktree-enforcing policies. Why: Linked-worktree safeguards discipline a person’s repositories, not the disposable clones a tool keeps in its own cache.

In TS you’d write (pseudocode):

// classifyEffectiveTarget(identity, allowedDirs) === 'linked-worktree'

Enums§

EffectiveTarget
What: The four targets worktree policies distinguish. #[derive(...)] generates copying, debug printing and ==. Why: A bare repository or no repository has no worktree to protect; an allowlisted tool cache is exempt; main versus linked decides enforcement.

Functions§

classify_effective_target
What: Map a repository identity to the target worktree policies act on. Why: Bare and absent repositories have no worktree; a repository whose Git directory sits under an allowed tool cache is exempt before main/linked matters.
default_allowed_worktree_dirs
What: The tool-cache directories exempt from worktree enforcement on this machine. Vec<PathBuf> is an owned list of owned paths. Why: The set is a property of installed tooling, not of any repository, so it is compiled in rather than configured.
is_allowed_worktree_dir
What: Report whether the canonical candidate lies inside any allowed directory. Why: Each allowed directory is resolved through symbolic links first, so a home reached through a link still matches; a directory that does not exist drops out. Path::starts_with compares whole segments, so /a/b does not contain /a/bc.
uv_cache_dir
What: Resolve uv’s cache directory the way uv does: UV_CACHE_DIR, then XDG_CACHE_HOME/uv, then HOME/.cache/uv; an empty value counts as unset. Option<&Path> is “a borrowed home directory or nothing”; Option<PathBuf> is “an owned path or nothing”. Why: uv runs destructive Git inside throwaway clones it owns there. The home directory is injected so tests never read the real one.