forked from cline/cline
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
fix(checkpoints): resolve incorrect commit location when GIT_DIR set in Dev Containers #8811
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
Merged
mrubens
merged 2 commits into
RooCodeInc:main
from
heyseth:fix/checkpoints-commit-to-wrong-repo-when-GIT_DIR-set-in-dev-containers
Nov 5, 2025
+151
−3
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -823,6 +823,69 @@ describe.each([[RepoPerTaskCheckpointService, "RepoPerTaskCheckpointService"]])( | |
| // File should be back to original state | ||
| expect(await fs.readFile(testFile, "utf-8")).toBe("Hello, world!") | ||
| }) | ||
|
|
||
| it("isolates checkpoint operations from GIT_DIR environment variable", async () => { | ||
| // This test verifies the fix for the issue where GIT_DIR environment variable | ||
| // causes checkpoint commits to go to the wrong repository | ||
|
|
||
| // Create a separate git directory to simulate GIT_DIR pointing elsewhere | ||
| const externalGitDir = path.join(tmpDir, `external-git-${Date.now()}`) | ||
| await fs.mkdir(externalGitDir, { recursive: true }) | ||
| const externalGit = simpleGit(externalGitDir) | ||
| await externalGit.init() | ||
| await externalGit.addConfig("user.name", "External User") | ||
| await externalGit.addConfig("user.email", "[email protected]") | ||
|
|
||
| // Create and commit a file in the external repo | ||
| const externalFile = path.join(externalGitDir, "external.txt") | ||
| await fs.writeFile(externalFile, "External content") | ||
| await externalGit.add(".") | ||
| await externalGit.commit("External commit") | ||
|
|
||
| // Store the original commit count in the external repo | ||
| const externalLogBefore = await externalGit.log() | ||
| const externalCommitCountBefore = externalLogBefore.total | ||
|
|
||
| // Set GIT_DIR to point to the external repository | ||
| const originalGitDir = process.env.GIT_DIR | ||
| const externalDotGit = path.join(externalGitDir, ".git") | ||
| process.env.GIT_DIR = externalDotGit | ||
|
|
||
| try { | ||
| // Make a change in the workspace and save a checkpoint | ||
| await fs.writeFile(testFile, "Modified with GIT_DIR set") | ||
| const commit = await service.saveCheckpoint("Checkpoint with GIT_DIR set") | ||
| expect(commit?.commit).toBeTruthy() | ||
|
|
||
| // Verify the checkpoint was saved in the shadow repo, not the external repo | ||
| const externalLogAfter = await externalGit.log() | ||
| const externalCommitCountAfter = externalLogAfter.total | ||
|
|
||
| // External repo should have the same number of commits (no new commits) | ||
| expect(externalCommitCountAfter).toBe(externalCommitCountBefore) | ||
|
|
||
| // Verify the checkpoint is accessible in the shadow repo | ||
| const diff = await service.getDiff({ to: commit!.commit }) | ||
| expect(diff).toHaveLength(1) | ||
| expect(diff[0].paths.relative).toBe("test.txt") | ||
| expect(diff[0].content.after).toBe("Modified with GIT_DIR set") | ||
|
|
||
| // Verify we can restore the checkpoint | ||
| await fs.writeFile(testFile, "Another modification") | ||
| await service.restoreCheckpoint(commit!.commit) | ||
| expect(await fs.readFile(testFile, "utf-8")).toBe("Modified with GIT_DIR set") | ||
| } finally { | ||
| // Restore original GIT_DIR | ||
| if (originalGitDir !== undefined) { | ||
| process.env.GIT_DIR = originalGitDir | ||
| } else { | ||
| delete process.env.GIT_DIR | ||
| } | ||
|
|
||
| // Clean up external git directory | ||
| await fs.rm(externalGitDir, { recursive: true, force: true }) | ||
| } | ||
| }) | ||
| }) | ||
| }, | ||
| ) | ||
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.
Uh oh!
There was an error while loading. Please reload this page.