| ... | ... | @@ -1,4 +1,7 @@ |
| 1 | // @effect-diagnostics nodeBuiltinImport:off - realpathSync.native resolves Windows 8.3 short names, which the Effect realPath does not. |
| 2 | import * as NodeFS from "node:fs"; |
| 1 | 3 | import * as NodeServices from "@effect/platform-node/NodeServices"; |
| 4 | import { HostProcessPlatform } from "@t3tools/shared/hostProcess"; |
| 2 | 5 | import { assert, it, describe } from "@effect/vitest"; |
| 3 | 6 | import * as Deferred from "effect/Deferred"; |
| 4 | 7 | import * as Effect from "effect/Effect"; |
| ... | ... | @@ -570,7 +573,6 @@ it.effect("backs off failed upstream refreshes across linked worktrees", () => |
| 570 | 573 | const driver = yield* makeGitVcsDriverCore().pipe( |
| 571 | 574 | Effect.provideService(ChildProcessSpawner.ChildProcessSpawner, failingFetchSpawner), |
| 572 | 575 | ); |
| 573 | | const fileSystem = yield* FileSystem.FileSystem; |
| 574 | 576 | const cwd = yield* makeTmpDir(); |
| 575 | 577 | const remote = yield* makeTmpDir("git-vcs-driver-remote-"); |
| 576 | 578 | const worktreesRoot = yield* makeTmpDir("git-vcs-driver-worktrees-"); |
| ... | ... | @@ -606,9 +608,11 @@ it.effect("backs off failed upstream refreshes across linked worktrees", () => |
| 606 | 608 | "rev-parse", |
| 607 | 609 | "--git-common-dir", |
| 608 | 610 | ])).stdout.trim(); |
| 611 | // Native realpath, since git reports the long form of a directory the |
| 612 | // temp dir may name by its 8.3 short form on Windows. |
| 609 | 613 | assert.equal( |
| 610 | | yield* fileSystem.realPath(pathService.resolve(cwd, rootCommonDir)), |
| 611 | | yield* fileSystem.realPath(pathService.resolve(worktreePath, linkedCommonDir)), |
| 614 | NodeFS.realpathSync.native(pathService.resolve(cwd, rootCommonDir)), |
| 615 | NodeFS.realpathSync.native(pathService.resolve(worktreePath, linkedCommonDir)), |
| 612 | 616 | ); |
| 613 | 617 | yield* Ref.set(fetchAttempts, 0); |
| 614 | 618 | |
| ... | ... | @@ -1376,31 +1380,33 @@ it.layer(TestLayer)("GitVcsDriver core integration", (it) => { |
| 1376 | 1380 | }); |
| 1377 | 1381 | |
| 1378 | 1382 | describe("worktree operations", () => { |
| 1379 | | it.effect("preserves newline characters in worktree paths when listing refs", () => |
| 1380 | | Effect.gen(function* () { |
| 1381 | | const cwd = yield* makeTmpDir(); |
| 1382 | | yield* initRepoWithCommit(cwd); |
| 1383 | | const worktreesRoot = yield* makeTmpDir("git-vcs-driver-worktrees-"); |
| 1384 | | const fileSystem = yield* FileSystem.FileSystem; |
| 1385 | | const pathService = yield* Path.Path; |
| 1386 | | const worktreePath = pathService.join(worktreesRoot, "linked\nworktree"); |
| 1387 | | const driver = yield* GitVcsDriver.GitVcsDriver; |
| 1383 | // NTFS rejects a newline in a file name, so there is nothing to preserve there. |
| 1384 | it.effect.skipIf(HostProcessPlatform.defaultValue() === "win32")( |
| 1385 | "preserves newline characters in worktree paths when listing refs", |
| 1386 | () => |
| 1387 | Effect.gen(function* () { |
| 1388 | const cwd = yield* makeTmpDir(); |
| 1389 | yield* initRepoWithCommit(cwd); |
| 1390 | const worktreesRoot = yield* makeTmpDir("git-vcs-driver-worktrees-"); |
| 1391 | const pathService = yield* Path.Path; |
| 1392 | const worktreePath = pathService.join(worktreesRoot, "linked\nworktree"); |
| 1393 | const driver = yield* GitVcsDriver.GitVcsDriver; |
| 1388 | 1394 | |
| 1389 | | yield* git(cwd, ["worktree", "add", "-b", "feature/newline-path", worktreePath]); |
| 1395 | yield* git(cwd, ["worktree", "add", "-b", "feature/newline-path", worktreePath]); |
| 1390 | 1396 | |
| 1391 | | const refs = yield* driver.listRefs({ cwd, refresh: true }); |
| 1392 | | const listedPath = refs.refs.find( |
| 1393 | | (ref) => ref.name === "feature/newline-path", |
| 1394 | | )?.worktreePath; |
| 1397 | const refs = yield* driver.listRefs({ cwd, refresh: true }); |
| 1398 | const listedPath = refs.refs.find( |
| 1399 | (ref) => ref.name === "feature/newline-path", |
| 1400 | )?.worktreePath; |
| 1395 | 1401 | |
| 1396 | | if (typeof listedPath !== "string") { |
| 1397 | | return assert.fail("expected the linked branch to include its worktree path"); |
| 1398 | | } |
| 1399 | | assert.equal( |
| 1400 | | yield* fileSystem.realPath(listedPath), |
| 1401 | | yield* fileSystem.realPath(worktreePath), |
| 1402 | | ); |
| 1403 | | }), |
| 1402 | if (typeof listedPath !== "string") { |
| 1403 | return assert.fail("expected the linked branch to include its worktree path"); |
| 1404 | } |
| 1405 | assert.equal( |
| 1406 | NodeFS.realpathSync.native(listedPath), |
| 1407 | NodeFS.realpathSync.native(worktreePath), |
| 1408 | ); |
| 1409 | }), |
| 1404 | 1410 | ); |
| 1405 | 1411 | |
| 1406 | 1412 | it.effect("checks out submodules in a new worktree", () => |