fix: resolve worktree root before removal in monorepos#61
Merged
matej21 merged 2 commits intocontember:mainfrom Mar 27, 2026
Merged
fix: resolve worktree root before removal in monorepos#61matej21 merged 2 commits intocontember:mainfrom
matej21 merged 2 commits intocontember:mainfrom
Conversation
In monorepo setups the project path points to a subdirectory inside the worktree checkout (e.g. /repo-wt-branch/app), causing `git worktree remove` to fail with "is not a working tree". Use `get_repo_root()` to resolve the actual worktree root before passing it to the remove command. Closes contember#60 Co-Authored-By: Claude Code
There was a problem hiding this comment.
Pull request overview
Fixes worktree close failures in monorepo setups by ensuring git worktree remove is called with the actual worktree root (instead of a subdirectory project path).
Changes:
- Resolve the git repo/worktree root via
okena_git::get_repo_root()before determining branch and removing the worktree. - Fall back to
project.pathwhen the repo root cannot be resolved.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Verify that get_repo_root correctly resolves the worktree root (not a subdirectory) when called from a nested path inside a worktree. This covers the monorepo worktree removal fix. Co-Authored-By: Claude Code
4 tasks
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
project.pathpoints to a subdirectory inside the worktree (e.g./repo-wt-branch/app), not the worktree rootget_repo_root()(git rev-parse --show-toplevel) to resolve the actual worktree root before passing it togit worktree removeCloses #60
Test plan
Co-Authored-By: Claude Code