Migrate stash-tidy onto the CleanPipeline seam#203
Merged
Conversation
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
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 (3 of 5). Moves
git-stash-tidyontogit_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 (neworder_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_orderand all other tests pass unchanged. Local CI green.Refs #118