fix(project): use "/" as global project worktree when git has no commits#23220
Open
sim590 wants to merge 11 commits intoanomalyco:devfrom
Open
fix(project): use "/" as global project worktree when git has no commits#23220sim590 wants to merge 11 commits intoanomalyco:devfrom
sim590 wants to merge 11 commits intoanomalyco:devfrom
Conversation
Quand git init est exécuté dans un répertoire sans validation, fromDirectory() retombait sur ProjectID.global avec worktree=sandbox au lieu de worktree="/". L'upsert Phase 2 écrasait alors le worktree du projet global existant, corrompant toutes les sessions globales. Refs: anomalyco#21230
Contributor
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Issue for this PR
Fixes #23221
Related: #21230
Type of change
What does this PR do?
When
fromDirectory()encounters a Git repository with no commits (git rev-list --max-parents=0 HEADfails), it correctly falls back toProjectID.globalbut setsworktreeto the current directory (sandbox) instead of"/".This causes the Phase 2 upsert to overwrite the global project's
worktreein the database with a directory-specific path. The global project should always haveworktree="/"by definition — the specific directory is already captured insandboxand added to thesandboxeslist.The corruption is transient: it resolves the next time
fromDirectory()is called from a non-git directory (which resetsworktreeback to"/"). The practical impact is limited, but the metadata should remain consistent regardless.The fix is a one-line change in
project.ts(line 234):worktree: sandbox→worktree: "/".How did you verify your code works?
fromDirectory()on a non-git directory (creates global project withworktree="/"), then callsfromDirectory()on agit initdirectory without commits, and checks the database. Before the fix,worktreeis overwritten with the directory path. After the fix, it stays"/".git init without commits must not overwrite global worktree) that encodes this scenario.worktree: tmp.pathto expectworktree: "/"for the no-commits fallback.Screenshots / recordings
Not a UI change.
Checklist