Documentation
¶
Overview ¶
Package gitwt inspects git worktrees. It is safety-critical: a worktree may only be offered for removal when Inspect proves it holds no unsaved work. Whenever a git command needed for the proof fails, Inspect returns an error (callers keep the item) rather than guessing that the worktree is clean.
Index ¶
- Variables
- func BaseRef(ctx context.Context, repo string) string
- func FindRepos(root string, depth int) []string
- func Remove(ctx context.Context, repo, path string) error
- func RepoOf(ctx context.Context, path string) (string, error)
- func TrackedFiles(ctx context.Context, path string) (map[string]bool, error)
- type State
- type Worktree
Constants ¶
This section is empty.
Variables ¶
var Regenerable = []string{"node_modules", "dist", "build", "target", ".venv", "venv", "__pycache__", ".next", ".turbo", "coverage", ".pytest_cache", ".gradle", ".cache", ".parcel-cache", "out"}
Regenerable lists directory names whose ignored contents can be rebuilt.
Functions ¶
func FindRepos ¶
FindRepos returns root and directories at most depth levels below it that contain a .git directory. It skips node_modules and hidden directories and never follows symlinks.
func Remove ¶
Remove unregisters and deletes a worktree without --force. git only refuses for modified or untracked files it can see; it does NOT refuse for ignored files, assume-unchanged/skip-worktree edits, or untracked files hidden by status.showUntrackedFiles=no. Callers must Inspect immediately before Remove.
Types ¶
type State ¶
type State struct {
HeadSHA, Base string
Uncommitted, Untracked, IgnoredKept []string
HiddenFromStatus []string // assume-unchanged / skip-worktree files
UnsavedCommits, CommitsBeyondBase int
DetachedUnreachable bool
OpInProgress string
Locked bool
}
State is what Inspect found in a worktree.