Skip to content

Migrate stash-tidy onto the CleanPipeline seam#203

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

Migrate stash-tidy onto the CleanPipeline seam#203
jakebromberg merged 1 commit into
mainfrom
migrate/clean-stash

Conversation

@jakebromberg

Copy link
Copy Markdown
Owner

Step 3 of #118 (3 of 5). Moves git-stash-tidy onto git_tidy_core::clean::run_clean. CleanResult<DroppedStash> unchanged.

Descending-drop-order (so dropping stash@{2} never renumbers a lower pending index) is preserved by pre-sorting each group's stashes by descending index before the call (new order_group_items), since the shared loop preserves input order. should_clean-rejected stashes are retained so they're still counted skipped; should_clean+unparseable-ref stashes are excluded entirely, matching the original's silent fall-through.

Behavior-preserving: clean_drops_in_descending_order and all other tests pass unchanged. Local CI green.

Refs #118

Rewrite git-stash-tidy's hand-rolled clean loop to delegate iterate/filter/act/aggregate to the shared git_tidy_core::clean::run_clean seam (issue #118 step 3). The public run_clean signature and CleanResult<DroppedStash> return type are unchanged, so no callers or tests needed edits. The should_clean classification filter becomes the pure, silent decide predicate (Decision::Clean/Skip), and a single act closure owns the tool-specific work: dry-run-vs-real branching, the verbatim "would drop {ref} in {group}" / "dropped {ref} in {group}" / "error: could not drop {ref}" wording, the git.stash_drop call, and construction of the success record (Outcome::Cleaned) or failure record (Outcome::Failed(FailedItem)). run_clean is invoked once per repo group so each repo's output stays contiguous, with succeeded/failed/skipped accumulated across groups.

Descending-drop-order is preserved by pre-sorting each group's stashes by descending stash@{N} index before the call, in the new order_group_items helper, because the shared loop preserves input order. Admitted stashes (should_clean true and a parseable index) sort high-index-first so dropping stash@{2} never renumbers a lower pending index; should_clean-rejected stashes are retained so the loop still counts them as skipped; and stashes that would be cleaned but whose ref does not parse are excluded entirely, exactly as the original loop silently ignored them. The index parsing reuses the unchanged parse_stash_index. clean_drops_in_descending_order and every other unit and integration test pass unchanged.

Refs #118
@jakebromberg jakebromberg merged commit 71b285c into main Jun 22, 2026
3 checks passed
@jakebromberg jakebromberg deleted the migrate/clean-stash 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