Skip to content

Migrate worktree-tidy onto core run_pipeline scan seam#198

Merged
jakebromberg merged 1 commit into
mainfrom
117e-scan-pipeline
Jun 21, 2026
Merged

Migrate worktree-tidy onto core run_pipeline scan seam#198
jakebromberg merged 1 commit into
mainfrom
117e-scan-pipeline

Conversation

@jakebromberg

Copy link
Copy Markdown
Owner

Summary

Migrates git-worktree-tidy onto the shared git_tidy_core::scan::run_pipeline seam with ScanOptions { fetch: true }, and deletes the now-dead worktree-specific core types. worktree-tidy was the last tool still using the non-generic core::types::{RepoGroup, ScanResult} that PR B's generics were modeled on, so this PR also shrinks core::types for the first time.

What changed

  • run_scan_repos routes through run_pipeline. The per-repo git fetch --prune is handed to the seam (the last fetch: true tool), 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); the seam wraps non-empty groups, folds Counts by Classified::classification_label, and sums total_scanned.
  • Discovery and the --match 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 — the documented worktree deviation (parent-repo paths in, worktree map captured).
  • Core-type deletion + orphan-rule inversion. Removes the non-generic RepoGroup, ScanResult, and their FlatJsonItems impl from core::types. Because WorktreeInfo is a core type, its new Classified and IntoJsonItem impls live in core (the inverse of branch-tidy, where BranchInfo is a tool-crate type). A WorktreeScanResult = ScanResult<WorktreeInfo> alias keeps a stable type name for the tool and the audit runner, preserving repos/total_scanned/counts/warnings.

Behavior

Public output is byte-identical: flat --json array, 9-field porcelain (worktree dir then parent repo, via the untouched TidyItem impl), and the LANDED_SUMMARY human line. Item ordering is preserved by the closure's sort_by_key on classification priority; fetch parity is one git fetch --prune per repo as before. The audit runner is untouched (run_scan 8-arg signature and |r| &r.counts unchanged).

Tests

All existing scan/output/clean/discovery tests pass unchanged save the worktreesitems / ScanResultWorktreeScanResult fixture renames. Adds run_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 manual is_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

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
@jakebromberg jakebromberg merged commit dec1568 into main Jun 21, 2026
3 checks passed
@jakebromberg jakebromberg deleted the 117e-scan-pipeline branch June 21, 2026 17:20
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