Fix checkout workspace opening for Windows drive roots#43
Conversation
📝 WalkthroughWalkthroughCheckout workspace root setup now goes through a shared helper that checks the path first, creates it only when missing, and returns the resulting directory stats. The test suite adds coverage for the existing-directory case. ChangesCheckout workspace root handling
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/workspaces.test.ts (1)
50-63: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd coverage for the ENOENT creation branch.
This block verifies the existing-directory path (
mkdirnot called), but the actual fix logic —statfailing withENOENT, thenmkdir(..., { recursive: true })being invoked and a re-statreturning the created directory — is untested. Consider a sibling case where the mockedstatfirst throws anENOENT-coded error and assertsmkdirCalls === 1, plus one asserting a non-ENOENTerror is rethrown without callingmkdir.🧪 Example additional test case
+ { + let mkdirCalls = 0; + const missing = join(root, "nested-missing-root"); + const createdStats = await ensureCheckoutWorkspaceRoot(missing, { + stat: (() => { + let calls = 0; + return async (path: string) => { + assert.equal(path, missing); + calls += 1; + if (calls === 1) { + const err = new Error("missing") as NodeJS.ErrnoException; + err.code = "ENOENT"; + throw err; + } + return await stat(path); + }; + })(), + mkdir: async (path) => { + assert.equal(path, missing); + mkdirCalls += 1; + await mkdir(path, { recursive: true }); + }, + }); + assert.equal(createdStats.isDirectory(), true); + assert.equal(mkdirCalls, 1); + }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/workspaces.test.ts` around lines 50 - 63, Add test coverage for the ENOENT branch in ensureCheckoutWorkspaceRoot: create a sibling case where the mocked stat first throws an error with code ENOENT, then verify mkdir is called once with recursive behavior and that the subsequent re-stat returns the created directory. Also add a negative case in the same test file to confirm a non-ENOENT stat error is rethrown and mkdir is not called, using the existing ensureCheckoutWorkspaceRoot helper and its stat/mkdir mocks.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/workspaces.test.ts`:
- Around line 50-63: Add test coverage for the ENOENT branch in
ensureCheckoutWorkspaceRoot: create a sibling case where the mocked stat first
throws an error with code ENOENT, then verify mkdir is called once with
recursive behavior and that the subsequent re-stat returns the created
directory. Also add a negative case in the same test file to confirm a
non-ENOENT stat error is rethrown and mkdir is not called, using the existing
ensureCheckoutWorkspaceRoot helper and its stat/mkdir mocks.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 788ce9b6-cf06-44b7-ae3a-cb58ede2aad0
📒 Files selected for processing (2)
src/workspaces.test.tssrc/workspaces.ts
manual-qa-windows-drive-root-compressed.mp4 |
|
Manual QA recording attached. Local Windows testing for the drive-root checkout fix:
I also tried running the full ChatGPT + DevSpace |
Fixes Windows drive-root checkout workspace initialization.
This fixes a Windows-specific checkout workspace issue where opening an existing drive root such as
D:\orE:\can fail with:EPERM: operation not permitted, mkdir 'D:\'Root cause:
openCheckoutWorkspace()calledmkdir(root, { recursive: true })before checking whether the path already existed. That is unnecessary for existing paths and can fail for Windows drive roots.What changed:
ensureCheckoutWorkspaceRoot()stat()is now attempted firstmkdir(..., { recursive: true })is only called whenstat()fails withENOENTmkdir()Validation:
npm run testnpm run typechecknpm run buildManual QA:
A short Windows manual QA recording will be attached in the PR discussion.
Summary by CodeRabbit