Skip to content

Migrate branch-tidy and worktree-tidy onto the CleanPipeline seam#201

Merged
jakebromberg merged 1 commit into
mainfrom
migrate/clean-branch-worktree
Jun 22, 2026
Merged

Migrate branch-tidy and worktree-tidy onto the CleanPipeline seam#201
jakebromberg merged 1 commit into
mainfrom
migrate/clean-branch-worktree

Conversation

@jakebromberg

Copy link
Copy Markdown
Owner

Step 3 of #118 (1 of 5 tool-migration PRs). Moves git-branch-tidy and git-worktree-tidy off their hand-rolled clean loops and onto the shared git_tidy_core::clean::run_clean seam, and deduplicates the byte-identical should_clean the two shared.

  • Each tool calls run_clean once per repo group; decide is the pure silent filter, act owns dry-run/wording/guards/delete/record. Public signatures and return types unchanged.
  • branch: decide also silently skips the current branch; act preserves the remote-only path, force-vs-safe local delete, include_remote soft-warning, and all wording.
  • worktree: act preserves the dirty guard (LandedStale fall-through + working-tree diff-check), the three-tier remove_worktree, and the delete_branches fail-closed guard.
  • New git_tidy_core::classification::should_clean_landed(c, all, strict) is the one shared filter; worktree keeps a thin wrapper so its existing unit tests still exercise it.

Behavior-preserving: all existing unit + integration tests pass unchanged. Local CI green (fmt, clippy -D, test).

Refs #118

Rewrite the hand-rolled clean loops in git-branch-tidy and git-worktree-tidy to delegate to the shared git_tidy_core::clean::run_clean pipeline, matching the shape already used by git-repo-tidy. Both tools group by repo, so run_clean is invoked once per RepoGroup over that group's items, keeping group.name and group.repo_path in scope for the per-item act wording and preserving per-repo-contiguous output; the per-group CleanResults are accumulated into each tool's overall succeeded/failed/skipped totals. The public run_clean signatures and return types (CleanResult<RemovedRef> and CleanResult<RemovedWorktree>) are unchanged.

In each tool the decide closure is the pure, silent classification filter and act owns everything tool-specific: dry-run branching, printed guards (returning Outcome::Skipped after printing), the actual delete, and the success record. For branch-tidy decide additionally skips the current branch silently, and act preserves the remote-only deletion path, the force-vs-safe local-delete decision, the include_remote soft-warning, and all dry-run/success/error wording. For worktree-tidy act preserves the dirty guard with the LandedStale fall-through and the working-tree diff-check, the three-tier remove_worktree helper, the delete_branches fail-closed guard, and all wording.

Dedup the byte-identical should_clean shared by both tools into a new git_tidy_core::classification::should_clean_landed(c, all, strict) helper; branch-tidy's decide calls it directly and worktree-tidy keeps a thin should_clean wrapper (still exercised by its existing unit tests) that delegates to it. No behavior changed.

Refs #118
@jakebromberg jakebromberg merged commit 339a66c into main Jun 22, 2026
3 checks passed
@jakebromberg jakebromberg deleted the migrate/clean-branch-worktree branch June 22, 2026 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant