Skip to content

chore: cleanup-branches task + gitignored mise task split - #267

Merged
getappz merged 4 commits into
masterfrom
chore/cleanup-branches-script
Jul 19, 2026
Merged

getappz merged 4 commits into
masterfrom
chore/cleanup-branches-script

Conversation

@getappz

@getappz getappz commented Jul 19, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Add cleanup:branches mise task + scripts/cleanup-branches.sh to delete local branches/worktrees already merged into origin/master
  • Move mise tasks out of tracked mise.toml/mise.local.toml into a gitignored .mise.toml (root) + .mise/tasks/*.toml (split via task_config.includes), since these are personal dev-workflow shortcuts, not shared project config
  • Replace the stale refresh-install flow (worktree detection + cargo install --path --force) with: pull master, then run agentflare dev-install

Test plan

  • mise tasks lists all 4 tasks correctly from the split included files
  • mise tasks info release resolves to .mise/tasks/release.toml
  • Ran agentflare dev-install end-to-end against updated master, confirmed via agentflare --version

Summary by CodeRabbit

  • New Features
    • Added a command-line utility to clean up merged local Git branches, including optional worktree cleanup and a preview-only dry run.
    • Optionally deletes merged remote branches after local cleanup.
  • Chores
    • Updated local configuration to remove the obsolete installation refresh task.
    • Removed the prior installation refresh script.
    • Removed release workflow task definitions.
    • Updated ignore rules for local “mise” runtime/config directories.

…nstall flow

Tasks now live in .mise.toml + .mise/tasks/*.toml (split via task_config.includes),
gitignored since they're personal dev-workflow shortcuts, not shared project config.
refresh-install now pulls master and runs 'agentflare dev-install' instead of the
old worktree-detection + cargo install --path --force script.
@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: 5bc4a359-40f7-4e79-a600-0af4a8b14018

📥 Commits

Reviewing files that changed from the base of the PR and between d8b4b3d and cce6971.

📒 Files selected for processing (1)
  • scripts/cleanup-branches.sh
🚧 Files skipped from review as they are similar to previous changes (1)
  • scripts/cleanup-branches.sh

📝 Walkthrough

Walkthrough

Adds branch and worktree cleanup automation with protected-branch checks, merge-base safety verification, dry-run support, and optional remote deletion. Removes obsolete mise tasks and the refresh-install script, and ignores local mise configuration.

Changes

Branch cleanup automation

Layer / File(s) Summary
Cleanup entrypoint and safeguards
scripts/cleanup-branches.sh, .gitignore
Defines cleanup options, protected branches, repository context, and ignored local mise state.
Candidate branch discovery
scripts/cleanup-branches.sh
Fetches pruned refs, maps worktrees, and combines deleted-upstream and merged-branch candidates.
Local and remote cleanup
scripts/cleanup-branches.sh
Verifies candidates against the default branch before removing worktrees and local branches, prunes metadata, and optionally deletes remote branches.
Mise configuration cleanup
mise.local.toml, mise.toml, scripts/refresh-install.ps1
Removes obsolete refresh-install, release, and release-watch tasks and deletes the refresh-install script.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant CleanupScript
  participant LocalGit
  participant RemoteGit
  User->>CleanupScript: Run cleanup options
  CleanupScript->>LocalGit: Fetch and inspect branches and worktrees
  LocalGit-->>CleanupScript: Return cleanup candidates
  CleanupScript->>LocalGit: Verify and remove eligible worktrees and branches
  CleanupScript->>RemoteGit: Delete merged remote branches when --remote is set
  CleanupScript-->>User: Report cleanup results
Loading

Suggested labels: tech-debt

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change set: a cleanup-branches task plus mise task restructuring.
Description check ✅ Passed The description covers the summary and test plan, but omits the reviewer notes section from the template.
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 chore/cleanup-branches-script

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
scripts/cleanup-branches.sh (1)

47-50: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

awk $2 truncates worktree paths containing spaces.

$2 in awk splits on whitespace, so a worktree path like /Users/foo/my projects would be captured as /Users/foo/my. Use substr($0, 10) to capture the full path after the worktree prefix.

♻️ Proposed fix for paths with spaces
 done < <(git worktree list --porcelain | awk '
-  /^worktree /{p=$2}
+  /^worktree /{p=substr($0, 10)}
   /^branch /{print p; print $2}
 ')
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/cleanup-branches.sh` around lines 47 - 50, Update the awk processing
in the worktree-list input to extract worktree paths with substr($0, 10) when
handling /^worktree /, rather than using $2; keep branch extraction unchanged so
paths containing spaces are passed intact.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scripts/cleanup-branches.sh`:
- Around line 96-107: Update the remote-branch loop in the DO_REMOTE cleanup
block to call is_protected with each normalized branch name after removing the
origin/ prefix. Skip every protected branch, including DEFAULT_BRANCH, main, and
CURRENT_BRANCH, while preserving the existing HEAD exclusion and deletion
behavior for unprotected branches.

---

Nitpick comments:
In `@scripts/cleanup-branches.sh`:
- Around line 47-50: Update the awk processing in the worktree-list input to
extract worktree paths with substr($0, 10) when handling /^worktree /, rather
than using $2; keep branch extraction unchanged so paths containing spaces are
passed intact.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: f59e4a8b-2ea6-45e9-b1f4-a57351ec0e02

📥 Commits

Reviewing files that changed from the base of the PR and between d3ce544 and 26a67f6.

📒 Files selected for processing (5)
  • .gitignore
  • mise.local.toml
  • mise.toml
  • scripts/cleanup-branches.sh
  • scripts/refresh-install.ps1
💤 Files with no reviewable changes (3)
  • mise.local.toml
  • mise.toml
  • scripts/refresh-install.ps1

Comment thread scripts/cleanup-branches.sh
…branch or its worktree

git branch -D has no merge check, and the [gone] heuristic (needed since
squash-merges break plain ancestry checks) doesn't guarantee the local
branch's content actually matches what got merged -- a branch with an
extra unpushed commit past what was squash-merged would be silently
destroyed. Compare the branch's touched files against
origin/ before removing either its worktree or its ref;
skip with a warning if they differ. Verified against a sandboxed repo:
a clean squash-merged branch still deletes, one with an unpushed
follow-up commit is now left alone (ref and worktree both).

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@scripts/cleanup-branches.sh`:
- Around line 79-96: Move the merge-base and touched-file safety verification
using merge_base and touched before the --dry-run reporting in
scripts/cleanup-branches.sh. Ensure dry-run outputs “would remove” only for
candidates that pass these checks, while preserving skip messages and leaving
verified branches untouched during dry-run.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 9d0e84fb-60ad-4f06-a7b9-cd1b5b889e05

📥 Commits

Reviewing files that changed from the base of the PR and between 26a67f6 and d8b4b3d.

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

Comment thread scripts/cleanup-branches.sh
getappz added 2 commits July 19, 2026 23:49
…g too

--dry-run was reporting every candidate as removable before the
content-diff safety check ran, so it could claim 'would delete' for a
branch the real run would actually skip for possible unpushed work.
Move the check ahead of the DRY_RUN branch so the preview matches
real behavior.
@getappz
getappz merged commit 5003210 into master Jul 19, 2026
16 checks passed
@getappz
getappz deleted the chore/cleanup-branches-script branch July 19, 2026 18:56
getappz added a commit that referenced this pull request Jul 25, 2026
…#322)

remove_worktree_dir's existing retry loop and cmd /c rmdir fallback
both only clear a transient in-use lock (e.g. item #302's rust-analyzer
case). Neither touches a genuine ACL denial, which is item #267's
actual failure mode: cargo's own target/*/.fingerprint/* files can end
up ACL-restricted, not merely open, and no amount of retrying clears
that.

Adds one more fallback before giving up: icacls /grant <user>:F /T
resets ownership access recursively, then one final remove_dir_all
attempt. No-op (and thus never destructive) when the real problem was
actually an in-use lock the earlier retries already cleared.

Considered switching to git-parsec's shared_cache symlink strategy
instead (share target/ across worktrees so there's nothing per-worktree
to get ACL-locked in the first place) -- rejected: this codebase
already hit and fixed the exact correctness bug that would reintroduce
(item #139, cargo #12516/#14053/#7740 -- a shared CARGO_TARGET_DIR's
fingerprint hash omits the worktree path, so two worktrees of different
branches silently reuse each other's stale local crate artifacts).
isolate_worktree_target_dir's per-worktree isolation is deliberate, not
an oversight; sccache (item #133) already covers the safe part of
cross-worktree cache sharing (registry deps, hash-keyed).

Agentflare-Agent: claude-code_2-1-219_agent
Agentflare-Branch: task/267
Agentflare-Item: 267
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