Skip to main content

Module rule_linked_worktree

Module rule_linked_worktree 

Source
Expand description

Pure decision of the linked-worktree-only policy. What: Pure decision of the linked-worktree-only policy: commands that can discard worktree state run only in a linked worktree. Why: git stash, a deleting git clean and a git reset that rewrites files can throw away work in the primary checkout. The policy confines them to linked worktrees. This file decides from the arguments alone whether the command is guarded, and from the worktree kind the caller measured whether to reject it. It starts no process.

In TS you’d write (pseudocode):

// decideLinkedWorktree(['clean', '-fd']) => { kind: 'needs-effective-target', command: 'clean' }

Enums§

GuardedCommand
What: The commands the policy guards. An enum is a closed set of named alternatives. #[derive(...)] asks the compiler to generate copying, debug printing and ==. Why: Each has its own rejection text.
LinkedWorktreeDecision
What: The outcome of looking at the argument list only. Why: Most commands are not guarded and need no repository query at all.

Constants§

LINKED_WORKTREE_REQUIRED_CODE
What: The finding code of a linked-worktree rejection. &str is borrowed text baked into the program. Why: Callers identify the finding by this stable code.

Functions§

decide_linked_worktree
What: Decide from the argument list. &[OsString] borrows the arguments, already free of wrapper controls. Why: A command that is not guarded, or that Git itself refuses, needs no measurement.
main_worktree_message
What: The rejection text for a command run in the main worktree. Why: The text says what the command could destroy and where to run it instead.
outside_worktree_message
What: The rejection text for a command run where there is no worktree. &'static str is text baked into the program. Why: The text says what the command could destroy and how to run it safely.
resolve_linked_worktree
What: Decide from the measured worktree kind: the rejection text, or nothing to let the command through. Why: A linked worktree and an allowlisted tool cache are the two places where these commands may run.