Migrate branch-tidy and worktree-tidy onto the CleanPipeline seam#201
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Step 3 of #118 (1 of 5 tool-migration PRs). Moves
git-branch-tidyandgit-worktree-tidyoff their hand-rolled clean loops and onto the sharedgit_tidy_core::clean::run_cleanseam, and deduplicates the byte-identicalshould_cleanthe two shared.run_cleanonce per repo group;decideis the pure silent filter,actowns dry-run/wording/guards/delete/record. Public signatures and return types unchanged.decidealso silently skips the current branch;actpreserves the remote-only path, force-vs-safe local delete,include_remotesoft-warning, and all wording.actpreserves the dirty guard (LandedStale fall-through + working-tree diff-check), the three-tierremove_worktree, and thedelete_branchesfail-closed guard.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