Migrate worktree-tidy onto core run_pipeline scan seam#198
Merged
Conversation
worktree-tidy was the last tool still on the worktree-specific core::types::{RepoGroup, ScanResult} that PR B's generics were modeled on. Route run_scan_repos through git_tidy_core::scan::run_pipeline with ScanOptions { fetch: true }, handing the per-repo git fetch --prune to the seam and dropping the tool's manual parallel_fetch, parallel_classify, empty-group check, and counts/total_scanned fold. The closure now returns the repo's Vec<WorktreeInfo> (empty for skipped repos) and the seam wraps non-empty groups, folds counts by Classified::classification_label, and sums total_scanned. Discovery and the --match basename filter stay in the thin run_scan, applied to the parent-repo map before the pipeline; the closure still captures that map and looks worktrees up by parent repo.
Delete the now-dead non-generic RepoGroup, ScanResult, and the FlatJsonItems impl from core::types, and add the per-item glue next to JsonWorktree: Classified and IntoJsonItem impls on WorktreeInfo (both must live in core because WorktreeInfo is a core type, the orphan-rule inverse of branch-tidy). A WorktreeScanResult = ScanResult<WorktreeInfo> alias keeps a stable type name for the tool and the audit runner, preserving repos/total_scanned/counts/warnings so audit JSON keys are unchanged.
Public output is byte-identical: flat --json array, 9-field porcelain (worktree dir then parent repo), and the LANDED_SUMMARY human line. Item ordering is preserved by the closure's sort_by_key on classification priority. Add a regression-guard test confirming a repo present in the map with a worktree but with failing default-branch detection yields no group and surfaces the warning.
Part of #117
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.
Summary
Migrates
git-worktree-tidyonto the sharedgit_tidy_core::scan::run_pipelineseam withScanOptions { fetch: true }, and deletes the now-dead worktree-specific core types. worktree-tidy was the last tool still using the non-genericcore::types::{RepoGroup, ScanResult}that PR B's generics were modeled on, so this PR also shrinkscore::typesfor the first time.What changed
run_scan_reposroutes throughrun_pipeline. The per-repogit fetch --pruneis handed to the seam (the lastfetch: truetool), dropping the tool's manualparallel_fetch,parallel_classify, empty-group check, andcounts/total_scannedfold. The closure now returns the repo'sVec<WorktreeInfo>(empty for skipped repos); the seam wraps non-empty groups, foldsCountsbyClassified::classification_label, and sumstotal_scanned.--matchfilter stay in the thinrun_scan, applied to the parent-repo map before the pipeline. The closure still captures that map and looks worktrees up by parent repo — the documented worktree deviation (parent-repo paths in, worktree map captured).RepoGroup,ScanResult, and theirFlatJsonItemsimpl fromcore::types. BecauseWorktreeInfois a core type, its newClassifiedandIntoJsonItemimpls live in core (the inverse of branch-tidy, whereBranchInfois a tool-crate type). AWorktreeScanResult = ScanResult<WorktreeInfo>alias keeps a stable type name for the tool and the audit runner, preservingrepos/total_scanned/counts/warnings.Behavior
Public output is byte-identical: flat
--jsonarray, 9-field porcelain (worktree dir then parent repo, via the untouchedTidyItemimpl), and theLANDED_SUMMARYhuman line. Item ordering is preserved by the closure'ssort_by_keyon classification priority; fetch parity is onegit fetch --pruneper repo as before. The audit runner is untouched (run_scan8-arg signature and|r| &r.countsunchanged).Tests
All existing scan/output/clean/discovery tests pass unchanged save the
worktrees→items/ScanResult→WorktreeScanResultfixture renames. Addsrun_scan_repos_drops_repo_when_default_branch_errors, a regression guard confirming a repo present in the map with a worktree but with failing default-branch detection yields no group and surfaces the warning — the empty-group drop the old manualis_empty()check provided, now provided by the seam.Local gate jobs green:
cargo fmt --check,cargo clippy --workspace --all-targets -D clippy::all,cargo test --workspace,cargo +1.93.0 check --workspace(MSRV).Part of #117