Repository navigation
fix: finish cleanup before workspace closure - #59
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
✅ No new issues found.
Approach: sound — making workspace closure the final operation prevents caller termination from interrupting essential cleanup while preserving detached bulk deletion.
Reviewed changes cover removal sequencing, error handling, regression coverage, and the lifecycle specification.
- Cleanup ordering: Git metadata, routes, ports, and post-remove hooks are handled before workspace closure.
- Close failures: Errors explicitly distinguish a failed workspace close from completed worktree removal.
- Regression coverage: Unit assertions and a caller-killing E2E test verify cleanup and branch reuse; specification traceability includes the new scenario.
- Verification:
mise exec -- go test ./internal/worktree ./e2epassed.
gpt-6.1-sol | 𝕏
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.

Motivation
Removing a worktree from its own workspace could kill HWT before it cleared Git's worktree record. Reviewing the same PR again then failed with a stale-worktree error.
Changes
Finish metadata cleanup, release ports and routes, and run post-remove hooks before closing the workspace. Keep bulk deletion detached.
Testing
Remove a clean review worktree from its own workspace, then review the same PR again. It should reopen without manual Git repair. A compiled-binary regression test kills HWT at workspace closure and checks that the same branch can be reopened.
Dependencies
None.