Repository navigation
feat(hooks): remove merged task worktrees and branches at session start - #185
Merged
Merged
Conversation
A branch goes only when a merged pull request's head is its tip and its worktree is clean, so squash merges count while later or uncommitted work stays. The primary checkout, the caller's worktree, and main are never touched. Open Herdr workspaces close with their checkout. The Claude SessionStart hook runs it asynchronously; --dry-run reports. Refs #181 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Cleanup now covers the caller's repository and each repository under ~/.herdr/worktrees, so a lane merged elsewhere goes at whichever session starts next. A failure in one repository skips only that repository. Refs #181 Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
PR 2 of #181. Merged task worktrees and local branches are removed without a person running
git branch -D.agents/hooks/cleanup_worktrees.py. A branch goes only when both hold:Squash merges therefore count as merged, while later or uncommitted work stays. The primary checkout, the caller's own worktree, and
main/masterare never touched. An open Herdr workspace is closed with its checkout (herdr worktree remove), and other worktrees usegit worktree remove.Scope. It sweeps the caller's repository and every repository with a Herdr task worktree under
~/.herdr/worktrees. A lane merged in one repository therefore goes at whichever session starts next. A failure in one repository skips only that repository.Triggers.
-D.cleanup_worktrees.py --dry-runreports what would go.gh pr list --state mergedcall), and Herdr. No gh-poi.branches.md. Tells agents not to delete merged worktrees by hand.Remote branches:
delete_branch_on_mergeis already on for the active repositories. It is off forobsidian(no PRs),book-agent,swe-bench-trial,revisiting-pgd-evaluation,pairs, and older learning repos. The agent App token cannot change repository settings, so that is left to the user.Closes #181
Verification
uv run --frozen pytest tests: 1498 passed. The 3 errors intests/hermes/test_hermes_gateway.pyalso occur on main.ghand Herdr. They cover:--dry-run;🤖 Generated with Claude Code