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