fix(codegen): handle git worktrees correctly when detecting git roots#5302
Open
thehowl wants to merge 2 commits intognolang:masterfrom
Open
fix(codegen): handle git worktrees correctly when detecting git roots#5302thehowl wants to merge 2 commits intognolang:masterfrom
thehowl wants to merge 2 commits intognolang:masterfrom
Conversation
Use `git rev-parse --show-toplevel` as the primary mechanism for finding the git root directory, falling back to the existing parent-directory walk when the git command is unavailable. The command-based approach correctly handles git worktrees, where the `.git` entry is a file (not a directory) pointing to the worktree metadata rather than the repo root. https://claude.ai/code/session_011dNYdysBmW5maTxqEVdxiz
Collaborator
🛠 PR Checks SummaryAll Automated Checks passed. ✅ Manual Checks (for Reviewers):
Read More🤖 This bot helps streamline PR reviews by verifying automated checks and providing guidance for contributors and reviewers. ✅ Automated Checks (for Contributors):🟢 Maintainers must be able to edit this pull request (more info) ☑️ Contributor Actions:
☑️ Reviewer Actions:
📚 Resources:Debug
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
Updated git root detection logic in two locations to properly handle git worktrees by using
git rev-parse --show-toplevelas the primary method, with a fallback to the existing directory walking approach.Key Changes
findDirs()to first attemptgit rev-parse --show-toplevelbefore falling back to walking up parent directories looking for.gitgitRoot()to use the samegit rev-parse --show-toplevelapproach with fallback to the original directory walking logicImplementation Details
git rev-parse --show-toplevelcorrectly resolves the actual git repository root even when working in a git worktree, whereas walking up directories from the current working directory may notThis was an attempt to using claude code on web; but while good it seems to me it does too much of a self-promotion on itself (placing the session link in all of the commits). Still, the change is good and will help anyone who wants to use these in worktrees, considering also that they're becoming more ubiquitous with coding agents.