-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
fix: use isolated git env in project/repo detection to prevent worktree contamination #1363
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
fix: use isolated git env in project/repo detection to prevent worktree contamination #1363
Conversation
…ee contamination When Auto-Claude operates on git worktrees, environment variables like GIT_DIR, GIT_WORK_TREE, and GIT_INDEX_FILE can leak into subsequent git operations. This caused checkGitStatus() to incorrectly report "This folder is not a git repository" for valid git repos. Fixed by using getIsolatedGitEnv() for all git commands in: - checkGitStatus() - repo detection and commit checking - initializeGit() - git init and initial commit - getGitBranches() - branch listing - getCurrentGitBranch() - current branch detection - detectMainBranch() - main branch detection Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Summary of ChangesHello @AwooOOoo, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a critical issue where Git operations were being affected by environment variables ( Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
📝 WalkthroughWalkthroughThis PR introduces isolated Git environment usage across frontend Git operations to prevent worktree and environment variable contamination. Changes apply to Git commands in project handlers and project initializer without altering public APIs or return values. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 Thanks for your first PR!
A maintainer will review it soon. Please make sure:
- Your branch is synced with
develop - CI checks pass
- You've followed our contribution guide
Welcome to the Auto Claude community!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request addresses a bug where git environment variables could leak from worktree operations and affect subsequent git commands. The fix involves using getIsolatedGitEnv() for all git operations related to project and repository detection, ensuring a clean environment for each command. The changes are applied consistently across multiple functions in project-handlers.ts and project-initializer.ts. My review includes one suggestion to improve code consistency and avoid a redundant function call in checkGitStatus.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
67a743f to
e83e445
Compare
Summary
getIsolatedGitEnv()to all git operations in project detection functionsProblem
When Auto-Claude operates on git worktrees, environment variables like
GIT_DIR,GIT_WORK_TREE, andGIT_INDEX_FILEcan leak into subsequent git operations. This causedcheckGitStatus()to incorrectly report "This folder is not a git repository" for valid git repos.Solution
Applied
getIsolatedGitEnv()(which already existed inutils/git-isolation.ts) to all git commands in:checkGitStatus()- repo detection and commit checkinginitializeGit()- git init and initial commitgetGitBranches()- branch listinggetCurrentGitBranch()- current branch detectiondetectMainBranch()- main branch detectionTest plan
npm run devI have read the CLA Document and I hereby sign the CLA
🤖 Generated with Claude Code
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.