Skip to main content

Module clean

Module clean 

Source
Expand description

Worktree cleanup for finished runs: blyte clean, on review, and at dispatch.

Structs§

CleanContext
Context for cleaning a repository, caching metadata to avoid redundant git calls and disk reads.
CleanRepoStats
GitWorktreeInfo

Enums§

KeptReason
RemovalReason

Functions§

check_removable
Evaluates whether a worktree is removable according to the clean rules.
clean_on_review
Removes a run’s worktree on review after recording the verdict under the same rules. Removes the worktree only when the rules allow it now (e.g. redone, or work already merged); otherwise prints nothing extra beyond the verdict line, except for accepted/fixed prints worktree .wt/<id> kept until wip/<id> is merged.
clean_quiet
Quiet cleanup at dispatch start: no output unless something was removed, then one line blyte: removed N finished worktrees (X GB) on stderr. Never fails the dispatch: logs errors to stderr and goes on.
clean_repo
Cleans one repository.
dir_size
Recursively computes directory size in bytes without following symlinks.
display_worktree_path
Formats a worktree path for display and for git CLI commands: relative to root if inside root or a sibling (same parent directory); otherwise absolute.
find_blyte_worktrees
Lists all .wt/<id> directories that have a corresponding .wt/<id>.start.json.
find_default_branch
Identifies the default branch (origin/HEAD’s target, else main, else master).
find_merged_followup
Finds a follow-up run that makes <id> merged.
find_repo_root
Finds the root repository (resolving the owning repository if inside a .wt run).
format_size
Formats byte count into human-readable representation: e.g. “812 MB”, “12.3 GB”.
get_branch_tip
Returns the commit SHA at the tip of branch_name if it exists.
has_uncommitted_changes
Checks whether a worktree has uncommitted changes via git status --porcelain.
has_wt_component
Returns true if any path component is .wt.
is_branch_merged
Checks whether a branch’s work is on the default branch when any of:
is_branch_merged_with_extra_targets
Checks whether a branch’s work is on the default branch or any of the extra target refs.
is_branch_merged_with_targets
Checks whether a branch’s work is on the default branch or any of the extra target refs.
is_commit_merged
Checks whether a commit’s work is on the default branch when any of:
is_commit_merged_with_targets
Checks whether a commit’s work is on the default branch or any of the extra target refs.
is_linked_worktree
Returns true if root is a linked worktree (its git-dir differs from its git-common-dir).
is_pid_alive
Checks whether a process with the given PID is alive.
is_research
Checks whether a run is a research run from its start file.
is_worktree_clean
Checks whether a worktree’s working tree is clean: git status --porcelain lists nothing other than .DS_Store files, at any depth.
list_all_run_ids
Lists all run IDs that have a corresponding .wt/<id>.start.json.
parse_worktree_list
Parses git worktrees from git worktree list --porcelain.
read_run_base
Reads base from .wt/<id>.start.json if present.
report_other_worktrees
Inspects other worktrees (excluding main checkout, linked-worktree roots, and blyte’s .wt/<id> runs), and reports any that are both merged and clean. Never deletes them.
resolve_base_targets
Resolves candidate git refs for a run’s base branch. Returns (display_name, targets) if base is a branch name that resolves. Returns None if base is not a branch name (e.g. HEAD, commit id, wip/ branch) or if none of the candidate refs resolve in git.
run
Runs the blyte clean command.