|
2 | 2 | import * as NodeFS from "node:fs"; |
3 | 3 | import * as NodeServices from "@effect/platform-node/NodeServices"; |
4 | 4 | import * as HostProcess from "@t3tools/shared/HostProcess"; |
| 5 | +import { SpawnExecutableResolution } from "@t3tools/shared/shell"; |
5 | 6 | import { assert, it, describe } from "@effect/vitest"; |
6 | 7 | import * as Deferred from "effect/Deferred"; |
7 | 8 | import * as Effect from "effect/Effect"; |
@@ -339,6 +340,57 @@ it.effect("uses stable diagnostics for every parsed non-repository command", () |
339 | 340 | }).pipe(Effect.provide(layer)); |
340 | 341 | }); |
341 | 342 |
|
| 343 | +it.effect("starts Git for Windows reads without a console", () => { |
| 344 | + const commands: Array<{ |
| 345 | + readonly args: ReadonlyArray<string>; |
| 346 | + readonly detached: boolean | undefined; |
| 347 | + readonly windowsHide: boolean | undefined; |
| 348 | + }> = []; |
| 349 | + const spawner = ChildProcessSpawner.make((command) => |
| 350 | + Effect.sync(() => { |
| 351 | + if (!ChildProcess.isStandardCommand(command)) { |
| 352 | + return assert.fail("expected a standard Git command"); |
| 353 | + } |
| 354 | + commands.push({ |
| 355 | + args: command.args, |
| 356 | + detached: command.options.detached, |
| 357 | + windowsHide: command.options.windowsHide, |
| 358 | + }); |
| 359 | + return makeNonRepositoryHandle(); |
| 360 | + }), |
| 361 | + ); |
| 362 | + const layer = GitVcsDriver.layer.pipe( |
| 363 | + Layer.provide(layerServerConfig), |
| 364 | + Layer.provideMerge( |
| 365 | + Layer.mergeAll( |
| 366 | + NodeServices.layer, |
| 367 | + Layer.succeed(ChildProcessSpawner.ChildProcessSpawner, spawner), |
| 368 | + Layer.succeed(HostProcess.Platform, "win32"), |
| 369 | + ), |
| 370 | + ), |
| 371 | + ); |
| 372 | + |
| 373 | + return Effect.gen(function* () { |
| 374 | + const driver = yield* GitVcsDriver.GitVcsDriver; |
| 375 | + yield* driver.statusDetailsLocal("/repo"); |
| 376 | + |
| 377 | + assert.deepStrictEqual(commands, [ |
| 378 | + { args: ["rev-parse", "--git-path", "index"], detached: true, windowsHide: true }, |
| 379 | + { |
| 380 | + args: ["status", "--porcelain=2", "--branch"], |
| 381 | + detached: undefined, |
| 382 | + windowsHide: undefined, |
| 383 | + }, |
| 384 | + ]); |
| 385 | + }).pipe( |
| 386 | + Effect.provide(layer), |
| 387 | + Effect.provideService( |
| 388 | + SpawnExecutableResolution, |
| 389 | + () => "C:\\Program Files\\Git\\mingw64\\bin\\git.exe", |
| 390 | + ), |
| 391 | + ); |
| 392 | +}); |
| 393 | + |
342 | 394 | it.effect("invalidates origin remote cache when a driver mutation adds origin", () => |
343 | 395 | Effect.gen(function* () { |
344 | 396 | const driver = yield* GitVcsDriver.GitVcsDriver; |
|
0 commit comments