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§
- Effective
Target - 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
candidatelies 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_withcompares whole segments, so/a/bdoes not contain/a/bc. - uv_
cache_ dir - What:
Resolve uv’s cache directory the way uv does:
UV_CACHE_DIR, thenXDG_CACHE_HOME/uv, thenHOME/.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.