fix(utils): getGitRepoRoot should convert MSYS/Git-Bash paths on Windows#12269
Open
ATKasem wants to merge 1 commit into
Open
fix(utils): getGitRepoRoot should convert MSYS/Git-Bash paths on Windows#12269ATKasem wants to merge 1 commit into
ATKasem wants to merge 1 commit into
Conversation
✅ [V2]Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
On Windows under Git Bash / MSYS, `git rev-parse --show-toplevel` returns a POSIX-style drive path such as `/p/projets/my-repo`. `getGitRepoRoot` passed this straight to `fs.realpath.native`, and Node interprets the leading `/p/` as relative to the current drive root, resolving it to `P:\p\projets\my-repo`. That makes `realpath` throw `ENOENT` and breaks the build (reachable via the eager Git VCS logic, `future.faster.gitEagerVcs`). Convert MSYS drive paths (`/c/...` -> `C:\...`) before resolving, gated on `process.platform === 'win32'` so real POSIX paths on macOS/Linux are untouched. Closes facebook#11920
d598e07 to
aff6e19
Compare
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.
Pre-flight checklist
Motivation
Fixes #11920.
On Windows under Git Bash / MSYS,
git rev-parse --show-toplevelreturns a POSIX-style drive path such as/p/projets/my-repo.getGitRepoRoot(packages/docusaurus-utils/src/vcs/gitUtils.ts) passes that string directly tofs.realpath.native. Node interprets the leading/p/as relative to the current drive root and resolves it toP:\p\projets\my-repo, sorealpaththrows:and the build fails. This is reachable through the eager Git VCS logic (
future.faster.gitEagerVcs).Test Plan
Fix: convert MSYS/Git-Bash POSIX drive paths (
/c/...→C:\...) to native Windows paths before resolving, via a small pure helpergitPosixDrivePathToWindows. It's applied ingetGitRepoRootonly whenprocess.platform === 'win32', so real POSIX paths on macOS/Linux are untouched.New unit tests in
gitUtils.test.tscover the helper:/p/projets/my-repo→P:\projets\my-repo,/c/Users/me/website→C:\Users\me\website/d/→D:\C:/already/windows) and non-drive-mount POSIX paths (/home/user/repo,/usr/local/lib) pass through unchangedThe existing
getGitRepoRootsuite still passes (44 tests total).pnpm build(tsc) and ESLint are clean.Test links
n/a — internal Git path handling, no UI change.
Deploy preview: n/a