-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix: allow checkpoints with nested git repos by excluding them #8434
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
Conversation
- Modified ShadowCheckpointService to exclude nested git repos instead of disabling checkpoints - Added getNestedGitRepositories method to find all nested repos - Updated writeExcludeFile to add nested repos to exclude patterns - Added info messages to notify users when nested repos are excluded - Updated tests to reflect new behavior - Fixes #8433
| await git.addConfig("commit.gpgSign", "false") // Disable commit signing for shadow repo. | ||
| await git.addConfig("user.name", "Roo Code") | ||
| await git.addConfig("user.email", "[email protected]") | ||
| // Write exclude file which will include nested git repos |
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.
Typo/wording concern: The comment on line 101 says "Write exclude file which will include nested git repos", but based on the commit message, the intention is to exclude nested git repos. Please verify if "include" should be changed to "exclude" to maintain consistency.
| // Write exclude file which will include nested git repos | |
| // Write exclude file which will exclude nested git repos |
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.
Self-review activated: evaluating my own diff like a linter with trust issues.
| for (const gitPath of nestedGitPaths) { | ||
| const relativePath = path.relative(this.workspaceDir, gitPath) | ||
| // Add the directory and all its contents to exclude patterns | ||
| patterns.push(relativePath + "/") |
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.
P1: Normalize to POSIX-style separators before writing to exclude to ensure Git matching across platforms.
| patterns.push(relativePath + "/") | |
| const relativePath = path | |
| .relative(this.workspaceDir, gitPath) | |
| .split(path.sep) | |
| .join('/'); | |
| patterns.push(`${relativePath}/`) |
| this.log(`[${this.constructor.name}#writeExcludeFile] excluding nested git repo: ${relativePath}`) | ||
| } | ||
|
|
||
| await fs.writeFile(path.join(this.dotGitDir, "info", "exclude"), patterns.join("\n")) |
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.
P3: Add a trailing newline when writing .git/info/exclude for consistency with POSIX tools and Git defaults.
| await fs.writeFile(path.join(this.dotGitDir, "info", "exclude"), patterns.join("\n")) | |
| await fs.writeFile(path.join(this.dotGitDir, "info", "exclude"), patterns.join("\n") + "\n") |
| private async getNestedGitRepositories(): Promise<string[]> { | ||
| try { | ||
| // Find all .git/HEAD files that are not at the root level. | ||
| const args = ["--files", "--hidden", "--follow", "-g", "**/.git/HEAD", this.workspaceDir] |
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.
P2: This only finds nested repos with a .git directory containing HEAD; submodules/worktrees often have .git as a file pointing to a gitdir. Consider also detecting .git files and resolving their gitdir targets to exclude them.
Description
This PR fixes the issue where the checkpoint feature was completely disabled when nested git repositories were detected in the project. Instead of throwing an error and disabling checkpoints, the implementation now excludes nested git repositories from checkpoint tracking, allowing users to continue using checkpoints in projects with nested repos.
Changes
ShadowCheckpointServiceto exclude nested git repos instead of disabling checkpoints entirelygetNestedGitRepositorytogetNestedGitRepositoriesto find all nested repos (not just the first one)writeExcludeFileto add nested repos to the exclude patternsTesting
Related Issue
Fixes #8433
Type of Change
Checklist
Important
ShadowCheckpointServicenow excludes nested git repos from checkpoints, allowing main repo tracking, with updated tests and user notifications.ShadowCheckpointServicenow excludes nested git repos from checkpoints instead of disabling them.common.json.getNestedGitRepositorytogetNestedGitRepositoriesto handle multiple nested repos.writeExcludeFileto add nested repos to exclude patterns.ShadowCheckpointService.spec.tsto verify exclusion of nested repos.This description was created by
for a995d0e. You can customize this summary. It will automatically update as commits are pushed.