fix(cmd): detach worktrees before pool reuse#19
Merged
Conversation
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.
Summary
treehouse return --forcerecover conflicted or dirty worktrees through forced cleanup instead of failing before reset.--forcecleanup behavior explicit, with e2e coverage for the detach and forced-return cases.Risk Assessment
✅ Low: The change is narrowly scoped to detaching worktree HEADs before reuse/return and adds focused regression coverage, with no material issues found in the changed code.
Testing
go test ./cmdgo test ./cmd -run 'Test(GetDetachesWorktreeWhenLeavingDirty|ReturnForceCleansAndDetachesCheckedOutBranch|ReturnForceCleansConflictedWorktree)$' -count=1go test ./... -count=1Pipeline
Updates from git push no-mistakes
✅ **Rebase** - passed
Round 1 - passed ✅
🔧 **Review** - 1 issue found → auto-fixed
Round 1 - found 1 error
cmd/return_cmd.go:47-treehouse return --forcenow runs a non-forcedgit checkout --detachbefore cleanup. A dirty worktree with an unmerged/conflicted index can make this detach fail beforepool.ReleasereachesResetWorktree's forced checkout/reset, so--forcecan no longer recover and clean that state. Move the detach until after the non-force confirmation, or let the forced reset path handle detaching for--force.Round 2 (auto-fix) - passed ✅
✅ **Test** - passed
Round 1 - passed ✅
go test ./cmdgo test ./cmd -run 'Test(GetDetachesWorktreeWhenLeavingDirty|ReturnForceCleansAndDetachesCheckedOutBranch|ReturnForceCleansConflictedWorktree)$' -count=1go test ./... -count=1🔧 **Document** - 1 issue found → auto-fixed (2)
Round 1 - found 1 info
README.md:151- Thereturn --forcedocumentation still describes the flag only as skipping the dirty-check prompt, but the changed behavior now force-detaches and hard-resets/cleans worktrees so it can recover checked-out branches and conflicted states. Update the flag description to make the destructive cleanup behavior explicit, such as noting that it cleans/resets the worktree and returns it without prompting.Round 2 (auto-fix) - found 1 info
cmd/return_cmd.go:74- The Cobra help text fortreehouse return --forcestill saysSkip dirty check prompt, but the changed behavior now force-cleans/resets and detaches the worktree before returning it. Update the flag description used bytreehouse return --helpso the built-in CLI documentation matches the README and the new destructive cleanup behavior.Round 3 (auto-fix) - passed ✅
✅ **Lint** - passed
Round 1 - passed ✅
✅ **Push** - passed
Round 1 - passed ✅