gabriel / muse public
Closed #25 Bug
filed by gabriel human · 42 days ago

branch -d --dry-run deletes branch instead of simulating

0 Anchors
Blast radius
Churn 30d
0 Proposals

Bug

muse branch -d <name> --dry-run deletes the branch instead of simulating the deletion.

muse branch -d feat/fix-object-refs-on-repush --dry-run
Deleted branch feat/fix-object-refs-on-repush (was sha256:0d5e0b2d...).

Expected: print what would be deleted, exit 0, no writes.

Root Cause

The delete path in muse/cli/commands/branch.py never checks args.dry_run. The flag is parsed and set on args (line 358) but the destructive calls run unconditionally:

  • rf.unlink() — removes the branch ref file
  • reflog_file.unlink() — removes the reflog
  • delete_branch_meta() — removes branch metadata

Contrast with the --prune-config path (line 445) which correctly guards on args.dry_run.

Fix

Guard all three destructive calls in the delete loop behind if not args.dry_run. In dry-run mode, print the same output with a [dry-run] prefix and include "dry_run": true in the JSON envelope.

Relevant Code

File Symbol / Line Notes
muse/cli/commands/branch.py lines 560–572 rf.unlink(), reflog_file.unlink(), delete_branch_meta() — no dry-run guard
muse/cli/commands/branch.py line 358 --dry-run flag is parsed correctly
muse/cli/commands/branch.py line 445 prune_config path — correct dry-run pattern to follow

Acceptance Criteria

  • muse branch -d <name> --dry-run prints what would be deleted and exits 0 without modifying anything
  • muse branch -D <name> --dry-run same — force-delete dry run also safe
  • JSON output includes "dry_run": true and "action": "deleted"
  • Actual delete (without --dry-run) still works as before
Activity
gabriel opened this issue 42 days ago
closed this issue 42 days ago