Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

SourceControlRepositoryService.test.ts

660 lines23.8 KB

1import { SourceControlProviderKind } from "@t3tools/contracts";
2import * as NodePath from "@effect/platform-node/NodePath";
3import * as NodeServices from "@effect/platform-node/NodeServices";
4import { assert, it } from "@effect/vitest";
5import * as Effect from "effect/Effect";
6import * as FileSystem from "effect/FileSystem";
7import * as Path from "effect/Path";
8import * as Layer from "effect/Layer";
9import * as PlatformError from "effect/PlatformError";
10import { ChildProcessSpawner } from "effect/process";
11​
12import {
13 GitCommandError,
14 SourceControlProviderError,
15 type SourceControlCloneRepositoryInput,
16} from "@t3tools/contracts";
17​
18import * as ServerConfig from "../config.ts";
19import * as GitVcsDriver from "../vcs/GitVcsDriver.ts";
20import type * as SourceControlProvider from "@t3tools/source-control-core/server/SourceControlProvider";
21import * as SourceControlProviderRegistry from "./SourceControlProviderRegistry.ts";
22import * as SourceControlRepositoryService from "./SourceControlRepositoryService.ts";
23​
24const CLONE_URLS = {
25 nameWithOwner: "octocat/t3code",
26 url: "https://github.com/octocat/t3code",
27 sshUrl: "git@github.com:octocat/t3code.git",
28};
29​
30function makeProvider(
31 overrides: Partial<SourceControlProvider.SourceControlProvider["Service"]> = {},
32): SourceControlProvider.SourceControlProvider["Service"] {
33 const unsupported = (operation: string) =>
34 Effect.die(`unexpected provider operation ${operation}`) as Effect.Effect<
35 never,
36 SourceControlProviderError
37 >;
38​
39 return {
40 kind: SourceControlProviderKind.make("github"),
41 listChangeRequests: () => unsupported("listChangeRequests"),
42 getChangeRequest: () => unsupported("getChangeRequest"),
43 createChangeRequest: () => unsupported("createChangeRequest"),
44 getRepositoryCloneUrls: () => Effect.succeed(CLONE_URLS),
45 createRepository: () => Effect.succeed(CLONE_URLS),
46 getDefaultBranch: () => Effect.succeed(null),
47 checkoutChangeRequest: () => unsupported("checkoutChangeRequest"),
48 ...overrides,
49 };
51​
52function processOutput(): GitVcsDriver.ExecuteGitResult {
53 return {
54 exitCode: ChildProcessSpawner.ExitCode(0),
55 stdout: "",
56 stderr: "",
57 stdoutTruncated: false,
58 stderrTruncated: false,
59 };
61​
62function layer(input: {
63 readonly provider?: SourceControlProvider.SourceControlProvider["Service"];
64 readonly git?: Partial<GitVcsDriver.GitVcsDriver["Service"]>;
65 readonly fileSystem?: FileSystem.FileSystem;
66}) {
67 const layerService = SourceControlRepositoryService.layer.pipe(
68 Layer.provide(
69 Layer.mock(SourceControlProviderRegistry.SourceControlProviderRegistry)({
70 resolveLink: () => undefined,
71 get: () => Effect.succeed(input.provider ?? makeProvider()),
72 }),
73 ),
74 Layer.provide(
75 Layer.mock(GitVcsDriver.GitVcsDriver)({
76 execute: () => Effect.succeed(processOutput()),
77 ensureRemote: () => Effect.succeed("origin"),
78 pushCurrentBranch: () =>
79 Effect.succeed({
80 status: "pushed" as const,
81 branch: "feature/remote-v1",
82 upstreamBranch: "origin/feature/remote-v1",
83 setUpstream: true,
84 }),
85 ...input.git,
86 }),
87 ),
88 Layer.provide(
89 ServerConfig.layerTest(
90 process.cwd(),
91 input.fileSystem ? "/tmp/t3-source-control-repos" : { prefix: "t3-source-control-repos-" },
92 ),
93 ),
94 );
95​
96 return input.fileSystem
97 ? layerService.pipe(
98 Layer.provide(Layer.succeed(FileSystem.FileSystem, input.fileSystem)),
99 Layer.provideMerge(NodePath.layer),
100 )
101 : layerService.pipe(Layer.provideMerge(NodeServices.layer));
103​
104const lookupFailingWith = (cause: unknown, detail: string) =>
105 Effect.gen(function* () {
106 const service = yield* SourceControlRepositoryService.SourceControlRepositoryService;
107 return yield* service
108 .lookupRepository({ provider: SourceControlProviderKind.make("bitbucket"), repository: "x" })
109 .pipe(Effect.flip);
110 }).pipe(
111 Effect.provide(
112 layer({
113 provider: makeProvider({
114 getRepositoryCloneUrls: (input) =>
115 Effect.fail(
116 new SourceControlProviderError({
117 provider: SourceControlProviderKind.make("bitbucket"),
118 operation: "getRepositoryCloneUrls",
119 cwd: input.cwd,
120 detail,
121 cause,
122 }),
123 ),
124 }),
125 }),
126 ),
127 );
128​
129it.effect("tells the user a host's fixed explanation of a failed repository lookup", () =>
130 Effect.gen(function* () {
131 const error = yield* lookupFailingWith(
132 { userFacingDetail: "Repositories are named workspace/repository." },
133 "Repositories are named workspace/repository.",
134 );
135 assert.strictEqual(error.detail, "Repositories are named workspace/repository.");
136 }),
137);
138​
139it.effect("keeps a host's raw response text out of a failed repository lookup", () =>
140 Effect.gen(function* () {
141 const error = yield* lookupFailingWith(
142 new Error("upstream"),
143 "<html>internal token=abc</html>",
144 );
145 assert.strictEqual(error.detail, "The source control operation could not be completed.");
146 }),
147);
148​
149it.effect("clones a looked-up repository after creating missing parent directories", () =>
150 Effect.gen(function* () {
151 const fs = yield* FileSystem.FileSystem;
152 const path = yield* Path.Path;
153 const temporaryDirectory = yield* fs.makeTempDirectoryScoped({
154 prefix: "t3-source-control-clone-parent-",
155 });
156 const parent = path.join(temporaryDirectory, "missing", "nested");
157 const destinationPath = path.join(parent, "t3code");
158 const cloneCalls: Array<{ cwd: string; args: ReadonlyArray<string> }> = [];
159​
160 yield* Effect.gen(function* () {
161 const service = yield* SourceControlRepositoryService.SourceControlRepositoryService;
162 const result = yield* service.cloneRepository({
163 provider: SourceControlProviderKind.make("github"),
164 repository: "octocat/t3code",
165 destinationPath,
166 protocol: "https",
167 });
168​
169 assert.deepStrictEqual(result, {
170 cwd: destinationPath,
171 remoteUrl: CLONE_URLS.url,
172 repository: { provider: SourceControlProviderKind.make("github"), ...CLONE_URLS },
173 });
174 assert.deepStrictEqual(cloneCalls, [
175 {
176 cwd: parent,
177 args: ["clone", "--progress", "--", CLONE_URLS.url, "t3code"],
178 },
179 ]);
180 }).pipe(
181 Effect.provide(
182 layer({
183 git: {
184 execute: (input) =>
185 Effect.gen(function* () {
186 assert.isTrue(yield* fs.exists(parent).pipe(Effect.orDie));
187 cloneCalls.push({ cwd: input.cwd, args: input.args });
188 return processOutput();
189 }),
190 },
191 }),
192 ),
193 );
194 }).pipe(Effect.provide(NodeServices.layer)),
195);
196​
197it.effect.each(["--bare", "source.git"])(
198 "clones a local repository named %s as a working tree",
199 (repositoryName) =>
200 Effect.gen(function* () {
201 const fs = yield* FileSystem.FileSystem;
202 const path = yield* Path.Path;
203 const git = yield* GitVcsDriver.GitVcsDriver;
204 const parent = yield* fs.makeTempDirectoryScoped({ prefix: "t3-clone-options-" });
205 yield* git.execute({
206 operation: "test.init",
207 cwd: parent,
208 args: ["init", "--bare", path.join(parent, repositoryName)],
209 });
210 const destinationPath = path.join(parent, "checkout");
211 yield* Effect.gen(function* () {
212 const service = yield* SourceControlRepositoryService.SourceControlRepositoryService;
213 const result = yield* service.cloneRepository({
214 remoteUrl: repositoryName,
215 destinationPath,
216 });
217 assert.strictEqual(result.cwd, destinationPath);
218 assert.isTrue(yield* fs.exists(path.join(destinationPath, ".git")));
219 }).pipe(Effect.provide(layer({ git: { execute: git.execute } })));
220 }).pipe(
221 Effect.provide(
222 GitVcsDriver.layer.pipe(
223 Layer.provide(
224 ServerConfig.layerTest(process.cwd(), {
225 prefix: "t3-clone-options-config-",
226 }),
227 ),
228 Layer.provideMerge(NodeServices.layer),
229 ),
230 ),
231 ),
232);
233​
234it.effect("reports clone progress from git's stderr and keeps its error text on failure", () =>
235 Effect.gen(function* () {
236 const fs = yield* FileSystem.FileSystem;
237 const path = yield* Path.Path;
238 const parent = yield* fs.makeTempDirectoryScoped({
239 prefix: "t3-source-control-clone-progress-",
240 });
241 const destinationPath = path.join(parent, "t3code");
242 const progress: Array<{ stage: string; percent: number | null; detail: string | null }> = [];
243​
244 const stderrLines = [
245 "Cloning into 't3code'...",
246 "remote: Enumerating objects: 10, done.",
247 "Receiving objects: 40% (4/10), 1.00 MiB | 2.00 MiB/s",
248 "Receiving objects: 100% (10/10), 2.50 MiB | 2.00 MiB/s, done.",
249 "fatal: early EOF",
250 "fatal: unable to access 'https://user:s3c@ret@github.com/octocat/t3code.git/': could not resolve host",
251 ];
252 const error = yield* Effect.gen(function* () {
253 const service = yield* SourceControlRepositoryService.SourceControlRepositoryService;
254 return yield* Effect.flip(
255 service.cloneRepository(
256 { remoteUrl: CLONE_URLS.sshUrl, destinationPath },
257 { onProgress: (line) => Effect.sync(() => void progress.push(line)) },
258 ),
259 );
260 }).pipe(
261 Effect.provide(
262 layer({
263 git: {
264 execute: (input) =>
265 Effect.gen(function* () {
266 for (const line of stderrLines) {
267 yield* input.progress?.onStderrLine?.(line) ?? Effect.void;
268 }
269 return yield* new GitCommandError({
270 operation: input.operation,
271 command: "git",
272 cwd: input.cwd,
273 detail: "Git command exited with a non-zero status.",
274 exitCode: 128,
275 });
276 }),
277 },
278 }),
279 ),
280 );
281​
282 assert.deepStrictEqual(progress, [
283 { stage: "counting", percent: null, detail: null },
284 { stage: "receiving", percent: 40, detail: "1.00 MiB | 2.00 MiB/s" },
285 { stage: "receiving", percent: 100, detail: "2.50 MiB | 2.00 MiB/s" },
286 ]);
287 assert.strictEqual(
288 error.detail,
289 "fatal: early EOF fatal: unable to access 'https://github.com/octocat/t3code.git/': could not resolve host",
290 );
291 }).pipe(Effect.provide(NodeServices.layer)),
292);
293​
294function rejectingSsh(
295 urls: Array<string>,
296 httpsFails: boolean,
297 reason: GitCommandError["reason"] = "authentication_failed",
298) {
299 return {
300 execute: (input: GitVcsDriver.ExecuteGitInput) =>
301 Effect.gen(function* () {
302 const url = input.args.at(-2)!;
303 urls.push(url);
304 if (url.startsWith("https://") && !httpsFails) return processOutput();
305 yield* (
306 input.progress?.onStderrLine?.(
307 url.startsWith("https://")
308 ? "fatal: could not read Username for 'https://github.com': terminal prompts disabled"
309 : "git@github.com: Permission denied (publickey).",
310 ) ?? Effect.void
311 );
312 return yield* new GitCommandError({
313 operation: input.operation,
314 command: "git",
315 cwd: input.cwd,
316 reason,
317 detail: "Git command exited with a non-zero status.",
318 });
319 }),
320 } satisfies Partial<GitVcsDriver.GitVcsDriver["Service"]>;
322​
323const cloneInTemporaryDirectory = (
324 git: Partial<GitVcsDriver.GitVcsDriver["Service"]>,
325 input: Omit<SourceControlCloneRepositoryInput, "destinationPath">,
326) =>
327 Effect.gen(function* () {
328 const fs = yield* FileSystem.FileSystem;
329 const path = yield* Path.Path;
330 const parent = yield* fs
331 .makeTempDirectoryScoped({ prefix: "t3-clone-fallback-" })
332 .pipe(Effect.orDie);
333 return yield* Effect.gen(function* () {
334 const service = yield* SourceControlRepositoryService.SourceControlRepositoryService;
335 return yield* service.cloneRepository({
336 ...input,
337 destinationPath: path.join(parent, "t3code"),
338 });
339 }).pipe(Effect.provide(layer({ git }).pipe(Layer.orDie)));
340 }).pipe(Effect.provide(NodeServices.layer));
341​
342it.effect("retries a clone over HTTPS when the SSH login is refused", () =>
343 Effect.gen(function* () {
344 const urls: Array<string> = [];
345 const result = yield* cloneInTemporaryDirectory(rejectingSsh(urls, false), {
346 remoteUrl: CLONE_URLS.sshUrl,
347 });
348​
349 assert.deepStrictEqual(urls, [CLONE_URLS.sshUrl, "https://github.com/octocat/t3code.git"]);
350 assert.strictEqual(result.remoteUrl, "https://github.com/octocat/t3code.git");
351 }),
352);
353​
354it.effect("reports both failures when the HTTPS retry fails too", () =>
355 Effect.gen(function* () {
356 const urls: Array<string> = [];
357 const error = yield* Effect.flip(
358 cloneInTemporaryDirectory(rejectingSsh(urls, true), { remoteUrl: CLONE_URLS.sshUrl }),
359 );
360​
361 assert.strictEqual(urls.length, 2);
362 assert.strictEqual(
363 error.detail,
364 "git@github.com: Permission denied (publickey). Cloning over HTTPS instead also failed: fatal: could not read Username for 'https://github.com': terminal prompts disabled",
365 );
366 }),
367);
368​
369it.effect.each([
370 ["the caller asked for SSH", "ssh", "authentication_failed"],
371 ["git failed for another reason", undefined, "remote_unreachable"],
372] as const)("does not retry over HTTPS when %s", ([, protocol, reason]) =>
373 Effect.gen(function* () {
374 const urls: Array<string> = [];
375 yield* Effect.flip(
376 cloneInTemporaryDirectory(rejectingSsh(urls, false, reason), {
377 remoteUrl: CLONE_URLS.sshUrl,
378 ...(protocol === undefined ? {} : { protocol }),
379 }),
380 );
381​
382 assert.deepStrictEqual(urls, [CLONE_URLS.sshUrl]);
383 }),
384);
385​
386it.effect("strips embedded credentials from the remote URL it reports", () =>
387 Effect.gen(function* () {
388 const fs = yield* FileSystem.FileSystem;
389 const path = yield* Path.Path;
390 const parent = yield* fs.makeTempDirectoryScoped({ prefix: "t3-source-control-redact-" });
391 const destinationPath = path.join(parent, "t3code");
392 const cloneArgs: Array<ReadonlyArray<string>> = [];
393 const result = yield* Effect.gen(function* () {
394 const service = yield* SourceControlRepositoryService.SourceControlRepositoryService;
395 return yield* service.prepareClone({
396 remoteUrl: "https://user:s3cret@github.com/octocat/t3code.git",
397 destinationPath,
398 });
399 }).pipe(
400 Effect.provide(
401 layer({
402 git: {
403 execute: (input) =>
404 Effect.sync(() => {
405 cloneArgs.push(input.args);
406 return processOutput();
407 }),
408 },
409 }),
410 ),
411 );
412 assert.equal(result.remoteUrl, "https://github.com/octocat/t3code.git");
413 assert.equal(result.cloneUrl, "https://user:s3cret@github.com/octocat/t3code.git");
414 }).pipe(Effect.provide(NodeServices.layer)),
415);
416​
417it.effect("discards only a directory git wrote to", () =>
418 Effect.gen(function* () {
419 const fs = yield* FileSystem.FileSystem;
420 const path = yield* Path.Path;
421 const parent = yield* fs.makeTempDirectoryScoped({ prefix: "t3-source-control-discard-" });
422 const partial = path.join(parent, "partial");
423 yield* fs.makeDirectory(path.join(partial, ".git"), { recursive: true });
424 yield* fs.writeFileString(path.join(partial, "README.md"), "half");
425 const foreign = path.join(parent, "foreign");
426 yield* fs.makeDirectory(foreign);
427 yield* fs.writeFileString(path.join(foreign, "notes.txt"), "mine");
428​
429 const replaced = path.join(parent, "replaced");
430 yield* fs.writeFileString(replaced, "not a directory");
431​
432 yield* Effect.gen(function* () {
433 const service = yield* SourceControlRepositoryService.SourceControlRepositoryService;
434 yield* service.discardClone(partial);
435 const error = yield* Effect.flip(service.discardClone(foreign));
436 assert.include(error.detail, "not from the clone");
437 const replacedError = yield* Effect.flip(service.discardClone(replaced));
438 assert.include(replacedError.detail, "could not be inspected");
439 yield* service.discardClone(path.join(parent, "missing"));
440 }).pipe(Effect.provide(layer({})));
441​
442 assert.deepStrictEqual(yield* fs.readDirectory(partial), []);
443 assert.deepStrictEqual(yield* fs.readDirectory(foreign), ["notes.txt"]);
444 assert.strictEqual(yield* fs.readFileString(replaced), "not a directory");
445 }).pipe(Effect.provide(NodeServices.layer)),
446);
447​
448it.effect("redacts query tokens and userinfo containing '@' from reported URLs", () =>
449 Effect.gen(function* () {
450 const fs = yield* FileSystem.FileSystem;
451 const path = yield* Path.Path;
452 const parent = yield* fs.makeTempDirectoryScoped({ prefix: "t3-source-control-redact2-" });
453 yield* Effect.gen(function* () {
454 const service = yield* SourceControlRepositoryService.SourceControlRepositoryService;
455 const query = yield* service.prepareClone({
456 remoteUrl: "https://github.com/octocat/t3code.git?access_token=s3cret",
457 destinationPath: path.join(parent, "a"),
458 });
459 assert.equal(query.remoteUrl, "https://github.com/octocat/t3code.git");
460 const nested = yield* service.prepareClone({
461 remoteUrl: "https://user:pa@rt@github.com/octocat/t3code.git",
462 destinationPath: path.join(parent, "b"),
463 });
464 assert.equal(nested.remoteUrl, "https://github.com/octocat/t3code.git");
465 }).pipe(Effect.provide(layer({})));
466 }).pipe(Effect.provide(NodeServices.layer)),
467);
468​
469it.effect("preserves destination probe failures instead of treating them as missing paths", () => {
470 const fileSystemCause = PlatformError.systemError({
471 _tag: "PermissionDenied",
472 module: "FileSystem",
473 method: "exists",
474 pathOrDescriptor: "/restricted/t3code",
475 });
476​
477 return Effect.gen(function* () {
478 const service = yield* SourceControlRepositoryService.SourceControlRepositoryService;
479 const error = yield* Effect.flip(
480 service.cloneRepository({
481 remoteUrl: CLONE_URLS.sshUrl,
482 destinationPath: "/restricted/t3code",
483 }),
484 );
485​
486 assert.strictEqual(error.provider, "unknown");
487 assert.strictEqual(error.operation, "cloneRepository");
488 assert.strictEqual(error.cause, fileSystemCause);
489 }).pipe(
490 Effect.provide(
491 layer({
492 fileSystem: FileSystem.makeNoop({
493 exists: () => Effect.fail(fileSystemCause),
494 makeDirectory: () => Effect.void,
495 }),
496 }),
497 ),
498 );
499});
500​
501it.effect("publishes to the remote name returned by ensureRemote", () => {
502 const pushCalls: Array<{ cwd: string; remoteName: string | null | undefined }> = [];
503​
504 return Effect.gen(function* () {
505 const service = yield* SourceControlRepositoryService.SourceControlRepositoryService;
506 const result = yield* service.publishRepository({
507 cwd: "/workspace",
508 provider: SourceControlProviderKind.make("github"),
509 repository: "octocat/t3code",
510 visibility: "private",
511 remoteName: "origin",
512 protocol: "ssh",
513 });
514​
515 assert.equal(result.remoteName, "origin-1");
516 assert.deepStrictEqual(pushCalls, [{ cwd: "/workspace", remoteName: "origin-1" }]);
517 }).pipe(
518 Effect.provide(
519 layer({
520 git: {
521 ensureRemote: () => Effect.succeed("origin-1"),
522 pushCurrentBranch: (cwd, _fallbackBranch, options) =>
523 Effect.sync(() => {
524 pushCalls.push({ cwd, remoteName: options?.remoteName });
525 return {
526 status: "pushed" as const,
527 branch: "feature/remote-v1",
528 upstreamBranch: `${options?.remoteName ?? "missing"}/feature/remote-v1`,
529 setUpstream: true,
530 };
531 }),
532 },
533 }),
534 ),
535 );
536});
537​
538function failingPush(reason?: GitCommandError["reason"]) {
539 return {
540 pushCurrentBranch: (cwd: string) =>
541 Effect.fail(
542 new GitCommandError({
543 operation: "GitVcsDriver.pushCurrentBranch.pushWithRequestedRemote",
544 command: "git",
545 cwd,
546 ...(reason === undefined ? {} : { reason }),
547 detail: "Git command exited with a non-zero status.",
548 }),
549 ),
550 } satisfies Partial<GitVcsDriver.GitVcsDriver["Service"]>;
552​
553it.effect("explains a rejected SSH push after creating the repository", () =>
554 Effect.gen(function* () {
555 const service = yield* SourceControlRepositoryService.SourceControlRepositoryService;
556 const error = yield* Effect.flip(
557 service.publishRepository({
558 cwd: "/workspace",
559 provider: SourceControlProviderKind.make("github"),
560 repository: "octocat/t3code",
561 visibility: "private",
562 protocol: "ssh",
563 }),
564 );
565​
566 assert.strictEqual(error.operation, "publishRepository");
567 assert.strictEqual(
568 error.detail,
569 'Created octocat/t3code and added it as remote "origin", but the push failed because SSH authentication was rejected. Add an SSH key to your account, or switch the remote to HTTPS with "git remote set-url origin https://github.com/octocat/t3code", then push again.',
570 );
571 assert.instanceOf(error.cause, GitCommandError);
572 }).pipe(Effect.provide(layer({ git: failingPush("authentication_failed") }))),
573);
574​
575// regression: #19219 publishing did not explain why the first push failed
576it.effect("says the repository exists when an unclassified publish push fails", () =>
577 Effect.gen(function* () {
578 const service = yield* SourceControlRepositoryService.SourceControlRepositoryService;
579 const error = yield* Effect.flip(
580 service.publishRepository({
581 cwd: "/workspace",
582 provider: SourceControlProviderKind.make("github"),
583 repository: "octocat/t3code",
584 visibility: "private",
585 protocol: "https",
586 }),
587 );
588​
589 assert.strictEqual(
590 error.detail,
591 'Created octocat/t3code and added it as remote "origin", but the push failed. Fix the problem, then push again.',
592 );
593 }).pipe(Effect.provide(layer({ git: failingPush() }))),
594);
595​
596it.effect("publish succeeds with status remote_added when the local repo has no commits", () => {
597 let pushCalls = 0;
598 return Effect.gen(function* () {
599 const service = yield* SourceControlRepositoryService.SourceControlRepositoryService;
600 const result = yield* service.publishRepository({
601 cwd: "/workspace",
602 provider: SourceControlProviderKind.make("github"),
603 repository: "octocat/t3code",
604 visibility: "private",
605 remoteName: "origin",
606 protocol: "ssh",
607 });
608​
609 assert.deepStrictEqual(result, {
610 repository: { provider: SourceControlProviderKind.make("github"), ...CLONE_URLS },
611 remoteName: "origin",
612 remoteUrl: CLONE_URLS.sshUrl,
613 branch: "main",
614 status: "remote_added",
615 });
616 assert.strictEqual(pushCalls, 0);
617 }).pipe(
618 Effect.provide(
619 layer({
620 git: {
621 execute: (input) =>
622 input.args[0] === "rev-parse"
623 ? Effect.fail(
624 new GitCommandError({
625 operation: input.operation,
626 command: "git rev-parse --verify HEAD",
627 cwd: input.cwd,
628 detail: "fatal: Needed a single revision",
629 }),
630 )
631 : Effect.succeed(processOutput()),
632 statusDetails: () =>
633 Effect.succeed({
634 isRepo: true,
635 hasOriginRemote: true,
636 isDefaultBranch: true,
637 branch: "main",
638 upstreamRef: null,
639 hasWorkingTreeChanges: false,
640 workingTree: { files: [], insertions: 0, deletions: 0 },
641 hasUpstream: false,
642 aheadCount: 0,
643 behindCount: 0,
644 aheadOfDefaultCount: 0,
645 }),
646 pushCurrentBranch: () =>
647 Effect.sync(() => {
648 pushCalls += 1;
649 return {
650 status: "pushed" as const,
651 branch: "main",
652 upstreamBranch: "origin/main",
653 setUpstream: true,
654 };
655 }),
656 },
657 }),
658 ),
659 );
660});