fix: prevent shadow git from inheriting global init.templateDir #8629
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.
Related GitHub Issue
Closes: #8628
Roo Code Task Context (Optional)
N/A - This PR was created to address the reported issue.
Description
This PR fixes an issue where shadow git repositories were unintentionally inheriting the user's global
init.templateDir
configuration, causing unwanted hooks (like pre-commit hooks) to be triggered in the shadow repository.Key implementation details:
initShadowGit()
inShadowCheckpointService.ts
to usegit init --template=
which explicitly prevents any template from being used--template=
flag ensures the shadow repository is created without any hooks or templatesTest Procedure
How I tested:
cd src && npx vitest run services/checkpoints/__tests__/ShadowCheckpointService.spec.ts
does not inherit global init.templateDir when creating shadow git repo
to verify the fixHow reviewers can verify:
cd src && npx vitest run services/checkpoints/__tests__/ShadowCheckpointService.spec.ts
Pre-Submission Checklist
Screenshots / Videos
N/A - This is a backend fix with no UI changes.
Documentation Updates
The fix is an internal implementation detail that doesn't affect the public API or user-facing functionality.
Additional Notes
This is a targeted fix that prevents potential security issues and unexpected behavior when users have pre-commit hooks or other git templates configured globally. The shadow repository should be isolated from user configurations to ensure consistent behavior.
Get in Touch
Available via GitHub for any questions about this PR.
Important
Fixes shadow git repositories inheriting global
init.templateDir
by modifyinginitShadowGit()
to usegit init --template=
and adds a test to verify no hooks are created.initShadowGit()
inShadowCheckpointService.ts
to usegit init --template=
to prevent inheriting globalinit.templateDir
.does not inherit global init.templateDir when creating shadow git repo
inShadowCheckpointService.spec.ts
to verify no executable hooks are created.This description was created by
for e012ece. You can customize this summary. It will automatically update as commits are pushed.