Skip to content

Conversation

@AwooOOoo
Copy link

@AwooOOoo AwooOOoo commented Jan 20, 2026

Summary

  • Fixed "This folder is not a git repository" error when opening valid git repos
  • Added getIsolatedGitEnv() to all git operations in project detection functions
  • Prevents GIT_DIR, GIT_WORK_TREE, and GIT_INDEX_FILE env var contamination from worktree operations

Problem

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.

Solution

Applied getIsolatedGitEnv() (which already existed in utils/git-isolation.ts) to 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

Test plan

  • Opened a valid git repository that previously showed "not a git repository" error
  • Verified the repository is now correctly detected
  • Tested with npm run dev

I have read the CLA Document and I hereby sign the CLA

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced stability of Git-related features by implementing isolated Git environments for all repository interactions. This ensures proper isolation of environment variables and worktree configurations when performing operations such as branch detection, project initialization, fetching repository information, and committing changes. These improvements increase overall reliability of all Git operations throughout the application.

✏️ Tip: You can customize this high-level summary in your review settings.

…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>
@CLAassistant
Copy link

CLAassistant commented Jan 20, 2026

CLA assistant check
All committers have signed the CLA.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @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 (GIT_DIR, GIT_WORK_TREE, GIT_INDEX_FILE) leaking from worktree contexts. By consistently applying an isolated Git environment to all Git commands involved in project detection and initialization, the system can now correctly identify and interact with Git repositories, eliminating previous false negatives.

Highlights

  • Git Environment Isolation: Implemented getIsolatedGitEnv() across all relevant Git operations to prevent environment variable contamination from Git worktrees.
  • Bug Fix: Resolved the 'This folder is not a git repository' error that occurred when opening valid Git repositories, particularly in worktree contexts.
  • Improved Reliability: Ensured consistent and accurate Git repository detection, branch listing, and initialization by isolating Git command environments.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 20, 2026

📝 Walkthrough

Walkthrough

This 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

Cohort / File(s) Summary
Git environment isolation
apps/frontend/src/main/ipc-handlers/project-handlers.ts, apps/frontend/src/main/project-initializer.ts
Imports getIsolatedGitEnv and applies isolated environment to all Git subprocess executions (branch queries, HEAD detection, repository initialization, status checks) to prevent contamination from worktrees or external environment variables

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

bug, area/frontend, size/M

Suggested reviewers

  • AndyMik90
  • AlexMadera

Poem

🐰 Hops through repos clean and bright,
No worktrees tangled in the night,
Isolation keeps our Git so pure,
Environment vars now safe and sure!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main objective of the PR: using isolated git environment to prevent worktree contamination during project/repo detection.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@github-actions github-actions bot left a 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!

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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.

@sentry
Copy link

sentry bot commented Jan 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@StillKnotKnown StillKnotKnown self-assigned this Jan 20, 2026
@AndyMik90 AndyMik90 force-pushed the develop branch 2 times, most recently from 67a743f to e83e445 Compare January 21, 2026 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants