feat: add tidy command for branch cleanup - #342
Open
bkrupa wants to merge 4 commits into
Open
Conversation
- Add twig tidy clean: remove branches with no unique commits - Add twig tidy prune: remove stale branch references from twig config - Support --dry-run, --force, and --aggressive modes - Aggressive mode reparents children before deleting empty intermediates
- Issue #1 (MAJOR): fix detached/unborn HEAD crash in is_current_branch by using match instead of ? propagation - Issue #2 (MAJOR): guard has_non_cleanable_children against dependency cycles with a visited HashSet to prevent stack overflow - Issue #3 (MAJOR): move reparenting discovery to a pre-pass so the full deletion list (including reparenting-triggered deletions) is shown to the user before confirmation - Issue #4 (MAJOR): fix find_reparenting_opportunities to group by unique intermediate branch, preventing conflicting ops when the same branch appears as parent in multiple dependencies - Issue #5 (MINOR): collapse nested if statements (clippy::collapsible_if) - Issue #6 (MINOR): extract prompt_for_confirmation to crate::utils and share it across adopt.rs and tidy.rs - Issue #7 (MINOR): remove inline use std::io imports from function bodies - Issue #8 (MINOR): gate hardcoded fallback parents (main/master/develop) behind --aggressive mode via with_fallback parameter - Issue #9 (MINOR): cleanup_branch_from_config now also removes repo_state.branches metadata to stay consistent with prune - Issue #10 (MINOR): add 8 integration tests covering has_unique_commits, detached HEAD, cleanup metadata, fallback parent behaviour, cycle guard, and conflicting reparenting ops - Issue #11 (NIT): add Rustdoc to TidyArgs fields - Issue #12 (NIT): change find_cleanable_dependency_chain to return Option<Vec<String>> for clearer semantics - Issue #13 (NIT): use HashSet for O(1) dedup checks on branches_to_delete - Issue #14 (NIT): fix contradictory comment about non-interactive mode Also fix pre-existing clippy::useless_format lint in windows.rs
bkrupa
force-pushed
the
feature/tidy-command
branch
from
February 26, 2026 00:52
4972c41 to
f06a45d
Compare
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
New
twig tidycommand for cleaning up branches:Provides a safe, interactive workflow for branch cleanup with preview before deletion.
Files changed
twig-cli/src/cli/tidy.rs(new) - Tidy command implementationtwig-cli/src/cli/mod.rs- Command registration