Skip to content

fix(scripts): don't run git worktree prune under --dry-run - #272

Merged
getappz merged 2 commits into
masterfrom
fix/cleanup-branches-prune-dry-run
Jul 19, 2026
Merged

fix(scripts): don't run git worktree prune under --dry-run#272
getappz merged 2 commits into
masterfrom
fix/cleanup-branches-prune-dry-run

Conversation

@getappz

@getappz getappz commented Jul 19, 2026

Copy link
Copy Markdown
Owner

Summary

cleanup-branches.sh --dry-run is documented as "list what would be removed, change nothing", but the trailing git worktree prune ran unconditionally, outside the DRY_RUN gate everything else in the script respects.

Hit this live: running cleanup:branches --dry-run (via the mise MCP task runner) wiped .git/worktrees/<name>/ registration for ~29 worktrees in one shot on a Windows/Git-Bash checkout — git worktree prune apparently misjudged every present, unmodified worktree directory as stale. No data loss (prune only removes admin bookkeeping, never branches/commits/files), but every affected worktree now needs manual re-registration.

Fix

Gate the prune call behind the same ((DRY_RUN)) check as the rest of the script.

Test plan

  • bash -n scripts/cleanup-branches.sh — syntax OK
  • Manual read-through: git worktree remove (real-run path) already drops its own admin entry, so prune was only ever needed to sweep entries for worktrees removed some other way — never a --dry-run concern.

Summary by CodeRabbit

  • Bug Fixes
    • Dry-run cleanup operations no longer make destructive changes.
    • Branch cleanup now safely skips worktree pruning when previewing actions.

cleanup-branches.sh's dry-run mode is documented as 'list what would be
removed, change nothing', but the trailing git worktree prune call ran
unconditionally regardless of the flag. On at least one Windows/Git-Bash
setup, that prune misjudged every registered worktree as stale even
though their directories were all present and unmodified, wiping
.git/worktrees/<name>/ bookkeeping for ~29 worktrees from a single
--dry-run invocation. No branches, commits, or worktree files were lost
(prune only removes admin state), but every affected worktree needs
manual re-registration.

git worktree remove already drops the admin entry for anything it
actually removes, so prune only matters on a real (non-dry-run) pass.
@coderabbitai

coderabbitai Bot commented Jul 19, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 2a1c0c97-4de2-4935-92c6-cd8647d5fbda

📥 Commits

Reviewing files that changed from the base of the PR and between 2b47560 and 20e8935.

📒 Files selected for processing (1)
  • scripts/cleanup-branches.sh

📝 Walkthrough

Walkthrough

The branch cleanup script now skips the destructive git worktree prune operation when invoked with --dry-run, while retaining pruning for normal executions and updating inline comments.

Changes

Branch cleanup

Layer / File(s) Summary
Dry-run prune guard
scripts/cleanup-branches.sh
Adds a DRY_RUN condition around git worktree prune and updates comments describing its destructive behavior.

Estimated code review effort: 1 (Trivial) | ~3 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: preventing git worktree prune during dry-run cleanup.
Description check ✅ Passed The description covers Summary, Fix, and Test plan, with only the Notes for reviewers section missing.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/cleanup-branches-prune-dry-run

Comment @coderabbitai help to get the list of available commands.

@getappz
getappz merged commit 62a2828 into master Jul 19, 2026
16 checks passed
@getappz
getappz deleted the fix/cleanup-branches-prune-dry-run branch July 19, 2026 21:34
getappz added a commit that referenced this pull request Jul 28, 2026
…sk 9 provisioning (#354)

* feat(skill): finish EPIC #272 Task 6 write-path + Task 9 provisioning

Task 6 (proactive advisory): proactive_suggestions()/settings read-path
already existed (PR #302) but had no way to actually set a snooze or
dismiss - save_settings() was dead code. Add `skill snooze <name>
[--days N]` and `skill dismiss <name>` wired to it.

Task 9 (repo stack -> auto provisioning): new `skill provision <path>`
subcommand. Detects stack via manifest files (Cargo.toml/package.json/
tsconfig.json/pyproject.toml/requirements.txt/go.mod), ranks indexed
skills against it via BM25 search, prints a dry-run report (skills,
confidence, token cost) with zero DB writes, and on --yes re-tags the
matched entries under source "provisioned:<repo>" via the existing
scan+rebuild entry-creation path.

* fix(skill): address CodeRabbit findings on provision/snooze

- rank_candidates picked the highest bm25 score as "best" and sorted
  descending; bm25 is negative-is-better (search.rs sorts ASC on the
  same raw value), so this had it backwards. Flip to min-selection +
  ascending sort, add confidence_pct() for a bounded 0-100 display
  value instead of the broken score.min(1.0)*100.0.
- run_provision --yes rebuilt the DB from a fresh flat-dir scan only,
  and rebuild() is full-replace -- silently dropping any other
  provisioned:*/imported:*/hub:* DB-only rows on every run. Merge
  existing DB rows (via list_all_name_source_pairs + load, same
  reconstruction run_export already uses) before rebuilding, mirroring
  HubAction::Pull's merge-before-rebuild shape.
- Use crate::components::detected_skill_agents() instead of a
  hardcoded ["claude-code"] source list.
- snooze() clamped days to >=0 but not the upper bound; saturating_add
  from a large --days no longer risks i64 overflow.
- New adversarial rank_candidates test (two same-tag matches of
  different strength) -- the previous test had only one candidate per
  tag, so it couldn't have caught the sign inversion.
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