| @@ -6,20 +6,20 @@ import { it } from "@effect/vitest"; · 5 unmodified lines |
| 6 | 6 | import { Effect, FileSystem, Layer, PlatformError, Scope } from "effect"; |
| 7 | 7 | import { describe, expect, vi } from "vitest"; |
| 8 | 8 | |
| 9 | | −import { GitCoreLive, makeGitCore } from "./GitCore.ts"; |
| 10 | | −import { GitCore, type GitCoreShape } from "../Services/GitCore.ts"; |
| 9 | +import { makeGitVcsDriverCore } from "./GitVcsDriverCore.ts"; |
| 10 | +import * as GitVcsDriver from "./GitVcsDriver.ts"; |
| 11 | 11 | import { GitCommandError } from "@t3tools/contracts"; |
| 12 | | −import { type ProcessRunResult, runProcess } from "../../processRunner.ts"; |
| 13 | | −import { ServerConfig } from "../../config.ts"; |
| 12 | +import { type ProcessRunResult, runProcess } from "../processRunner.ts"; |
| 13 | +import { ServerConfig } from "../config.ts"; |
| 14 | 14 | |
| 15 | 15 | // ── Helpers ── |
| 16 | 16 | |
| 17 | 17 | const ServerConfigLayer = ServerConfig.layerTest(process.cwd(), { prefix: "t3-git-core-test-" }); |
| 18 | | −const GitCoreTestLayer = GitCoreLive.pipe( |
| 18 | +const GitVcsDriverTestLayer = GitVcsDriver.layer.pipe( |
| 19 | 19 | Layer.provide(ServerConfigLayer), |
| 20 | 20 | Layer.provide(NodeServices.layer), |
| 21 | 21 | ); |
| 22 | | −const TestLayer = Layer.mergeAll(NodeServices.layer, GitCoreTestLayer); |
| 22 | +const TestLayer = Layer.mergeAll(NodeServices.layer, GitVcsDriverTestLayer); |
| 23 | 23 | |
| 24 | 24 | function makeTmpDir( |
| 25 | 25 | prefix = "git-test-", |
| @@ -63,11 +63,11 @@ function git( · 37 unmodified lines |
| 63 | 63 | cwd: string, |
| 64 | 64 | args: ReadonlyArray<string>, |
| 65 | 65 | env?: NodeJS.ProcessEnv, |
| 66 | | −): Effect.Effect<string, GitCommandError, GitCore> { |
| 66 | +): Effect.Effect<string, GitCommandError, GitVcsDriver.GitVcsDriver> { |
| 67 | 67 | return Effect.gen(function* () { |
| 68 | | − const gitCore = yield* GitCore; |
| 69 | | − const result = yield* gitCore.execute({ |
| 70 | | − operation: "GitCore.test.git", |
| 68 | + const gitVcsDriver = yield* GitVcsDriver.GitVcsDriver; |
| 69 | + const result = yield* gitVcsDriver.execute({ |
| 70 | + operation: "GitVcsDriver.test.git", |
| 71 | 71 | cwd, |
| 72 | 72 | args, |
| 73 | 73 | ...(env ? { env } : {}), |
| @@ -82,7 +82,7 @@ function configureRemote( · 8 unmodified lines |
| 82 | 82 | remoteName: string, |
| 83 | 83 | remotePath: string, |
| 84 | 84 | fetchNamespace: string, |
| 85 | | −): Effect.Effect<string, GitCommandError, GitCore> { |
| 85 | +): Effect.Effect<string, GitCommandError, GitVcsDriver.GitVcsDriver> { |
| 86 | 86 | return Effect.gen(function* () { |
| 87 | 87 | yield* git(cwd, ["config", `remote.${remoteName}.url`, remotePath]); |
| 88 | 88 | return yield* git(cwd, [ |
| @@ -119,8 +119,8 @@ function runShellCommand(input: { · 30 unmodified lines |
| 119 | 119 | }); |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | | −const makeIsolatedGitCore = (executeOverride: GitCoreShape["execute"]) => |
| 123 | | − makeGitCore({ executeOverride }).pipe( |
| 122 | +const makeIsolatedGitVcsDriver = (executeOverride: GitVcsDriver.GitVcsDriverShape["execute"]) => |
| 123 | + makeGitVcsDriverCore({ executeOverride }).pipe( |
| 124 | 124 | Effect.provide(Layer.provideMerge(ServerConfigLayer, NodeServices.layer)), |
| 125 | 125 | ); |
| 126 | 126 | |
| @@ -130,10 +130,10 @@ function initRepoWithCommit( · 3 unmodified lines |
| 130 | 130 | ): Effect.Effect< |
| 131 | 131 | { initialBranch: string }, |
| 132 | 132 | GitCommandError | PlatformError.PlatformError, |
| 133 | | − GitCore | FileSystem.FileSystem |
| 133 | + GitVcsDriver.GitVcsDriver | FileSystem.FileSystem |
| 134 | 134 | > { |
| 135 | 135 | return Effect.gen(function* () { |
| 136 | | − const core = yield* GitCore; |
| 136 | + const core = yield* GitVcsDriver.GitVcsDriver; |
| 137 | 137 | yield* core.initRepo({ cwd }); |
| 138 | 138 | yield* git(cwd, ["config", "user.email", "test@test.com"]); |
| 139 | 139 | yield* git(cwd, ["config", "user.name", "Test"]); |
| @@ -154,7 +154,7 @@ function commitWithDate( · 14 unmodified lines |
| 154 | 154 | ): Effect.Effect< |
| 155 | 155 | void, |
| 156 | 156 | GitCommandError | PlatformError.PlatformError, |
| 157 | | − GitCore | FileSystem.FileSystem |
| 157 | + GitVcsDriver.GitVcsDriver | FileSystem.FileSystem |
| 158 | 158 | > { |
| 159 | 159 | return Effect.gen(function* () { |
| 160 | 160 | yield* writeTextFile(path.join(cwd, fileName), fileContents); |
| @@ -199,7 +199,7 @@ it.layer(TestLayer)("git integration", (it) => { · 38 unmodified lines |
| 199 | 199 | it.effect("creates a valid git repo", () => |
| 200 | 200 | Effect.gen(function* () { |
| 201 | 201 | const tmp = yield* makeTmpDir(); |
| 202 | | − yield* (yield* GitCore).initRepo({ cwd: tmp }); |
| 202 | + yield* (yield* GitVcsDriver.GitVcsDriver).initRepo({ cwd: tmp }); |
| 203 | 203 | expect(existsSync(path.join(tmp, ".git"))).toBe(true); |
| 204 | 204 | }), |
| 205 | 205 | ); |
| @@ -208,7 +208,7 @@ it.layer(TestLayer)("git integration", (it) => { · 2 unmodified lines |
| 208 | 208 | Effect.gen(function* () { |
| 209 | 209 | const tmp = yield* makeTmpDir(); |
| 210 | 210 | yield* initRepoWithCommit(tmp); |
| 211 | | − const result = yield* (yield* GitCore).listBranches({ cwd: tmp }); |
| 211 | + const result = yield* (yield* GitVcsDriver.GitVcsDriver).listBranches({ cwd: tmp }); |
| 212 | 212 | expect(result.isRepo).toBe(true); |
| 213 | 213 | expect(result.hasOriginRemote).toBe(false); |
| 214 | 214 | expect(result.branches.length).toBeGreaterThanOrEqual(1); |
| @@ -222,7 +222,7 @@ it.layer(TestLayer)("git integration", (it) => { · 7 unmodified lines |
| 222 | 222 | it.effect("returns isRepo: false for non-git directory", () => |
| 223 | 223 | Effect.gen(function* () { |
| 224 | 224 | const tmp = yield* makeTmpDir(); |
| 225 | | − const result = yield* (yield* GitCore).listBranches({ cwd: tmp }); |
| 225 | + const result = yield* (yield* GitVcsDriver.GitVcsDriver).listBranches({ cwd: tmp }); |
| 226 | 226 | expect(result.isRepo).toBe(false); |
| 227 | 227 | expect(result.hasOriginRemote).toBe(false); |
| 228 | 228 | expect(result.branches).toEqual([]); |
| @@ -236,7 +236,7 @@ it.layer(TestLayer)("git integration", (it) => { · 7 unmodified lines |
| 236 | 236 | yield* makeDirectory(deletedDir); |
| 237 | 237 | yield* removePath(deletedDir); |
| 238 | 238 | |
| 239 | | − const result = yield* (yield* GitCore).listBranches({ cwd: deletedDir }); |
| 239 | + const result = yield* (yield* GitVcsDriver.GitVcsDriver).listBranches({ cwd: deletedDir }); |
| 240 | 240 | |
| 241 | 241 | expect(result.isRepo).toBe(false); |
| 242 | 242 | expect(result.hasOriginRemote).toBe(false); |
| @@ -248,7 +248,7 @@ it.layer(TestLayer)("git integration", (it) => { · 5 unmodified lines |
| 248 | 248 | Effect.gen(function* () { |
| 249 | 249 | const tmp = yield* makeTmpDir(); |
| 250 | 250 | yield* initRepoWithCommit(tmp); |
| 251 | | − const result = yield* (yield* GitCore).listBranches({ cwd: tmp }); |
| 251 | + const result = yield* (yield* GitVcsDriver.GitVcsDriver).listBranches({ cwd: tmp }); |
| 252 | 252 | const current = result.branches.find((b) => b.current); |
| 253 | 253 | expect(current).toBeDefined(); |
| 254 | 254 | expect(current!.current).toBe(true); |
| @@ -261,7 +261,7 @@ it.layer(TestLayer)("git integration", (it) => { · 6 unmodified lines |
| 261 | 261 | yield* initRepoWithCommit(tmp); |
| 262 | 262 | yield* git(tmp, ["checkout", "--detach", "HEAD"]); |
| 263 | 263 | |
| 264 | | − const result = yield* (yield* GitCore).listBranches({ cwd: tmp }); |
| 264 | + const result = yield* (yield* GitVcsDriver.GitVcsDriver).listBranches({ cwd: tmp }); |
| 265 | 265 | expect(result.branches.some((branch) => branch.name.startsWith("("))).toBe(false); |
| 266 | 266 | expect(result.branches.some((branch) => branch.current)).toBe(false); |
| 267 | 267 | }), |
| @@ -271,12 +271,18 @@ it.layer(TestLayer)("git integration", (it) => { · 3 unmodified lines |
| 271 | 271 | Effect.gen(function* () { |
| 272 | 272 | const tmp = yield* makeTmpDir(); |
| 273 | 273 | yield* initRepoWithCommit(tmp); |
| 274 | | − const initialBranch = (yield* (yield* GitCore).listBranches({ cwd: tmp })).branches.find( |
| 275 | | − (branch) => branch.current, |
| 276 | | − )!.name; |
| 274 | + const initialBranch = (yield* (yield* GitVcsDriver.GitVcsDriver).listBranches({ |
| 275 | + cwd: tmp, |
| 276 | + })).branches.find((branch) => branch.current)!.name; |
| 277 | 277 | |
| 278 | | − yield* (yield* GitCore).createBranch({ cwd: tmp, branch: "older-branch" }); |
| 279 | | − yield* (yield* GitCore).checkoutBranch({ cwd: tmp, branch: "older-branch" }); |
| 278 | + yield* (yield* GitVcsDriver.GitVcsDriver).createBranch({ |
| 279 | + cwd: tmp, |
| 280 | + branch: "older-branch", |
| 281 | + }); |
| 282 | + yield* (yield* GitVcsDriver.GitVcsDriver).checkoutBranch({ |
| 283 | + cwd: tmp, |
| 284 | + branch: "older-branch", |
| 285 | + }); |
| 280 | 286 | yield* commitWithDate( |
| 281 | 287 | tmp, |
| 282 | 288 | "older.txt", |
| @@ -285,9 +291,18 @@ it.layer(TestLayer)("git integration", (it) => { · 2 unmodified lines |
| 285 | 291 | "older branch change", |
| 286 | 292 | ); |
| 287 | 293 | |
| 288 | | − yield* (yield* GitCore).checkoutBranch({ cwd: tmp, branch: initialBranch }); |
| 289 | | − yield* (yield* GitCore).createBranch({ cwd: tmp, branch: "newer-branch" }); |
| 290 | | − yield* (yield* GitCore).checkoutBranch({ cwd: tmp, branch: "newer-branch" }); |
| 294 | + yield* (yield* GitVcsDriver.GitVcsDriver).checkoutBranch({ |
| 295 | + cwd: tmp, |
| 296 | + branch: initialBranch, |
| 297 | + }); |
| 298 | + yield* (yield* GitVcsDriver.GitVcsDriver).createBranch({ |
| 299 | + cwd: tmp, |
| 300 | + branch: "newer-branch", |
| 301 | + }); |
| 302 | + yield* (yield* GitVcsDriver.GitVcsDriver).checkoutBranch({ |
| 303 | + cwd: tmp, |
| 304 | + branch: "newer-branch", |
| 305 | + }); |
| 291 | 306 | yield* commitWithDate( |
| 292 | 307 | tmp, |
| 293 | 308 | "newer.txt", |
| @@ -297,9 +312,12 @@ it.layer(TestLayer)("git integration", (it) => { · 3 unmodified lines |
| 297 | 312 | ); |
| 298 | 313 | |
| 299 | 314 | // Switch away to show current branch is pinned, then remaining branches are recency-sorted. |
| 300 | | − yield* (yield* GitCore).checkoutBranch({ cwd: tmp, branch: "older-branch" }); |
| 315 | + yield* (yield* GitVcsDriver.GitVcsDriver).checkoutBranch({ |
| 316 | + cwd: tmp, |
| 317 | + branch: "older-branch", |
| 318 | + }); |
| 301 | 319 | |
| 302 | | − const result = yield* (yield* GitCore).listBranches({ cwd: tmp }); |
| 320 | + const result = yield* (yield* GitVcsDriver.GitVcsDriver).listBranches({ cwd: tmp }); |
| 303 | 321 | expect(result.branches[0]!.name).toBe("older-branch"); |
| 304 | 322 | expect(result.branches[1]!.name).toBe("newer-branch"); |
| 305 | 323 | }), |
| @@ -310,17 +328,23 @@ it.layer(TestLayer)("git integration", (it) => { · 4 unmodified lines |
| 310 | 328 | const tmp = yield* makeTmpDir(); |
| 311 | 329 | const remote = yield* makeTmpDir(); |
| 312 | 330 | yield* initRepoWithCommit(tmp); |
| 313 | | − const defaultBranch = (yield* (yield* GitCore).listBranches({ cwd: tmp })).branches.find( |
| 314 | | − (branch) => branch.current, |
| 315 | | − )!.name; |
| 331 | + const defaultBranch = (yield* (yield* GitVcsDriver.GitVcsDriver).listBranches({ |
| 332 | + cwd: tmp, |
| 333 | + })).branches.find((branch) => branch.current)!.name; |
| 316 | 334 | |
| 317 | 335 | yield* git(remote, ["init", "--bare"]); |
| 318 | 336 | yield* git(tmp, ["remote", "add", "origin", remote]); |
| 319 | 337 | yield* git(tmp, ["push", "-u", "origin", defaultBranch]); |
| 320 | 338 | yield* git(tmp, ["remote", "set-head", "origin", defaultBranch]); |
| 321 | 339 | |
| 322 | | − yield* (yield* GitCore).createBranch({ cwd: tmp, branch: "current-branch" }); |
| 323 | | − yield* (yield* GitCore).checkoutBranch({ cwd: tmp, branch: "current-branch" }); |
| 340 | + yield* (yield* GitVcsDriver.GitVcsDriver).createBranch({ |
| 341 | + cwd: tmp, |
| 342 | + branch: "current-branch", |
| 343 | + }); |
| 344 | + yield* (yield* GitVcsDriver.GitVcsDriver).checkoutBranch({ |
| 345 | + cwd: tmp, |
| 346 | + branch: "current-branch", |
| 347 | + }); |
| 324 | 348 | yield* commitWithDate( |
| 325 | 349 | tmp, |
| 326 | 350 | "current.txt", |
| @@ -329,9 +353,18 @@ it.layer(TestLayer)("git integration", (it) => { · 2 unmodified lines |
| 329 | 353 | "current change", |
| 330 | 354 | ); |
| 331 | 355 | |
| 332 | | − yield* (yield* GitCore).checkoutBranch({ cwd: tmp, branch: defaultBranch }); |
| 333 | | − yield* (yield* GitCore).createBranch({ cwd: tmp, branch: "newer-branch" }); |
| 334 | | − yield* (yield* GitCore).checkoutBranch({ cwd: tmp, branch: "newer-branch" }); |
| 356 | + yield* (yield* GitVcsDriver.GitVcsDriver).checkoutBranch({ |
| 357 | + cwd: tmp, |
| 358 | + branch: defaultBranch, |
| 359 | + }); |
| 360 | + yield* (yield* GitVcsDriver.GitVcsDriver).createBranch({ |
| 361 | + cwd: tmp, |
| 362 | + branch: "newer-branch", |
| 363 | + }); |
| 364 | + yield* (yield* GitVcsDriver.GitVcsDriver).checkoutBranch({ |
| 365 | + cwd: tmp, |
| 366 | + branch: "newer-branch", |
| 367 | + }); |
| 335 | 368 | yield* commitWithDate( |
| 336 | 369 | tmp, |
| 337 | 370 | "newer.txt", |
| @@ -340,9 +373,12 @@ it.layer(TestLayer)("git integration", (it) => { · 2 unmodified lines |
| 340 | 373 | "newer change", |
| 341 | 374 | ); |
| 342 | 375 | |
| 343 | | − yield* (yield* GitCore).checkoutBranch({ cwd: tmp, branch: "current-branch" }); |
| 376 | + yield* (yield* GitVcsDriver.GitVcsDriver).checkoutBranch({ |
| 377 | + cwd: tmp, |
| 378 | + branch: "current-branch", |
| 379 | + }); |
| 344 | 380 | |
| 345 | | − const result = yield* (yield* GitCore).listBranches({ cwd: tmp }); |
| 381 | + const result = yield* (yield* GitVcsDriver.GitVcsDriver).listBranches({ cwd: tmp }); |
| 346 | 382 | expect(result.branches[0]!.name).toBe("current-branch"); |
| 347 | 383 | expect(result.branches[1]!.name).toBe(defaultBranch); |
| 348 | 384 | expect(result.branches[2]!.name).toBe("newer-branch"); |
| @@ -353,10 +389,10 @@ it.layer(TestLayer)("git integration", (it) => { · 4 unmodified lines |
| 353 | 389 | Effect.gen(function* () { |
| 354 | 390 | const tmp = yield* makeTmpDir(); |
| 355 | 391 | yield* initRepoWithCommit(tmp); |
| 356 | | − yield* (yield* GitCore).createBranch({ cwd: tmp, branch: "feature-a" }); |
| 357 | | − yield* (yield* GitCore).createBranch({ cwd: tmp, branch: "feature-b" }); |
| 392 | + yield* (yield* GitVcsDriver.GitVcsDriver).createBranch({ cwd: tmp, branch: "feature-a" }); |
| 393 | + yield* (yield* GitVcsDriver.GitVcsDriver).createBranch({ cwd: tmp, branch: "feature-b" }); |
| 358 | 394 | |
| 359 | | − const result = yield* (yield* GitCore).listBranches({ cwd: tmp }); |
| 395 | + const result = yield* (yield* GitVcsDriver.GitVcsDriver).listBranches({ cwd: tmp }); |
| 360 | 396 | const names = result.branches.map((b) => b.name); |
| 361 | 397 | expect(names).toContain("feature-a"); |
| 362 | 398 | expect(names).toContain("feature-b"); |
| @@ -367,11 +403,14 @@ it.layer(TestLayer)("git integration", (it) => { · 4 unmodified lines |
| 367 | 403 | Effect.gen(function* () { |
| 368 | 404 | const tmp = yield* makeTmpDir(); |
| 369 | 405 | const { initialBranch } = yield* initRepoWithCommit(tmp); |
| 370 | | − yield* (yield* GitCore).createBranch({ cwd: tmp, branch: "feature-a" }); |
| 371 | | − yield* (yield* GitCore).createBranch({ cwd: tmp, branch: "feature-b" }); |
| 372 | | − yield* (yield* GitCore).createBranch({ cwd: tmp, branch: "feature-c" }); |
| 406 | + yield* (yield* GitVcsDriver.GitVcsDriver).createBranch({ cwd: tmp, branch: "feature-a" }); |
| 407 | + yield* (yield* GitVcsDriver.GitVcsDriver).createBranch({ cwd: tmp, branch: "feature-b" }); |
| 408 | + yield* (yield* GitVcsDriver.GitVcsDriver).createBranch({ cwd: tmp, branch: "feature-c" }); |
| 373 | 409 | |
| 374 | | − const firstPage = yield* (yield* GitCore).listBranches({ cwd: tmp, limit: 2 }); |
| 410 | + const firstPage = yield* (yield* GitVcsDriver.GitVcsDriver).listBranches({ |
| 411 | + cwd: tmp, |
| 412 | + limit: 2, |
| 413 | + }); |
| 375 | 414 | expect(firstPage.totalCount).toBe(4); |
| 376 | 415 | expect(firstPage.nextCursor).toBe(2); |
| 377 | 416 | expect(firstPage.branches.map((branch) => branch.name)).toEqual([ |
| @@ -379,7 +418,7 @@ it.layer(TestLayer)("git integration", (it) => { · 1 unmodified line |
| 379 | 418 | "feature-a", |
| 380 | 419 | ]); |
| 381 | 420 | |
| 382 | | − const secondPage = yield* (yield* GitCore).listBranches({ |
| 421 | + const secondPage = yield* (yield* GitVcsDriver.GitVcsDriver).listBranches({ |
| 383 | 422 | cwd: tmp, |
| 384 | 423 | cursor: firstPage.nextCursor ?? 0, |
| 385 | 424 | limit: 2, |
| @@ -403,7 +442,7 @@ it.layer(TestLayer)("git integration", (it) => { · 17 unmodified lines |
| 403 | 442 | "copilot/rewrite-cli-in-rust", |
| 404 | 443 | ] as const; |
| 405 | 444 | for (const branchName of createdBranchNames) { |
| 406 | | − yield* (yield* GitCore).createBranch({ cwd: tmp, branch: branchName }); |
| 445 | + yield* (yield* GitVcsDriver.GitVcsDriver).createBranch({ cwd: tmp, branch: branchName }); |
| 407 | 446 | } |
| 408 | 447 | yield* git(tmp, ["config", "column.ui", "always"]); |
| 409 | 448 | |
| @@ -420,9 +459,9 @@ it.layer(TestLayer)("git integration", (it) => { · 10 unmodified lines |
| 420 | 459 | ), |
| 421 | 460 | ).toBe(true); |
| 422 | 461 | |
| 423 | | − const realGitCore = yield* GitCore; |
| 424 | | − const core = yield* makeIsolatedGitCore((input) => |
| 425 | | − realGitCore.execute( |
| 462 | + const realGitVcsDriver = yield* GitVcsDriver.GitVcsDriver; |
| 463 | + const core = yield* makeIsolatedGitVcsDriver((input) => |
| 464 | + realGitVcsDriver.execute( |
| 426 | 465 | input.args[0] === "branch" |
| 427 | 466 | ? { |
| 428 | 467 | ...input, |
| @@ -455,7 +494,7 @@ it.layer(TestLayer)("git integration", (it) => { · 26 unmodified lines |
| 455 | 494 | Effect.gen(function* () { |
| 456 | 495 | const tmp = yield* makeTmpDir(); |
| 457 | 496 | yield* initRepoWithCommit(tmp); |
| 458 | | − const result = yield* (yield* GitCore).listBranches({ cwd: tmp }); |
| 497 | + const result = yield* (yield* GitVcsDriver.GitVcsDriver).listBranches({ cwd: tmp }); |
| 459 | 498 | expect(result.branches.every((b) => b.isDefault === false)).toBe(true); |
| 460 | 499 | }), |
| 461 | 500 | ); |
| @@ -467,23 +506,29 @@ it.layer(TestLayer)("git integration", (it) => { · 5 unmodified lines |
| 467 | 506 | |
| 468 | 507 | yield* git(remote, ["init", "--bare"]); |
| 469 | 508 | yield* initRepoWithCommit(tmp); |
| 470 | | − const defaultBranch = (yield* (yield* GitCore).listBranches({ cwd: tmp })).branches.find( |
| 471 | | − (branch) => branch.current, |
| 472 | | − )!.name; |
| 509 | + const defaultBranch = (yield* (yield* GitVcsDriver.GitVcsDriver).listBranches({ |
| 510 | + cwd: tmp, |
| 511 | + })).branches.find((branch) => branch.current)!.name; |
| 473 | 512 | |
| 474 | 513 | yield* git(tmp, ["remote", "add", "origin", remote]); |
| 475 | 514 | yield* git(tmp, ["push", "-u", "origin", defaultBranch]); |
| 476 | 515 | |
| 477 | | − yield* (yield* GitCore).createBranch({ cwd: tmp, branch: "feature/local-only" }); |
| 516 | + yield* (yield* GitVcsDriver.GitVcsDriver).createBranch({ |
| 517 | + cwd: tmp, |
| 518 | + branch: "feature/local-only", |
| 519 | + }); |
| 478 | 520 | |
| 479 | 521 | const remoteOnlyBranch = "feature/remote-only"; |
| 480 | | − yield* (yield* GitCore).checkoutBranch({ cwd: tmp, branch: defaultBranch }); |
| 522 | + yield* (yield* GitVcsDriver.GitVcsDriver).checkoutBranch({ |
| 523 | + cwd: tmp, |
| 524 | + branch: defaultBranch, |
| 525 | + }); |
| 481 | 526 | yield* git(tmp, ["checkout", "-b", remoteOnlyBranch]); |
| 482 | 527 | yield* git(tmp, ["push", "-u", "origin", remoteOnlyBranch]); |
| 483 | 528 | yield* git(tmp, ["checkout", defaultBranch]); |
| 484 | 529 | yield* git(tmp, ["branch", "-D", remoteOnlyBranch]); |
| 485 | 530 | |
| 486 | | − const result = yield* (yield* GitCore).listBranches({ cwd: tmp }); |
| 531 | + const result = yield* (yield* GitVcsDriver.GitVcsDriver).listBranches({ cwd: tmp }); |
| 487 | 532 | const firstRemoteIndex = result.branches.findIndex((branch) => branch.isRemote); |
| 488 | 533 | |
| 489 | 534 | expect(result.hasOriginRemote).toBe(true); |
| @@ -515,9 +560,9 @@ it.layer(TestLayer)("git integration", (it) => { · 25 unmodified lines |
| 515 | 560 | |
| 516 | 561 | yield* git(remote, ["init", "--bare"]); |
| 517 | 562 | yield* initRepoWithCommit(tmp); |
| 518 | | − const defaultBranch = (yield* (yield* GitCore).listBranches({ cwd: tmp })).branches.find( |
| 519 | | − (branch) => branch.current, |
| 520 | | − )!.name; |
| 563 | + const defaultBranch = (yield* (yield* GitVcsDriver.GitVcsDriver).listBranches({ |
| 564 | + cwd: tmp, |
| 565 | + })).branches.find((branch) => branch.current)!.name; |
| 521 | 566 | |
| 522 | 567 | yield* git(tmp, ["remote", "add", remoteName, remote]); |
| 523 | 568 | yield* git(tmp, ["push", "-u", remoteName, defaultBranch]); |
| @@ -528,7 +573,7 @@ it.layer(TestLayer)("git integration", (it) => { · 4 unmodified lines |
| 528 | 573 | yield* git(tmp, ["checkout", defaultBranch]); |
| 529 | 574 | yield* git(tmp, ["branch", "-D", remoteOnlyBranch]); |
| 530 | 575 | |
| 531 | | − const result = yield* (yield* GitCore).listBranches({ cwd: tmp }); |
| 576 | + const result = yield* (yield* GitVcsDriver.GitVcsDriver).listBranches({ cwd: tmp }); |
| 532 | 577 | const remoteBranch = result.branches.find( |
| 533 | 578 | (branch) => branch.name === `${remoteName}/${remoteOnlyBranch}`, |
| 534 | 579 | ); |
| @@ -551,7 +596,10 @@ it.layer(TestLayer)("git integration", (it) => { · 16 unmodified lines |
| 551 | 596 | yield* git(tmp, ["remote", "add", "origin", remote]); |
| 552 | 597 | yield* git(tmp, ["push", "-u", "origin", initialBranch]); |
| 553 | 598 | |
| 554 | | − yield* (yield* GitCore).createBranch({ cwd: tmp, branch: "feature/demo" }); |
| 599 | + yield* (yield* GitVcsDriver.GitVcsDriver).createBranch({ |
| 600 | + cwd: tmp, |
| 601 | + branch: "feature/demo", |
| 602 | + }); |
| 555 | 603 | yield* git(tmp, ["push", "-u", "origin", "feature/demo"]); |
| 556 | 604 | |
| 557 | 605 | yield* git(tmp, ["checkout", "-b", "feature/remote-only"]); |
| @@ -559,7 +607,7 @@ it.layer(TestLayer)("git integration", (it) => { · 1 unmodified line |
| 559 | 607 | yield* git(tmp, ["checkout", initialBranch]); |
| 560 | 608 | yield* git(tmp, ["branch", "-D", "feature/remote-only"]); |
| 561 | 609 | |
| 562 | | − const result = yield* (yield* GitCore).listBranches({ |
| 610 | + const result = yield* (yield* GitVcsDriver.GitVcsDriver).listBranches({ |
| 563 | 611 | cwd: tmp, |
| 564 | 612 | query: "feature/", |
| 565 | 613 | limit: 10, |
| @@ -582,11 +630,11 @@ it.layer(TestLayer)("git integration", (it) => { · 16 unmodified lines |
| 582 | 630 | Effect.gen(function* () { |
| 583 | 631 | const tmp = yield* makeTmpDir(); |
| 584 | 632 | yield* initRepoWithCommit(tmp); |
| 585 | | − yield* (yield* GitCore).createBranch({ cwd: tmp, branch: "feature" }); |
| 633 | + yield* (yield* GitVcsDriver.GitVcsDriver).createBranch({ cwd: tmp, branch: "feature" }); |
| 586 | 634 | |
| 587 | | − yield* (yield* GitCore).checkoutBranch({ cwd: tmp, branch: "feature" }); |
| 635 | + yield* (yield* GitVcsDriver.GitVcsDriver).checkoutBranch({ cwd: tmp, branch: "feature" }); |
| 588 | 636 | |
| 589 | | − const result = yield* (yield* GitCore).listBranches({ cwd: tmp }); |
| 637 | + const result = yield* (yield* GitVcsDriver.GitVcsDriver).listBranches({ cwd: tmp }); |
| 590 | 638 | const current = result.branches.find((b) => b.current); |
| 591 | 639 | expect(current!.name).toBe("feature"); |
| 592 | 640 | }), |
| @@ -603,20 +651,29 @@ it.layer(TestLayer)("git integration", (it) => { · 10 unmodified lines |
| 603 | 651 | yield* git(remote, ["init", "--bare"]); |
| 604 | 652 | |
| 605 | 653 | yield* initRepoWithCommit(source); |
| 606 | | − const defaultBranch = (yield* (yield* GitCore).listBranches({ cwd: source })).branches.find( |
| 607 | | − (branch) => branch.current, |
| 608 | | − )!.name; |
| 654 | + const defaultBranch = (yield* (yield* GitVcsDriver.GitVcsDriver).listBranches({ |
| 655 | + cwd: source, |
| 656 | + })).branches.find((branch) => branch.current)!.name; |
| 609 | 657 | yield* git(source, ["remote", "add", "origin", remote]); |
| 610 | 658 | yield* git(source, ["push", "-u", "origin", defaultBranch]); |
| 611 | 659 | |
| 612 | 660 | const featureBranch = "feature-behind"; |
| 613 | | − yield* (yield* GitCore).createBranch({ cwd: source, branch: featureBranch }); |
| 614 | | − yield* (yield* GitCore).checkoutBranch({ cwd: source, branch: featureBranch }); |
| 661 | + yield* (yield* GitVcsDriver.GitVcsDriver).createBranch({ |
| 662 | + cwd: source, |
| 663 | + branch: featureBranch, |
| 664 | + }); |
| 665 | + yield* (yield* GitVcsDriver.GitVcsDriver).checkoutBranch({ |
| 666 | + cwd: source, |
| 667 | + branch: featureBranch, |
| 668 | + }); |
| 615 | 669 | yield* writeTextFile(path.join(source, "feature.txt"), "feature base\n"); |
| 616 | 670 | yield* git(source, ["add", "feature.txt"]); |
| 617 | 671 | yield* git(source, ["commit", "-m", "feature base"]); |
| 618 | 672 | yield* git(source, ["push", "-u", "origin", featureBranch]); |
| 619 | | − yield* (yield* GitCore).checkoutBranch({ cwd: source, branch: defaultBranch }); |
| 673 | + yield* (yield* GitVcsDriver.GitVcsDriver).checkoutBranch({ |
| 674 | + cwd: source, |
| 675 | + branch: defaultBranch, |
| 676 | + }); |
| 620 | 677 | |
| 621 | 678 | yield* git(clone, ["clone", remote, "."]); |
| 622 | 679 | yield* git(clone, ["config", "user.email", "test@test.com"]); |
| @@ -627,8 +684,11 @@ it.layer(TestLayer)("git integration", (it) => { · 4 unmodified lines |
| 627 | 684 | yield* git(clone, ["commit", "-m", "remote feature update"]); |
| 628 | 685 | yield* git(clone, ["push", "origin", featureBranch]); |
| 629 | 686 | |
| 630 | | − yield* (yield* GitCore).checkoutBranch({ cwd: source, branch: featureBranch }); |
| 631 | | − const core = yield* GitCore; |
| 687 | + yield* (yield* GitVcsDriver.GitVcsDriver).checkoutBranch({ |
| 688 | + cwd: source, |
| 689 | + branch: featureBranch, |
| 690 | + }); |
| 691 | + const core = yield* GitVcsDriver.GitVcsDriver; |
| 632 | 692 | yield* Effect.promise(() => |
| 633 | 693 | vi.waitFor( |
| 634 | 694 | async () => { |
| @@ -653,9 +713,9 @@ it.layer(TestLayer)("git integration", (it) => { · 18 unmodified lines |
| 653 | 713 | yield* git(remote, ["init", "--bare"]); |
| 654 | 714 | |
| 655 | 715 | yield* initRepoWithCommit(source); |
| 656 | | − const defaultBranch = (yield* (yield* GitCore).listBranches({ cwd: source })).branches.find( |
| 657 | | − (branch) => branch.current, |
| 658 | | − )!.name; |
| 716 | + const defaultBranch = (yield* (yield* GitVcsDriver.GitVcsDriver).listBranches({ |
| 717 | + cwd: source, |
| 718 | + })).branches.find((branch) => branch.current)!.name; |
| 659 | 719 | yield* git(source, ["remote", "add", "origin", remote]); |
| 660 | 720 | yield* git(source, ["push", "-u", "origin", defaultBranch]); |
| 661 | 721 | |
| @@ -668,9 +728,9 @@ it.layer(TestLayer)("git integration", (it) => { · 6 unmodified lines |
| 668 | 728 | yield* git(source, ["push", "-u", "origin", featureBranch]); |
| 669 | 729 | yield* git(source, ["checkout", defaultBranch]); |
| 670 | 730 | |
| 671 | | − const realGitCore = yield* GitCore; |
| 731 | + const realGitVcsDriver = yield* GitVcsDriver.GitVcsDriver; |
| 672 | 732 | let refreshFetchAttempts = 0; |
| 673 | | − const core = yield* makeIsolatedGitCore((input) => { |
| 733 | + const core = yield* makeIsolatedGitVcsDriver((input) => { |
| 674 | 734 | if (input.args[0] === "--git-dir" && input.args[2] === "fetch") { |
| 675 | 735 | refreshFetchAttempts += 1; |
| 676 | 736 | return Effect.fail( |
| @@ -682,7 +742,7 @@ it.layer(TestLayer)("git integration", (it) => { · 5 unmodified lines |
| 682 | 742 | }), |
| 683 | 743 | ); |
| 684 | 744 | } |
| 685 | | − return realGitCore.execute(input); |
| 745 | + return realGitVcsDriver.execute(input); |
| 686 | 746 | }); |
| 687 | 747 | yield* core.checkoutBranch({ cwd: source, branch: featureBranch }); |
| 688 | 748 | const status = yield* core.statusDetails(source); |
| @@ -700,9 +760,9 @@ it.layer(TestLayer)("git integration", (it) => { · 11 unmodified lines |
| 700 | 760 | yield* git(remote, ["init", "--bare"]); |
| 701 | 761 | |
| 702 | 762 | yield* initRepoWithCommit(source); |
| 703 | | − const defaultBranch = (yield* (yield* GitCore).listBranches({ cwd: source })).branches.find( |
| 704 | | − (branch) => branch.current, |
| 705 | | − )!.name; |
| 763 | + const defaultBranch = (yield* (yield* GitVcsDriver.GitVcsDriver).listBranches({ |
| 764 | + cwd: source, |
| 765 | + })).branches.find((branch) => branch.current)!.name; |
| 706 | 766 | yield* git(source, ["remote", "add", "origin", remote]); |
| 707 | 767 | yield* git(source, ["push", "-u", "origin", defaultBranch]); |
| 708 | 768 | |
| @@ -714,9 +774,9 @@ it.layer(TestLayer)("git integration", (it) => { · 5 unmodified lines |
| 714 | 774 | yield* git(source, ["push", "-u", "origin", featureBranch]); |
| 715 | 775 | yield* git(source, ["checkout", defaultBranch]); |
| 716 | 776 | |
| 717 | | − const realGitCore = yield* GitCore; |
| 777 | + const realGitVcsDriver = yield* GitVcsDriver.GitVcsDriver; |
| 718 | 778 | let refreshFetchAttempts = 0; |
| 719 | | − const core = yield* makeIsolatedGitCore((input) => { |
| 779 | + const core = yield* makeIsolatedGitVcsDriver((input) => { |
| 720 | 780 | if (input.args[0] === "--git-dir" && input.args[2] === "fetch") { |
| 721 | 781 | refreshFetchAttempts += 1; |
| 722 | 782 | return Effect.succeed({ |
| @@ -727,7 +787,7 @@ it.layer(TestLayer)("git integration", (it) => { · 4 unmodified lines |
| 727 | 787 | stderrTruncated: false, |
| 728 | 788 | }); |
| 729 | 789 | } |
| 730 | | − return realGitCore.execute(input); |
| 790 | + return realGitVcsDriver.execute(input); |
| 731 | 791 | }); |
| 732 | 792 | yield* core.checkoutBranch({ cwd: source, branch: featureBranch }); |
| 733 | 793 | yield* Effect.promise(() => new Promise<void>((resolve) => setTimeout(resolve, 50))); |
| @@ -750,7 +810,7 @@ it.layer(TestLayer)("git integration", (it) => { · 16 unmodified lines |
| 750 | 810 | }); |
| 751 | 811 | |
| 752 | 812 | let fetchCount = 0; |
| 753 | | − const core = yield* makeIsolatedGitCore((input) => { |
| 813 | + const core = yield* makeIsolatedGitVcsDriver((input) => { |
| 754 | 814 | if ( |
| 755 | 815 | input.args[0] === "rev-parse" && |
| 756 | 816 | input.args[1] === "--abbrev-ref" && |
| @@ -780,7 +840,7 @@ it.layer(TestLayer)("git integration", (it) => { · 23 unmodified lines |
| 780 | 840 | ]); |
| 781 | 841 | return ok(); |
| 782 | 842 | } |
| 783 | | − if (input.operation === "GitCore.statusDetails.status") { |
| 843 | + if (input.operation === "GitVcsDriver.statusDetails.status") { |
| 784 | 844 | return ok( |
| 785 | 845 | input.cwd === "/repo/worktrees/pr-123" |
| 786 | 846 | ? "# branch.head feature/pr-123\n# branch.upstream origin/feature/pr-123\n# branch.ab +0 -0\n" |
| @@ -788,12 +848,12 @@ it.layer(TestLayer)("git integration", (it) => { · 1 unmodified line |
| 788 | 848 | ); |
| 789 | 849 | } |
| 790 | 850 | if ( |
| 791 | | − input.operation === "GitCore.statusDetails.unstagedNumstat" || |
| 792 | | − input.operation === "GitCore.statusDetails.stagedNumstat" |
| 851 | + input.operation === "GitVcsDriver.statusDetails.unstagedNumstat" || |
| 852 | + input.operation === "GitVcsDriver.statusDetails.stagedNumstat" |
| 793 | 853 | ) { |
| 794 | 854 | return ok(); |
| 795 | 855 | } |
| 796 | | − if (input.operation === "GitCore.statusDetails.defaultRef") { |
| 856 | + if (input.operation === "GitVcsDriver.statusDetails.defaultRef") { |
| 797 | 857 | return ok("refs/remotes/origin/main\n"); |
| 798 | 858 | } |
| 799 | 859 | return Effect.fail( |
| @@ -826,7 +886,7 @@ it.layer(TestLayer)("git integration", (it) => { · 26 unmodified lines |
| 826 | 886 | }); |
| 827 | 887 | |
| 828 | 888 | let fetchCount = 0; |
| 829 | | − const core = yield* makeIsolatedGitCore((input) => { |
| 889 | + const core = yield* makeIsolatedGitVcsDriver((input) => { |
| 830 | 890 | if ( |
| 831 | 891 | input.args[0] === "rev-parse" && |
| 832 | 892 | input.args[1] === "--abbrev-ref" && |
| @@ -856,7 +916,7 @@ it.layer(TestLayer)("git integration", (it) => { · 23 unmodified lines |
| 856 | 916 | }), |
| 857 | 917 | ); |
| 858 | 918 | } |
| 859 | | − if (input.operation === "GitCore.statusDetails.status") { |
| 919 | + if (input.operation === "GitVcsDriver.statusDetails.status") { |
| 860 | 920 | return ok( |
| 861 | 921 | input.cwd === "/repo/worktrees/pr-123" |
| 862 | 922 | ? "# branch.head feature/pr-123\n# branch.upstream origin/feature/pr-123\n# branch.ab +0 -0\n" |
| @@ -864,12 +924,12 @@ it.layer(TestLayer)("git integration", (it) => { · 1 unmodified line |
| 864 | 924 | ); |
| 865 | 925 | } |
| 866 | 926 | if ( |
| 867 | | − input.operation === "GitCore.statusDetails.unstagedNumstat" || |
| 868 | | − input.operation === "GitCore.statusDetails.stagedNumstat" |
| 927 | + input.operation === "GitVcsDriver.statusDetails.unstagedNumstat" || |
| 928 | + input.operation === "GitVcsDriver.statusDetails.stagedNumstat" |
| 869 | 929 | ) { |
| 870 | 930 | return ok(); |
| 871 | 931 | } |
| 872 | | − if (input.operation === "GitCore.statusDetails.defaultRef") { |
| 932 | + if (input.operation === "GitVcsDriver.statusDetails.defaultRef") { |
| 873 | 933 | return ok("refs/remotes/origin/main\n"); |
| 874 | 934 | } |
| 875 | 935 | return Effect.fail( |
| @@ -893,7 +953,7 @@ it.layer(TestLayer)("git integration", (it) => { · 17 unmodified lines |
| 893 | 953 | const tmp = yield* makeTmpDir(); |
| 894 | 954 | yield* initRepoWithCommit(tmp); |
| 895 | 955 | const result = yield* Effect.result( |
| 896 | | − (yield* GitCore).checkoutBranch({ cwd: tmp, branch: "nonexistent" }), |
| 956 | + (yield* GitVcsDriver.GitVcsDriver).checkoutBranch({ cwd: tmp, branch: "nonexistent" }), |
| 897 | 957 | ); |
| 898 | 958 | expect(result._tag).toBe("Failure"); |
| 899 | 959 | }), |
| @@ -906,16 +966,19 @@ it.layer(TestLayer)("git integration", (it) => { · 6 unmodified lines |
| 906 | 966 | yield* git(remote, ["init", "--bare"]); |
| 907 | 967 | |
| 908 | 968 | yield* initRepoWithCommit(source); |
| 909 | | − const defaultBranch = (yield* (yield* GitCore).listBranches({ cwd: source })).branches.find( |
| 910 | | − (branch) => branch.current, |
| 911 | | − )!.name; |
| 969 | + const defaultBranch = (yield* (yield* GitVcsDriver.GitVcsDriver).listBranches({ |
| 970 | + cwd: source, |
| 971 | + })).branches.find((branch) => branch.current)!.name; |
| 912 | 972 | yield* git(source, ["remote", "add", "origin", remote]); |
| 913 | 973 | yield* git(source, ["push", "-u", "origin", defaultBranch]); |
| 914 | 974 | |
| 915 | | − yield* (yield* GitCore).createBranch({ cwd: source, branch: "feature" }); |
| 975 | + yield* (yield* GitVcsDriver.GitVcsDriver).createBranch({ cwd: source, branch: "feature" }); |
| 916 | 976 | |
| 917 | 977 | const checkoutResult = yield* Effect.result( |
| 918 | | − (yield* GitCore).checkoutBranch({ cwd: source, branch: "origin/feature" }), |
| 978 | + (yield* GitVcsDriver.GitVcsDriver).checkoutBranch({ |
| 979 | + cwd: source, |
| 980 | + branch: "origin/feature", |
| 981 | + }), |
| 919 | 982 | ); |
| 920 | 983 | expect(checkoutResult._tag).toBe("Failure"); |
| 921 | 984 | expect(yield* git(source, ["branch", "--show-current"])).toBe(defaultBranch); |
| @@ -935,9 +998,9 @@ it.layer(TestLayer)("git integration", (it) => { · 13 unmodified lines |
| 935 | 998 | yield* git(prefixRemote, ["init", "--bare"]); |
| 936 | 999 | |
| 937 | 1000 | yield* initRepoWithCommit(source); |
| 938 | | − const defaultBranch = (yield* (yield* GitCore).listBranches({ cwd: source })).branches.find( |
| 939 | | − (branch) => branch.current, |
| 940 | | − )!.name; |
| 1001 | + const defaultBranch = (yield* (yield* GitVcsDriver.GitVcsDriver).listBranches({ |
| 1002 | + cwd: source, |
| 1003 | + })).branches.find((branch) => branch.current)!.name; |
| 941 | 1004 | yield* configureRemote(source, prefixRemoteName, prefixRemote, prefixFetchNamespace); |
| 942 | 1005 | yield* configureRemote(source, remoteName, remote, remoteName); |
| 943 | 1006 | yield* git(source, ["push", "-u", remoteName, defaultBranch]); |
| @@ -950,16 +1013,16 @@ it.layer(TestLayer)("git integration", (it) => { · 6 unmodified lines |
| 950 | 1013 | yield* git(source, ["checkout", defaultBranch]); |
| 951 | 1014 | yield* git(source, ["branch", "-D", featureBranch]); |
| 952 | 1015 | |
| 953 | | − const checkoutResult = yield* (yield* GitCore).checkoutBranch({ |
| 1016 | + const checkoutResult = yield* (yield* GitVcsDriver.GitVcsDriver).checkoutBranch({ |
| 954 | 1017 | cwd: source, |
| 955 | 1018 | branch: `${remoteName}/${featureBranch}`, |
| 956 | 1019 | }); |
| 957 | 1020 | |
| 958 | 1021 | expect(checkoutResult.branch).toBe("upstream/feature"); |
| 959 | 1022 | expect(yield* git(source, ["branch", "--show-current"])).toBe("upstream/feature"); |
| 960 | | − const realGitCore = yield* GitCore; |
| 1023 | + const realGitVcsDriver = yield* GitVcsDriver.GitVcsDriver; |
| 961 | 1024 | let fetchArgs: readonly string[] | null = null; |
| 962 | | − const core = yield* makeIsolatedGitCore((input) => { |
| 1025 | + const core = yield* makeIsolatedGitVcsDriver((input) => { |
| 963 | 1026 | if (input.args[0] === "--git-dir" && input.args[2] === "fetch") { |
| 964 | 1027 | fetchArgs = [...input.args]; |
| 965 | 1028 | return Effect.succeed({ |
| @@ -970,7 +1033,7 @@ it.layer(TestLayer)("git integration", (it) => { · 4 unmodified lines |
| 970 | 1033 | stderrTruncated: false, |
| 971 | 1034 | }); |
| 972 | 1035 | } |
| 973 | | − return realGitCore.execute(input); |
| 1036 | + return realGitVcsDriver.execute(input); |
| 974 | 1037 | }); |
| 975 | 1038 | |
| 976 | 1039 | const status = yield* core.statusDetails(source); |
| @@ -996,7 +1059,7 @@ it.layer(TestLayer)("git integration", (it) => { · 19 unmodified lines |
| 996 | 1059 | yield* git(remote, ["init", "--bare"]); |
| 997 | 1060 | |
| 998 | 1061 | yield* initRepoWithCommit(source); |
| 999 | | − const defaultBranch = (yield* (yield* GitCore).listBranches({ |
| 1062 | + const defaultBranch = (yield* (yield* GitVcsDriver.GitVcsDriver).listBranches({ |
| 1000 | 1063 | cwd: source, |
| 1001 | 1064 | })).branches.find((branch) => branch.current)!.name; |
| 1002 | 1065 | yield* git(source, ["remote", "add", "origin", remote]); |
| @@ -1006,12 +1069,12 @@ it.layer(TestLayer)("git integration", (it) => { · 3 unmodified lines |
| 1006 | 1069 | // would attempt to create an already-existing local branch. |
| 1007 | 1070 | yield* git(source, ["branch", "--unset-upstream"]); |
| 1008 | 1071 | |
| 1009 | | − yield* (yield* GitCore).checkoutBranch({ |
| 1072 | + yield* (yield* GitVcsDriver.GitVcsDriver).checkoutBranch({ |
| 1010 | 1073 | cwd: source, |
| 1011 | 1074 | branch: `origin/${defaultBranch}`, |
| 1012 | 1075 | }); |
| 1013 | 1076 | |
| 1014 | | − const core = yield* GitCore; |
| 1077 | + const core = yield* GitVcsDriver.GitVcsDriver; |
| 1015 | 1078 | const status = yield* core.statusDetails(source); |
| 1016 | 1079 | expect(status.branch).toBeNull(); |
| 1017 | 1080 | }), |
| @@ -1021,7 +1084,7 @@ it.layer(TestLayer)("git integration", (it) => { · 3 unmodified lines |
| 1021 | 1084 | Effect.gen(function* () { |
| 1022 | 1085 | const tmp = yield* makeTmpDir(); |
| 1023 | 1086 | yield* initRepoWithCommit(tmp); |
| 1024 | | − yield* (yield* GitCore).createBranch({ cwd: tmp, branch: "other" }); |
| 1087 | + yield* (yield* GitVcsDriver.GitVcsDriver).createBranch({ cwd: tmp, branch: "other" }); |
| 1025 | 1088 | |
| 1026 | 1089 | // Create a conflicting change: modify README on current branch |
| 1027 | 1090 | yield* writeTextFile(path.join(tmp, "README.md"), "modified\n"); |
| @@ -1029,23 +1092,26 @@ it.layer(TestLayer)("git integration", (it) => { · 1 unmodified line |
| 1029 | 1092 | |
| 1030 | 1093 | // First, checkout other branch cleanly |
| 1031 | 1094 | yield* git(tmp, ["stash"]); |
| 1032 | | − yield* (yield* GitCore).checkoutBranch({ cwd: tmp, branch: "other" }); |
| 1095 | + yield* (yield* GitVcsDriver.GitVcsDriver).checkoutBranch({ cwd: tmp, branch: "other" }); |
| 1033 | 1096 | yield* writeTextFile(path.join(tmp, "README.md"), "other content\n"); |
| 1034 | 1097 | yield* git(tmp, ["add", "."]); |
| 1035 | 1098 | yield* git(tmp, ["commit", "-m", "other change"]); |
| 1036 | 1099 | |
| 1037 | 1100 | // Go back to default branch |
| 1038 | | − const defaultBranch = (yield* (yield* GitCore).listBranches({ cwd: tmp })).branches.find( |
| 1039 | | − (b) => !b.current, |
| 1040 | | − )!.name; |
| 1041 | | − yield* (yield* GitCore).checkoutBranch({ cwd: tmp, branch: defaultBranch }); |
| 1101 | + const defaultBranch = (yield* (yield* GitVcsDriver.GitVcsDriver).listBranches({ |
| 1102 | + cwd: tmp, |
| 1103 | + })).branches.find((b) => !b.current)!.name; |
| 1104 | + yield* (yield* GitVcsDriver.GitVcsDriver).checkoutBranch({ |
| 1105 | + cwd: tmp, |
| 1106 | + branch: defaultBranch, |
| 1107 | + }); |
| 1042 | 1108 | |
| 1043 | 1109 | // Make uncommitted changes to the same file |
| 1044 | 1110 | yield* writeTextFile(path.join(tmp, "README.md"), "conflicting local\n"); |
| 1045 | 1111 | |
| 1046 | 1112 | // Checkout should fail due to uncommitted changes |
| 1047 | 1113 | const result = yield* Effect.result( |
| 1048 | | − (yield* GitCore).checkoutBranch({ cwd: tmp, branch: "other" }), |
| 1114 | + (yield* GitVcsDriver.GitVcsDriver).checkoutBranch({ cwd: tmp, branch: "other" }), |
| 1049 | 1115 | ); |
| 1050 | 1116 | expect(result._tag).toBe("Failure"); |
| 1051 | 1117 | }), |
| @@ -1059,9 +1125,9 @@ it.layer(TestLayer)("git integration", (it) => { · 7 unmodified lines |
| 1059 | 1125 | Effect.gen(function* () { |
| 1060 | 1126 | const tmp = yield* makeTmpDir(); |
| 1061 | 1127 | yield* initRepoWithCommit(tmp); |
| 1062 | | − yield* (yield* GitCore).createBranch({ cwd: tmp, branch: "new-feature" }); |
| 1128 | + yield* (yield* GitVcsDriver.GitVcsDriver).createBranch({ cwd: tmp, branch: "new-feature" }); |
| 1063 | 1129 | |
| 1064 | | − const result = yield* (yield* GitCore).listBranches({ cwd: tmp }); |
| 1130 | + const result = yield* (yield* GitVcsDriver.GitVcsDriver).listBranches({ cwd: tmp }); |
| 1065 | 1131 | expect(result.branches.some((b) => b.name === "new-feature")).toBe(true); |
| 1066 | 1132 | }), |
| 1067 | 1133 | ); |
| @@ -1070,9 +1136,9 @@ it.layer(TestLayer)("git integration", (it) => { · 2 unmodified lines |
| 1070 | 1136 | Effect.gen(function* () { |
| 1071 | 1137 | const tmp = yield* makeTmpDir(); |
| 1072 | 1138 | yield* initRepoWithCommit(tmp); |
| 1073 | | − yield* (yield* GitCore).createBranch({ cwd: tmp, branch: "dupe" }); |
| 1139 | + yield* (yield* GitVcsDriver.GitVcsDriver).createBranch({ cwd: tmp, branch: "dupe" }); |
| 1074 | 1140 | const result = yield* Effect.result( |
| 1075 | | − (yield* GitCore).createBranch({ cwd: tmp, branch: "dupe" }), |
| 1141 | + (yield* GitVcsDriver.GitVcsDriver).createBranch({ cwd: tmp, branch: "dupe" }), |
| 1076 | 1142 | ); |
| 1077 | 1143 | expect(result._tag).toBe("Failure"); |
| 1078 | 1144 | }), |
| @@ -1086,10 +1152,16 @@ it.layer(TestLayer)("git integration", (it) => { · 7 unmodified lines |
| 1086 | 1152 | Effect.gen(function* () { |
| 1087 | 1153 | const tmp = yield* makeTmpDir(); |
| 1088 | 1154 | yield* initRepoWithCommit(tmp); |
| 1089 | | − yield* (yield* GitCore).createBranch({ cwd: tmp, branch: "feature/old-name" }); |
| 1090 | | − yield* (yield* GitCore).checkoutBranch({ cwd: tmp, branch: "feature/old-name" }); |
| 1155 | + yield* (yield* GitVcsDriver.GitVcsDriver).createBranch({ |
| 1156 | + cwd: tmp, |
| 1157 | + branch: "feature/old-name", |
| 1158 | + }); |
| 1159 | + yield* (yield* GitVcsDriver.GitVcsDriver).checkoutBranch({ |
| 1160 | + cwd: tmp, |
| 1161 | + branch: "feature/old-name", |
| 1162 | + }); |
| 1091 | 1163 | |
| 1092 | | − const renamed = yield* (yield* GitCore).renameBranch({ |
| 1164 | + const renamed = yield* (yield* GitVcsDriver.GitVcsDriver).renameBranch({ |
| 1093 | 1165 | cwd: tmp, |
| 1094 | 1166 | oldBranch: "feature/old-name", |
| 1095 | 1167 | newBranch: "feature/new-name", |
| @@ -1097,7 +1169,7 @@ it.layer(TestLayer)("git integration", (it) => { · 1 unmodified line |
| 1097 | 1169 | |
| 1098 | 1170 | expect(renamed.branch).toBe("feature/new-name"); |
| 1099 | 1171 | |
| 1100 | | − const branches = yield* (yield* GitCore).listBranches({ cwd: tmp }); |
| 1172 | + const branches = yield* (yield* GitVcsDriver.GitVcsDriver).listBranches({ cwd: tmp }); |
| 1101 | 1173 | expect(branches.branches.some((branch) => branch.name === "feature/old-name")).toBe(false); |
| 1102 | 1174 | const current = branches.branches.find((branch) => branch.current); |
| 1103 | 1175 | expect(current?.name).toBe("feature/new-name"); |
| @@ -1108,11 +1180,11 @@ it.layer(TestLayer)("git integration", (it) => { · 4 unmodified lines |
| 1108 | 1180 | Effect.gen(function* () { |
| 1109 | 1181 | const tmp = yield* makeTmpDir(); |
| 1110 | 1182 | yield* initRepoWithCommit(tmp); |
| 1111 | | − const current = (yield* (yield* GitCore).listBranches({ cwd: tmp })).branches.find( |
| 1112 | | − (b) => b.current, |
| 1113 | | − )!; |
| 1183 | + const current = (yield* (yield* GitVcsDriver.GitVcsDriver).listBranches({ |
| 1184 | + cwd: tmp, |
| 1185 | + })).branches.find((b) => b.current)!; |
| 1114 | 1186 | |
| 1115 | | − const renamed = yield* (yield* GitCore).renameBranch({ |
| 1187 | + const renamed = yield* (yield* GitVcsDriver.GitVcsDriver).renameBranch({ |
| 1116 | 1188 | cwd: tmp, |
| 1117 | 1189 | oldBranch: current.name, |
| 1118 | 1190 | newBranch: current.name, |
| @@ -1126,18 +1198,27 @@ it.layer(TestLayer)("git integration", (it) => { · 7 unmodified lines |
| 1126 | 1198 | Effect.gen(function* () { |
| 1127 | 1199 | const tmp = yield* makeTmpDir(); |
| 1128 | 1200 | yield* initRepoWithCommit(tmp); |
| 1129 | | − yield* (yield* GitCore).createBranch({ cwd: tmp, branch: "t3code/feat/session" }); |
| 1130 | | − yield* (yield* GitCore).createBranch({ cwd: tmp, branch: "t3code/tmp-working" }); |
| 1131 | | − yield* (yield* GitCore).checkoutBranch({ cwd: tmp, branch: "t3code/tmp-working" }); |
| 1201 | + yield* (yield* GitVcsDriver.GitVcsDriver).createBranch({ |
| 1202 | + cwd: tmp, |
| 1203 | + branch: "t3code/feat/session", |
| 1204 | + }); |
| 1205 | + yield* (yield* GitVcsDriver.GitVcsDriver).createBranch({ |
| 1206 | + cwd: tmp, |
| 1207 | + branch: "t3code/tmp-working", |
| 1208 | + }); |
| 1209 | + yield* (yield* GitVcsDriver.GitVcsDriver).checkoutBranch({ |
| 1210 | + cwd: tmp, |
| 1211 | + branch: "t3code/tmp-working", |
| 1212 | + }); |
| 1132 | 1213 | |
| 1133 | | − const renamed = yield* (yield* GitCore).renameBranch({ |
| 1214 | + const renamed = yield* (yield* GitVcsDriver.GitVcsDriver).renameBranch({ |
| 1134 | 1215 | cwd: tmp, |
| 1135 | 1216 | oldBranch: "t3code/tmp-working", |
| 1136 | 1217 | newBranch: "t3code/feat/session", |
| 1137 | 1218 | }); |
| 1138 | 1219 | |
| 1139 | 1220 | expect(renamed.branch).toBe("t3code/feat/session-1"); |
| 1140 | | − const branches = yield* (yield* GitCore).listBranches({ cwd: tmp }); |
| 1221 | + const branches = yield* (yield* GitVcsDriver.GitVcsDriver).listBranches({ cwd: tmp }); |
| 1141 | 1222 | expect(branches.branches.some((branch) => branch.name === "t3code/feat/session")).toBe( |
| 1142 | 1223 | true, |
| 1143 | 1224 | ); |
| @@ -1153,12 +1234,24 @@ it.layer(TestLayer)("git integration", (it) => { · 9 unmodified lines |
| 1153 | 1234 | Effect.gen(function* () { |
| 1154 | 1235 | const tmp = yield* makeTmpDir(); |
| 1155 | 1236 | yield* initRepoWithCommit(tmp); |
| 1156 | | − yield* (yield* GitCore).createBranch({ cwd: tmp, branch: "t3code/feat/session" }); |
| 1157 | | − yield* (yield* GitCore).createBranch({ cwd: tmp, branch: "t3code/feat/session-1" }); |
| 1158 | | − yield* (yield* GitCore).createBranch({ cwd: tmp, branch: "t3code/tmp-working" }); |
| 1159 | | − yield* (yield* GitCore).checkoutBranch({ cwd: tmp, branch: "t3code/tmp-working" }); |
| 1237 | + yield* (yield* GitVcsDriver.GitVcsDriver).createBranch({ |
| 1238 | + cwd: tmp, |
| 1239 | + branch: "t3code/feat/session", |
| 1240 | + }); |
| 1241 | + yield* (yield* GitVcsDriver.GitVcsDriver).createBranch({ |
| 1242 | + cwd: tmp, |
| 1243 | + branch: "t3code/feat/session-1", |
| 1244 | + }); |
| 1245 | + yield* (yield* GitVcsDriver.GitVcsDriver).createBranch({ |
| 1246 | + cwd: tmp, |
| 1247 | + branch: "t3code/tmp-working", |
| 1248 | + }); |
| 1249 | + yield* (yield* GitVcsDriver.GitVcsDriver).checkoutBranch({ |
| 1250 | + cwd: tmp, |
| 1251 | + branch: "t3code/tmp-working", |
| 1252 | + }); |
| 1160 | 1253 | |
| 1161 | | − const renamed = yield* (yield* GitCore).renameBranch({ |
| 1254 | + const renamed = yield* (yield* GitVcsDriver.GitVcsDriver).renameBranch({ |
| 1162 | 1255 | cwd: tmp, |
| 1163 | 1256 | oldBranch: "t3code/tmp-working", |
| 1164 | 1257 | newBranch: "t3code/feat/session", |
| @@ -1172,16 +1265,22 @@ it.layer(TestLayer)("git integration", (it) => { · 7 unmodified lines |
| 1172 | 1265 | Effect.gen(function* () { |
| 1173 | 1266 | const tmp = yield* makeTmpDir(); |
| 1174 | 1267 | yield* initRepoWithCommit(tmp); |
| 1175 | | − yield* (yield* GitCore).createBranch({ cwd: tmp, branch: "feature/old-name" }); |
| 1176 | | − yield* (yield* GitCore).checkoutBranch({ cwd: tmp, branch: "feature/old-name" }); |
| 1268 | + yield* (yield* GitVcsDriver.GitVcsDriver).createBranch({ |
| 1269 | + cwd: tmp, |
| 1270 | + branch: "feature/old-name", |
| 1271 | + }); |
| 1272 | + yield* (yield* GitVcsDriver.GitVcsDriver).checkoutBranch({ |
| 1273 | + cwd: tmp, |
| 1274 | + branch: "feature/old-name", |
| 1275 | + }); |
| 1177 | 1276 | |
| 1178 | | − const realGitCore = yield* GitCore; |
| 1277 | + const realGitVcsDriver = yield* GitVcsDriver.GitVcsDriver; |
| 1179 | 1278 | let renameArgs: ReadonlyArray<string> | null = null; |
| 1180 | | − const core = yield* makeIsolatedGitCore((input) => { |
| 1279 | + const core = yield* makeIsolatedGitVcsDriver((input) => { |
| 1181 | 1280 | if (input.args[0] === "branch" && input.args[1] === "-m") { |
| 1182 | 1281 | renameArgs = [...input.args]; |
| 1183 | 1282 | } |
| 1184 | | − return realGitCore.execute(input); |
| 1283 | + return realGitVcsDriver.execute(input); |
| 1185 | 1284 | }); |
| 1186 | 1285 | |
| 1187 | 1286 | const renamed = yield* core.renameBranch({ |
| @@ -1205,11 +1304,11 @@ it.layer(TestLayer)("git integration", (it) => { · 17 unmodified lines |
| 1205 | 1304 | yield* initRepoWithCommit(tmp); |
| 1206 | 1305 | |
| 1207 | 1306 | const wtPath = path.join(tmp, "worktree-out"); |
| 1208 | | − const currentBranch = (yield* (yield* GitCore).listBranches({ cwd: tmp })).branches.find( |
| 1209 | | − (b) => b.current, |
| 1210 | | − )!.name; |
| 1307 | + const currentBranch = (yield* (yield* GitVcsDriver.GitVcsDriver).listBranches({ |
| 1308 | + cwd: tmp, |
| 1309 | + })).branches.find((b) => b.current)!.name; |
| 1211 | 1310 | |
| 1212 | | − const result = yield* (yield* GitCore).createWorktree({ |
| 1311 | + const result = yield* (yield* GitVcsDriver.GitVcsDriver).createWorktree({ |
| 1213 | 1312 | cwd: tmp, |
| 1214 | 1313 | branch: currentBranch, |
| 1215 | 1314 | newBranch: "wt-branch", |
| @@ -1222,7 +1321,7 @@ it.layer(TestLayer)("git integration", (it) => { · 6 unmodified lines |
| 1222 | 1321 | expect(existsSync(path.join(wtPath, "README.md"))).toBe(true); |
| 1223 | 1322 | |
| 1224 | 1323 | // Clean up worktree before tmp dir disposal |
| 1225 | | − yield* (yield* GitCore).removeWorktree({ cwd: tmp, path: wtPath }); |
| 1324 | + yield* (yield* GitVcsDriver.GitVcsDriver).removeWorktree({ cwd: tmp, path: wtPath }); |
| 1226 | 1325 | }), |
| 1227 | 1326 | ); |
| 1228 | 1327 | |
| @@ -1232,11 +1331,11 @@ it.layer(TestLayer)("git integration", (it) => { · 3 unmodified lines |
| 1232 | 1331 | yield* initRepoWithCommit(tmp); |
| 1233 | 1332 | |
| 1234 | 1333 | const wtPath = path.join(tmp, "wt-check-dir"); |
| 1235 | | − const currentBranch = (yield* (yield* GitCore).listBranches({ cwd: tmp })).branches.find( |
| 1236 | | − (b) => b.current, |
| 1237 | | − )!.name; |
| 1334 | + const currentBranch = (yield* (yield* GitVcsDriver.GitVcsDriver).listBranches({ |
| 1335 | + cwd: tmp, |
| 1336 | + })).branches.find((b) => b.current)!.name; |
| 1238 | 1337 | |
| 1239 | | − yield* (yield* GitCore).createWorktree({ |
| 1338 | + yield* (yield* GitVcsDriver.GitVcsDriver).createWorktree({ |
| 1240 | 1339 | cwd: tmp, |
| 1241 | 1340 | branch: currentBranch, |
| 1242 | 1341 | newBranch: "wt-check", |
| @@ -1247,7 +1346,7 @@ it.layer(TestLayer)("git integration", (it) => { · 4 unmodified lines |
| 1247 | 1346 | const branchOutput = yield* git(wtPath, ["branch", "--show-current"]); |
| 1248 | 1347 | expect(branchOutput).toBe("wt-check"); |
| 1249 | 1348 | |
| 1250 | | − yield* (yield* GitCore).removeWorktree({ cwd: tmp, path: wtPath }); |
| 1349 | + yield* (yield* GitVcsDriver.GitVcsDriver).removeWorktree({ cwd: tmp, path: wtPath }); |
| 1251 | 1350 | }), |
| 1252 | 1351 | ); |
| 1253 | 1352 | |
| @@ -1255,10 +1354,13 @@ it.layer(TestLayer)("git integration", (it) => { · 1 unmodified line |
| 1255 | 1354 | Effect.gen(function* () { |
| 1256 | 1355 | const tmp = yield* makeTmpDir(); |
| 1257 | 1356 | yield* initRepoWithCommit(tmp); |
| 1258 | | − yield* (yield* GitCore).createBranch({ cwd: tmp, branch: "feature/existing-worktree" }); |
| 1357 | + yield* (yield* GitVcsDriver.GitVcsDriver).createBranch({ |
| 1358 | + cwd: tmp, |
| 1359 | + branch: "feature/existing-worktree", |
| 1360 | + }); |
| 1259 | 1361 | |
| 1260 | 1362 | const wtPath = path.join(tmp, "wt-existing"); |
| 1261 | | − const result = yield* (yield* GitCore).createWorktree({ |
| 1363 | + const result = yield* (yield* GitVcsDriver.GitVcsDriver).createWorktree({ |
| 1262 | 1364 | cwd: tmp, |
| 1263 | 1365 | branch: "feature/existing-worktree", |
| 1264 | 1366 | path: wtPath, |
| @@ -1269,7 +1371,7 @@ it.layer(TestLayer)("git integration", (it) => { · 4 unmodified lines |
| 1269 | 1371 | const branchOutput = yield* git(wtPath, ["branch", "--show-current"]); |
| 1270 | 1372 | expect(branchOutput).toBe("feature/existing-worktree"); |
| 1271 | 1373 | |
| 1272 | | − yield* (yield* GitCore).removeWorktree({ cwd: tmp, path: wtPath }); |
| 1374 | + yield* (yield* GitVcsDriver.GitVcsDriver).removeWorktree({ cwd: tmp, path: wtPath }); |
| 1273 | 1375 | }), |
| 1274 | 1376 | ); |
| 1275 | 1377 | |
| @@ -1277,15 +1379,15 @@ it.layer(TestLayer)("git integration", (it) => { · 1 unmodified line |
| 1277 | 1379 | Effect.gen(function* () { |
| 1278 | 1380 | const tmp = yield* makeTmpDir(); |
| 1279 | 1381 | yield* initRepoWithCommit(tmp); |
| 1280 | | − yield* (yield* GitCore).createBranch({ cwd: tmp, branch: "existing" }); |
| 1382 | + yield* (yield* GitVcsDriver.GitVcsDriver).createBranch({ cwd: tmp, branch: "existing" }); |
| 1281 | 1383 | |
| 1282 | 1384 | const wtPath = path.join(tmp, "wt-conflict"); |
| 1283 | | − const currentBranch = (yield* (yield* GitCore).listBranches({ cwd: tmp })).branches.find( |
| 1284 | | − (b) => b.current, |
| 1285 | | − )!.name; |
| 1385 | + const currentBranch = (yield* (yield* GitVcsDriver.GitVcsDriver).listBranches({ |
| 1386 | + cwd: tmp, |
| 1387 | + })).branches.find((b) => b.current)!.name; |
| 1286 | 1388 | |
| 1287 | 1389 | const result = yield* Effect.result( |
| 1288 | | − (yield* GitCore).createWorktree({ |
| 1390 | + (yield* GitVcsDriver.GitVcsDriver).createWorktree({ |
| 1289 | 1391 | cwd: tmp, |
| 1290 | 1392 | branch: currentBranch, |
| 1291 | 1393 | newBranch: "existing", |
| @@ -1302,11 +1404,11 @@ it.layer(TestLayer)("git integration", (it) => { · 10 unmodified lines |
| 1302 | 1404 | yield* initRepoWithCommit(tmp); |
| 1303 | 1405 | |
| 1304 | 1406 | const wtPath = path.join(tmp, "wt-list-dir"); |
| 1305 | | − const mainBranch = (yield* (yield* GitCore).listBranches({ cwd: tmp })).branches.find( |
| 1306 | | − (b) => b.current, |
| 1307 | | − )!.name; |
| 1407 | + const mainBranch = (yield* (yield* GitVcsDriver.GitVcsDriver).listBranches({ |
| 1408 | + cwd: tmp, |
| 1409 | + })).branches.find((b) => b.current)!.name; |
| 1308 | 1410 | |
| 1309 | | − yield* (yield* GitCore).createWorktree({ |
| 1411 | + yield* (yield* GitVcsDriver.GitVcsDriver).createWorktree({ |
| 1310 | 1412 | cwd: tmp, |
| 1311 | 1413 | branch: mainBranch, |
| 1312 | 1414 | newBranch: "wt-list", |
| @@ -1314,17 +1416,17 @@ it.layer(TestLayer)("git integration", (it) => { · 1 unmodified line |
| 1314 | 1416 | }); |
| 1315 | 1417 | |
| 1316 | 1418 | // listGitBranches from the worktree should show wt-list as current |
| 1317 | | − const wtBranches = yield* (yield* GitCore).listBranches({ cwd: wtPath }); |
| 1419 | + const wtBranches = yield* (yield* GitVcsDriver.GitVcsDriver).listBranches({ cwd: wtPath }); |
| 1318 | 1420 | expect(wtBranches.isRepo).toBe(true); |
| 1319 | 1421 | const wtCurrent = wtBranches.branches.find((b) => b.current); |
| 1320 | 1422 | expect(wtCurrent!.name).toBe("wt-list"); |
| 1321 | 1423 | |
| 1322 | 1424 | // Main repo should still show the original branch as current |
| 1323 | | − const mainBranches = yield* (yield* GitCore).listBranches({ cwd: tmp }); |
| 1425 | + const mainBranches = yield* (yield* GitVcsDriver.GitVcsDriver).listBranches({ cwd: tmp }); |
| 1324 | 1426 | const mainCurrent = mainBranches.branches.find((b) => b.current); |
| 1325 | 1427 | expect(mainCurrent!.name).toBe(mainBranch); |
| 1326 | 1428 | |
| 1327 | | − yield* (yield* GitCore).removeWorktree({ cwd: tmp, path: wtPath }); |
| 1429 | + yield* (yield* GitVcsDriver.GitVcsDriver).removeWorktree({ cwd: tmp, path: wtPath }); |
| 1328 | 1430 | }), |
| 1329 | 1431 | ); |
| 1330 | 1432 | |
| @@ -1334,11 +1436,11 @@ it.layer(TestLayer)("git integration", (it) => { · 3 unmodified lines |
| 1334 | 1436 | yield* initRepoWithCommit(tmp); |
| 1335 | 1437 | |
| 1336 | 1438 | const wtPath = path.join(tmp, "wt-remove-dir"); |
| 1337 | | − const currentBranch = (yield* (yield* GitCore).listBranches({ cwd: tmp })).branches.find( |
| 1338 | | − (b) => b.current, |
| 1339 | | − )!.name; |
| 1439 | + const currentBranch = (yield* (yield* GitVcsDriver.GitVcsDriver).listBranches({ |
| 1440 | + cwd: tmp, |
| 1441 | + })).branches.find((b) => b.current)!.name; |
| 1340 | 1442 | |
| 1341 | | − yield* (yield* GitCore).createWorktree({ |
| 1443 | + yield* (yield* GitVcsDriver.GitVcsDriver).createWorktree({ |
| 1342 | 1444 | cwd: tmp, |
| 1343 | 1445 | branch: currentBranch, |
| 1344 | 1446 | newBranch: "wt-remove", |
| @@ -1346,7 +1448,7 @@ it.layer(TestLayer)("git integration", (it) => { · 1 unmodified line |
| 1346 | 1448 | }); |
| 1347 | 1449 | expect(existsSync(wtPath)).toBe(true); |
| 1348 | 1450 | |
| 1349 | | − yield* (yield* GitCore).removeWorktree({ cwd: tmp, path: wtPath }); |
| 1451 | + yield* (yield* GitVcsDriver.GitVcsDriver).removeWorktree({ cwd: tmp, path: wtPath }); |
| 1350 | 1452 | expect(existsSync(wtPath)).toBe(false); |
| 1351 | 1453 | }), |
| 1352 | 1454 | ); |
| @@ -1357,11 +1459,11 @@ it.layer(TestLayer)("git integration", (it) => { · 4 unmodified lines |
| 1357 | 1459 | yield* initRepoWithCommit(tmp); |
| 1358 | 1460 | |
| 1359 | 1461 | const wtPath = path.join(tmp, "wt-dirty-dir"); |
| 1360 | | − const currentBranch = (yield* (yield* GitCore).listBranches({ cwd: tmp })).branches.find( |
| 1361 | | − (b) => b.current, |
| 1362 | | − )!.name; |
| 1462 | + const currentBranch = (yield* (yield* GitVcsDriver.GitVcsDriver).listBranches({ |
| 1463 | + cwd: tmp, |
| 1464 | + })).branches.find((b) => b.current)!.name; |
| 1363 | 1465 | |
| 1364 | | − yield* (yield* GitCore).createWorktree({ |
| 1466 | + yield* (yield* GitVcsDriver.GitVcsDriver).createWorktree({ |
| 1365 | 1467 | cwd: tmp, |
| 1366 | 1468 | branch: currentBranch, |
| 1367 | 1469 | newBranch: "wt-dirty", |
| @@ -1372,12 +1474,16 @@ it.layer(TestLayer)("git integration", (it) => { · 4 unmodified lines |
| 1372 | 1474 | yield* writeTextFile(path.join(wtPath, "README.md"), "dirty change\n"); |
| 1373 | 1475 | |
| 1374 | 1476 | const failedRemove = yield* Effect.result( |
| 1375 | | − (yield* GitCore).removeWorktree({ cwd: tmp, path: wtPath }), |
| 1477 | + (yield* GitVcsDriver.GitVcsDriver).removeWorktree({ cwd: tmp, path: wtPath }), |
| 1376 | 1478 | ); |
| 1377 | 1479 | expect(failedRemove._tag).toBe("Failure"); |
| 1378 | 1480 | expect(existsSync(wtPath)).toBe(true); |
| 1379 | 1481 | |
| 1380 | | − yield* (yield* GitCore).removeWorktree({ cwd: tmp, path: wtPath, force: true }); |
| 1482 | + yield* (yield* GitVcsDriver.GitVcsDriver).removeWorktree({ |
| 1483 | + cwd: tmp, |
| 1484 | + path: wtPath, |
| 1485 | + force: true, |
| 1486 | + }); |
| 1381 | 1487 | expect(existsSync(wtPath)).toBe(false); |
| 1382 | 1488 | }), |
| 1383 | 1489 | ); |
| @@ -1390,10 +1496,16 @@ it.layer(TestLayer)("git integration", (it) => { · 6 unmodified lines |
| 1390 | 1496 | Effect.gen(function* () { |
| 1391 | 1497 | const tmp = yield* makeTmpDir(); |
| 1392 | 1498 | yield* initRepoWithCommit(tmp); |
| 1393 | | − yield* (yield* GitCore).createBranch({ cwd: tmp, branch: "feature-login" }); |
| 1394 | | − yield* (yield* GitCore).checkoutBranch({ cwd: tmp, branch: "feature-login" }); |
| 1499 | + yield* (yield* GitVcsDriver.GitVcsDriver).createBranch({ |
| 1500 | + cwd: tmp, |
| 1501 | + branch: "feature-login", |
| 1502 | + }); |
| 1503 | + yield* (yield* GitVcsDriver.GitVcsDriver).checkoutBranch({ |
| 1504 | + cwd: tmp, |
| 1505 | + branch: "feature-login", |
| 1506 | + }); |
| 1395 | 1507 | |
| 1396 | | − const result = yield* (yield* GitCore).listBranches({ cwd: tmp }); |
| 1508 | + const result = yield* (yield* GitVcsDriver.GitVcsDriver).listBranches({ cwd: tmp }); |
| 1397 | 1509 | const current = result.branches.find((b) => b.current); |
| 1398 | 1510 | expect(current!.name).toBe("feature-login"); |
| 1399 | 1511 | }), |
| @@ -1408,12 +1520,12 @@ it.layer(TestLayer)("git integration", (it) => { · 8 unmodified lines |
| 1408 | 1520 | const tmp = yield* makeTmpDir(); |
| 1409 | 1521 | yield* initRepoWithCommit(tmp); |
| 1410 | 1522 | |
| 1411 | | − const currentBranch = (yield* (yield* GitCore).listBranches({ cwd: tmp })).branches.find( |
| 1412 | | − (b) => b.current, |
| 1413 | | − )!.name; |
| 1523 | + const currentBranch = (yield* (yield* GitVcsDriver.GitVcsDriver).listBranches({ |
| 1524 | + cwd: tmp, |
| 1525 | + })).branches.find((b) => b.current)!.name; |
| 1414 | 1526 | |
| 1415 | 1527 | const wtPath = path.join(tmp, "my-worktree"); |
| 1416 | | − const result = yield* (yield* GitCore).createWorktree({ |
| 1528 | + const result = yield* (yield* GitVcsDriver.GitVcsDriver).createWorktree({ |
| 1417 | 1529 | cwd: tmp, |
| 1418 | 1530 | branch: currentBranch, |
| 1419 | 1531 | newBranch: "feature-wt", |
| @@ -1424,7 +1536,7 @@ it.layer(TestLayer)("git integration", (it) => { · 4 unmodified lines |
| 1424 | 1536 | expect(existsSync(result.worktree.path)).toBe(true); |
| 1425 | 1537 | |
| 1426 | 1538 | // Main repo still on original branch |
| 1427 | | − const mainBranches = yield* (yield* GitCore).listBranches({ cwd: tmp }); |
| 1539 | + const mainBranches = yield* (yield* GitVcsDriver.GitVcsDriver).listBranches({ cwd: tmp }); |
| 1428 | 1540 | const mainCurrent = mainBranches.branches.find((b) => b.current); |
| 1429 | 1541 | expect(mainCurrent!.name).toBe(currentBranch); |
| 1430 | 1542 | |
| @@ -1432,7 +1544,7 @@ it.layer(TestLayer)("git integration", (it) => { · 1 unmodified line |
| 1432 | 1544 | const wtBranch = yield* git(wtPath, ["branch", "--show-current"]); |
| 1433 | 1545 | expect(wtBranch).toBe("feature-wt"); |
| 1434 | 1546 | |
| 1435 | | − yield* (yield* GitCore).removeWorktree({ cwd: tmp, path: wtPath }); |
| 1547 | + yield* (yield* GitVcsDriver.GitVcsDriver).removeWorktree({ cwd: tmp, path: wtPath }); |
| 1436 | 1548 | }), |
| 1437 | 1549 | ); |
| 1438 | 1550 | }); |
| @@ -1454,7 +1566,7 @@ it.layer(TestLayer)("git integration", (it) => { · 15 unmodified lines |
| 1454 | 1566 | yield* git(tmp, ["push", "origin", "HEAD:refs/pull/55/head"]); |
| 1455 | 1567 | yield* git(tmp, ["checkout", initialBranch]); |
| 1456 | 1568 | |
| 1457 | | − yield* (yield* GitCore).fetchPullRequestBranch({ |
| 1569 | + yield* (yield* GitVcsDriver.GitVcsDriver).fetchPullRequestBranch({ |
| 1458 | 1570 | cwd: tmp, |
| 1459 | 1571 | prNumber: 55, |
| 1460 | 1572 | branch: "feature/pr-fetch", |
| @@ -1475,22 +1587,22 @@ it.layer(TestLayer)("git integration", (it) => { · 14 unmodified lines |
| 1475 | 1587 | Effect.gen(function* () { |
| 1476 | 1588 | const tmp = yield* makeTmpDir(); |
| 1477 | 1589 | yield* initRepoWithCommit(tmp); |
| 1478 | | − yield* (yield* GitCore).createBranch({ cwd: tmp, branch: "branch-a" }); |
| 1479 | | − yield* (yield* GitCore).createBranch({ cwd: tmp, branch: "branch-b" }); |
| 1590 | + yield* (yield* GitVcsDriver.GitVcsDriver).createBranch({ cwd: tmp, branch: "branch-a" }); |
| 1591 | + yield* (yield* GitVcsDriver.GitVcsDriver).createBranch({ cwd: tmp, branch: "branch-b" }); |
| 1480 | 1592 | |
| 1481 | 1593 | // Simulate switching to thread A's branch |
| 1482 | | − yield* (yield* GitCore).checkoutBranch({ cwd: tmp, branch: "branch-a" }); |
| 1483 | | − let branches = yield* (yield* GitCore).listBranches({ cwd: tmp }); |
| 1594 | + yield* (yield* GitVcsDriver.GitVcsDriver).checkoutBranch({ cwd: tmp, branch: "branch-a" }); |
| 1595 | + let branches = yield* (yield* GitVcsDriver.GitVcsDriver).listBranches({ cwd: tmp }); |
| 1484 | 1596 | expect(branches.branches.find((b) => b.current)!.name).toBe("branch-a"); |
| 1485 | 1597 | |
| 1486 | 1598 | // Simulate switching to thread B's branch |
| 1487 | | − yield* (yield* GitCore).checkoutBranch({ cwd: tmp, branch: "branch-b" }); |
| 1488 | | − branches = yield* (yield* GitCore).listBranches({ cwd: tmp }); |
| 1599 | + yield* (yield* GitVcsDriver.GitVcsDriver).checkoutBranch({ cwd: tmp, branch: "branch-b" }); |
| 1600 | + branches = yield* (yield* GitVcsDriver.GitVcsDriver).listBranches({ cwd: tmp }); |
| 1489 | 1601 | expect(branches.branches.find((b) => b.current)!.name).toBe("branch-b"); |
| 1490 | 1602 | |
| 1491 | 1603 | // Switch back to thread A |
| 1492 | | − yield* (yield* GitCore).checkoutBranch({ cwd: tmp, branch: "branch-a" }); |
| 1493 | | − branches = yield* (yield* GitCore).listBranches({ cwd: tmp }); |
| 1604 | + yield* (yield* GitVcsDriver.GitVcsDriver).checkoutBranch({ cwd: tmp, branch: "branch-a" }); |
| 1605 | + branches = yield* (yield* GitVcsDriver.GitVcsDriver).listBranches({ cwd: tmp }); |
| 1494 | 1606 | expect(branches.branches.find((b) => b.current)!.name).toBe("branch-a"); |
| 1495 | 1607 | }), |
| 1496 | 1608 | ); |
| @@ -1503,40 +1615,43 @@ it.layer(TestLayer)("git integration", (it) => { · 6 unmodified lines |
| 1503 | 1615 | Effect.gen(function* () { |
| 1504 | 1616 | const tmp = yield* makeTmpDir(); |
| 1505 | 1617 | yield* initRepoWithCommit(tmp); |
| 1506 | | − yield* (yield* GitCore).createBranch({ cwd: tmp, branch: "diverged" }); |
| 1618 | + yield* (yield* GitVcsDriver.GitVcsDriver).createBranch({ cwd: tmp, branch: "diverged" }); |
| 1507 | 1619 | |
| 1508 | 1620 | // Make diverged branch have different file content |
| 1509 | | − yield* (yield* GitCore).checkoutBranch({ cwd: tmp, branch: "diverged" }); |
| 1621 | + yield* (yield* GitVcsDriver.GitVcsDriver).checkoutBranch({ cwd: tmp, branch: "diverged" }); |
| 1510 | 1622 | yield* writeTextFile(path.join(tmp, "README.md"), "diverged content\n"); |
| 1511 | 1623 | yield* git(tmp, ["add", "."]); |
| 1512 | 1624 | yield* git(tmp, ["commit", "-m", "diverge"]); |
| 1513 | 1625 | |
| 1514 | 1626 | // Actually, let's just get back to the initial branch explicitly |
| 1515 | | − const allBranches = yield* (yield* GitCore).listBranches({ cwd: tmp }); |
| 1627 | + const allBranches = yield* (yield* GitVcsDriver.GitVcsDriver).listBranches({ cwd: tmp }); |
| 1516 | 1628 | const initialBranch = allBranches.branches.find((b) => b.name !== "diverged")!.name; |
| 1517 | | − yield* (yield* GitCore).checkoutBranch({ cwd: tmp, branch: initialBranch }); |
| 1629 | + yield* (yield* GitVcsDriver.GitVcsDriver).checkoutBranch({ |
| 1630 | + cwd: tmp, |
| 1631 | + branch: initialBranch, |
| 1632 | + }); |
| 1518 | 1633 | |
| 1519 | 1634 | // Make local uncommitted changes to the same file |
| 1520 | 1635 | yield* writeTextFile(path.join(tmp, "README.md"), "local uncommitted\n"); |
| 1521 | 1636 | |
| 1522 | 1637 | // Attempt checkout should fail |
| 1523 | 1638 | const failedCheckout = yield* Effect.result( |
| 1524 | | − (yield* GitCore).checkoutBranch({ cwd: tmp, branch: "diverged" }), |
| 1639 | + (yield* GitVcsDriver.GitVcsDriver).checkoutBranch({ cwd: tmp, branch: "diverged" }), |
| 1525 | 1640 | ); |
| 1526 | 1641 | expect(failedCheckout._tag).toBe("Failure"); |
| 1527 | 1642 | |
| 1528 | 1643 | // Current branch should still be the initial one |
| 1529 | | − const result = yield* (yield* GitCore).listBranches({ cwd: tmp }); |
| 1644 | + const result = yield* (yield* GitVcsDriver.GitVcsDriver).listBranches({ cwd: tmp }); |
| 1530 | 1645 | expect(result.branches.find((b) => b.current)!.name).toBe(initialBranch); |
| 1531 | 1646 | }), |
| 1532 | 1647 | ); |
| 1533 | 1648 | }); |
| 1534 | 1649 | |
| 1535 | | − describe("GitCore", () => { |
| 1650 | + describe("GitVcsDriver", () => { |
| 1536 | 1651 | it.effect("supports branch lifecycle operations through the service API", () => |
| 1537 | 1652 | Effect.gen(function* () { |
| 1538 | 1653 | const tmp = yield* makeTmpDir(); |
| 1539 | | − const core = yield* GitCore; |
| 1654 | + const core = yield* GitVcsDriver.GitVcsDriver; |
| 1540 | 1655 | |
| 1541 | 1656 | yield* core.initRepo({ cwd: tmp }); |
| 1542 | 1657 | yield* git(tmp, ["config", "user.email", "test@test.com"]); |
| @@ -1563,7 +1678,7 @@ it.layer(TestLayer)("git integration", (it) => { · 20 unmodified lines |
| 1563 | 1678 | Effect.gen(function* () { |
| 1564 | 1679 | const tmp = yield* makeTmpDir(); |
| 1565 | 1680 | yield* initRepoWithCommit(tmp); |
| 1566 | | − const core = yield* GitCore; |
| 1681 | + const core = yield* GitVcsDriver.GitVcsDriver; |
| 1567 | 1682 | |
| 1568 | 1683 | yield* git(tmp, ["remote", "add", "origin", "git@github.com:pingdotgg/t3code.git"]); |
| 1569 | 1684 | |
| @@ -1582,7 +1697,7 @@ it.layer(TestLayer)("git integration", (it) => { · 12 unmodified lines |
| 1582 | 1697 | Effect.gen(function* () { |
| 1583 | 1698 | const tmp = yield* makeTmpDir(); |
| 1584 | 1699 | yield* initRepoWithCommit(tmp); |
| 1585 | | − const core = yield* GitCore; |
| 1700 | + const core = yield* GitVcsDriver.GitVcsDriver; |
| 1586 | 1701 | |
| 1587 | 1702 | const clean = yield* core.status({ cwd: tmp }); |
| 1588 | 1703 | expect(clean.hasWorkingTreeChanges).toBe(false); |
| @@ -1600,7 +1715,7 @@ it.layer(TestLayer)("git integration", (it) => { · 11 unmodified lines |
| 1600 | 1715 | const deletedDir = path.join(tmp, "deleted-repo"); |
| 1601 | 1716 | yield* makeDirectory(deletedDir); |
| 1602 | 1717 | yield* removePath(deletedDir); |
| 1603 | | − const core = yield* GitCore; |
| 1718 | + const core = yield* GitVcsDriver.GitVcsDriver; |
| 1604 | 1719 | |
| 1605 | 1720 | const status = yield* core.statusDetails(deletedDir); |
| 1606 | 1721 | const localStatus = yield* core.statusDetailsLocal(deletedDir); |
| @@ -1629,7 +1744,7 @@ it.layer(TestLayer)("git integration", (it) => { · 22 unmodified lines |
| 1629 | 1744 | Effect.gen(function* () { |
| 1630 | 1745 | const tmp = yield* makeTmpDir(); |
| 1631 | 1746 | yield* initRepoWithCommit(tmp); |
| 1632 | | − const core = yield* GitCore; |
| 1747 | + const core = yield* GitVcsDriver.GitVcsDriver; |
| 1633 | 1748 | |
| 1634 | 1749 | yield* core.createBranch({ cwd: tmp, branch: "feature/no-upstream-ahead" }); |
| 1635 | 1750 | yield* core.checkoutBranch({ cwd: tmp, branch: "feature/no-upstream-ahead" }); |
| @@ -1654,7 +1769,7 @@ it.layer(TestLayer)("git integration", (it) => { · 18 unmodified lines |
| 1654 | 1769 | yield* git(remote, ["init", "--bare"]); |
| 1655 | 1770 | |
| 1656 | 1771 | yield* initRepoWithCommit(source); |
| 1657 | | − const initialBranch = (yield* (yield* GitCore).listBranches({ |
| 1772 | + const initialBranch = (yield* (yield* GitVcsDriver.GitVcsDriver).listBranches({ |
| 1658 | 1773 | cwd: source, |
| 1659 | 1774 | })).branches.find((branch) => branch.current)!.name; |
| 1660 | 1775 | yield* git(source, ["remote", "add", "origin", remote]); |
| @@ -1668,7 +1783,7 @@ it.layer(TestLayer)("git integration", (it) => { · 7 unmodified lines |
| 1668 | 1783 | yield* git(source, ["commit", "-m", "feature commit"]); |
| 1669 | 1784 | yield* git(source, ["branch", "-D", initialBranch]); |
| 1670 | 1785 | |
| 1671 | | − const core = yield* GitCore; |
| 1786 | + const core = yield* GitVcsDriver.GitVcsDriver; |
| 1672 | 1787 | const details = yield* core.statusDetails(source); |
| 1673 | 1788 | expect(details.branch).toBe("feature/remote-base-only"); |
| 1674 | 1789 | expect(details.hasUpstream).toBe(false); |
| @@ -1687,7 +1802,7 @@ it.layer(TestLayer)("git integration", (it) => { · 12 unmodified lines |
| 1687 | 1802 | yield* git(remote, ["init", "--bare"]); |
| 1688 | 1803 | |
| 1689 | 1804 | yield* initRepoWithCommit(source); |
| 1690 | | − const initialBranch = (yield* (yield* GitCore).listBranches({ |
| 1805 | + const initialBranch = (yield* (yield* GitVcsDriver.GitVcsDriver).listBranches({ |
| 1691 | 1806 | cwd: source, |
| 1692 | 1807 | })).branches.find((branch) => branch.current)!.name; |
| 1693 | 1808 | yield* git(source, ["remote", "add", remoteName, remote]); |
| @@ -1706,7 +1821,7 @@ it.layer(TestLayer)("git integration", (it) => { · 12 unmodified lines |
| 1706 | 1821 | yield* git(source, ["commit", "-m", "feature commit"]); |
| 1707 | 1822 | yield* git(source, ["branch", "-D", initialBranch]); |
| 1708 | 1823 | |
| 1709 | | − const core = yield* GitCore; |
| 1824 | + const core = yield* GitVcsDriver.GitVcsDriver; |
| 1710 | 1825 | const details = yield* core.statusDetails(source); |
| 1711 | 1826 | expect(details.branch).toBe("feature/non-origin-merge-base"); |
| 1712 | 1827 | expect(details.hasUpstream).toBe(false); |
| @@ -1719,7 +1834,7 @@ it.layer(TestLayer)("git integration", (it) => { · 6 unmodified lines |
| 1719 | 1834 | Effect.gen(function* () { |
| 1720 | 1835 | const tmp = yield* makeTmpDir(); |
| 1721 | 1836 | yield* initRepoWithCommit(tmp); |
| 1722 | | − const core = yield* GitCore; |
| 1837 | + const core = yield* GitVcsDriver.GitVcsDriver; |
| 1723 | 1838 | |
| 1724 | 1839 | yield* core.createBranch({ cwd: tmp, branch: "feature/no-upstream-no-ahead" }); |
| 1725 | 1840 | yield* core.checkoutBranch({ cwd: tmp, branch: "feature/no-upstream-no-ahead" }); |
| @@ -1745,7 +1860,7 @@ it.layer(TestLayer)("git integration", (it) => { · 19 unmodified lines |
| 1745 | 1860 | yield* git(tmp, ["remote", "add", "origin", remote]); |
| 1746 | 1861 | yield* git(tmp, ["checkout", "-b", "feature/no-base"]); |
| 1747 | 1862 | |
| 1748 | | − const core = yield* GitCore; |
| 1863 | + const core = yield* GitVcsDriver.GitVcsDriver; |
| 1749 | 1864 | const pushed = yield* core.pushCurrentBranch(tmp, null); |
| 1750 | 1865 | expect(pushed.status).toBe("pushed"); |
| 1751 | 1866 | expect(pushed.setUpstream).toBe(true); |
| @@ -1770,7 +1885,7 @@ it.layer(TestLayer)("git integration", (it) => { · 18 unmodified lines |
| 1770 | 1885 | yield* git(tmp, ["remote", "add", "fork", remote]); |
| 1771 | 1886 | yield* git(tmp, ["checkout", "-b", "feature/fork-only"]); |
| 1772 | 1887 | |
| 1773 | | − const core = yield* GitCore; |
| 1888 | + const core = yield* GitVcsDriver.GitVcsDriver; |
| 1774 | 1889 | const pushed = yield* core.pushCurrentBranch(tmp, null); |
| 1775 | 1890 | expect(pushed.status).toBe("pushed"); |
| 1776 | 1891 | expect(pushed.setUpstream).toBe(true); |
| @@ -1790,9 +1905,9 @@ it.layer(TestLayer)("git integration", (it) => { · 13 unmodified lines |
| 1790 | 1905 | yield* git(remote, ["init", "--bare"]); |
| 1791 | 1906 | |
| 1792 | 1907 | yield* initRepoWithCommit(tmp); |
| 1793 | | − const initialBranch = (yield* (yield* GitCore).listBranches({ cwd: tmp })).branches.find( |
| 1794 | | − (branch) => branch.current, |
| 1795 | | − )!.name; |
| 1908 | + const initialBranch = (yield* (yield* GitVcsDriver.GitVcsDriver).listBranches({ |
| 1909 | + cwd: tmp, |
| 1910 | + })).branches.find((branch) => branch.current)!.name; |
| 1796 | 1911 | yield* git(tmp, ["remote", "add", "origin", remote]); |
| 1797 | 1912 | yield* git(tmp, ["push", "-u", "origin", initialBranch]); |
| 1798 | 1913 | |
| @@ -1803,7 +1918,7 @@ it.layer(TestLayer)("git integration", (it) => { · 4 unmodified lines |
| 1803 | 1918 | const featureBranch = "feature/publish-no-upstream"; |
| 1804 | 1919 | yield* git(tmp, ["checkout", "-b", featureBranch]); |
| 1805 | 1920 | |
| 1806 | | − const core = yield* GitCore; |
| 1921 | + const core = yield* GitVcsDriver.GitVcsDriver; |
| 1807 | 1922 | const pushed = yield* core.pushCurrentBranch(tmp, null); |
| 1808 | 1923 | expect(pushed.status).toBe("pushed"); |
| 1809 | 1924 | expect(pushed.setUpstream).toBe(true); |
| @@ -1826,9 +1941,9 @@ it.layer(TestLayer)("git integration", (it) => { · 16 unmodified lines |
| 1826 | 1941 | yield* git(fork, ["init", "--bare"]); |
| 1827 | 1942 | |
| 1828 | 1943 | yield* initRepoWithCommit(tmp); |
| 1829 | | − const initialBranch = (yield* (yield* GitCore).listBranches({ cwd: tmp })).branches.find( |
| 1830 | | − (branch) => branch.current, |
| 1831 | | − )!.name; |
| 1944 | + const initialBranch = (yield* (yield* GitVcsDriver.GitVcsDriver).listBranches({ |
| 1945 | + cwd: tmp, |
| 1946 | + })).branches.find((branch) => branch.current)!.name; |
| 1832 | 1947 | yield* git(tmp, ["remote", "add", "origin", origin]); |
| 1833 | 1948 | yield* git(tmp, ["remote", "add", "fork", fork]); |
| 1834 | 1949 | yield* git(tmp, ["push", "-u", "origin", initialBranch]); |
| @@ -1840,7 +1955,7 @@ it.layer(TestLayer)("git integration", (it) => { · 5 unmodified lines |
| 1840 | 1955 | yield* git(tmp, ["add", "feature.txt"]); |
| 1841 | 1956 | yield* git(tmp, ["commit", "-m", "feature commit"]); |
| 1842 | 1957 | |
| 1843 | | − const core = yield* GitCore; |
| 1958 | + const core = yield* GitVcsDriver.GitVcsDriver; |
| 1844 | 1959 | const pushed = yield* core.pushCurrentBranch(tmp, null); |
| 1845 | 1960 | expect(pushed.status).toBe("pushed"); |
| 1846 | 1961 | expect(pushed.setUpstream).toBe(true); |
| @@ -1883,7 +1998,7 @@ it.layer(TestLayer)("git integration", (it) => { · 36 unmodified lines |
| 1883 | 1998 | yield* git(tmp, ["add", "fork.txt"]); |
| 1884 | 1999 | yield* git(tmp, ["commit", "-m", "update reviewed PR branch"]); |
| 1885 | 2000 | |
| 1886 | | − const core = yield* GitCore; |
| 2001 | + const core = yield* GitVcsDriver.GitVcsDriver; |
| 1887 | 2002 | const pushed = yield* core.pushCurrentBranch(tmp, null); |
| 1888 | 2003 | |
| 1889 | 2004 | expect(pushed.status).toBe("pushed"); |
| @@ -1928,7 +2043,7 @@ it.layer(TestLayer)("git integration", (it) => { · 38 unmodified lines |
| 1928 | 2043 | yield* git(tmp, ["add", "feature.txt"]); |
| 1929 | 2044 | yield* git(tmp, ["commit", "-m", "feature update"]); |
| 1930 | 2045 | |
| 1931 | | − const core = yield* GitCore; |
| 2046 | + const core = yield* GitVcsDriver.GitVcsDriver; |
| 1932 | 2047 | const pushed = yield* core.pushCurrentBranch(tmp, null); |
| 1933 | 2048 | expect(pushed.status).toBe("pushed"); |
| 1934 | 2049 | expect(pushed.setUpstream).toBe(false); |
| @@ -1946,7 +2061,7 @@ it.layer(TestLayer)("git integration", (it) => { · 11 unmodified lines |
| 1946 | 2061 | Effect.gen(function* () { |
| 1947 | 2062 | const tmp = yield* makeTmpDir(); |
| 1948 | 2063 | yield* initRepoWithCommit(tmp); |
| 1949 | | − const core = yield* GitCore; |
| 2064 | + const core = yield* GitVcsDriver.GitVcsDriver; |
| 1950 | 2065 | const missingWorktreePath = path.join(tmp, "missing-worktree"); |
| 1951 | 2066 | |
| 1952 | 2067 | const removeResult = yield* Effect.result( |
| @@ -1973,7 +2088,7 @@ it.layer(TestLayer)("git integration", (it) => { · 20 unmodified lines |
| 1973 | 2088 | yield* git(remote, ["init", "--bare"]); |
| 1974 | 2089 | |
| 1975 | 2090 | yield* initRepoWithCommit(source); |
| 1976 | | − const initialBranch = (yield* (yield* GitCore).listBranches({ |
| 2091 | + const initialBranch = (yield* (yield* GitVcsDriver.GitVcsDriver).listBranches({ |
| 1977 | 2092 | cwd: source, |
| 1978 | 2093 | })).branches.find((branch) => branch.current)!.name; |
| 1979 | 2094 | yield* git(source, ["remote", "add", "origin", remote]); |
| @@ -1994,7 +2109,7 @@ it.layer(TestLayer)("git integration", (it) => { · 14 unmodified lines |
| 1994 | 2109 | yield* git(clone, ["commit", "-m", "remote update"]); |
| 1995 | 2110 | yield* git(clone, ["push", "origin", initialBranch]); |
| 1996 | 2111 | |
| 1997 | | − const core = yield* GitCore; |
| 2112 | + const core = yield* GitVcsDriver.GitVcsDriver; |
| 1998 | 2113 | const details = yield* core.statusDetails(source); |
| 1999 | 2114 | expect(details.branch).toBe(initialBranch); |
| 2000 | 2115 | expect(details.aheadCount).toBe(0); |
| @@ -2006,7 +2121,7 @@ it.layer(TestLayer)("git integration", (it) => { · 5 unmodified lines |
| 2006 | 2121 | Effect.gen(function* () { |
| 2007 | 2122 | const tmp = yield* makeTmpDir(); |
| 2008 | 2123 | yield* initRepoWithCommit(tmp); |
| 2009 | | − const core = yield* GitCore; |
| 2124 | + const core = yield* GitVcsDriver.GitVcsDriver; |
| 2010 | 2125 | |
| 2011 | 2126 | yield* writeTextFile(path.join(tmp, "README.md"), "new content\n"); |
| 2012 | 2127 | const context = yield* core.prepareCommitContext(tmp); |
| @@ -2024,7 +2139,7 @@ it.layer(TestLayer)("git integration", (it) => { · 11 unmodified lines |
| 2024 | 2139 | Effect.gen(function* () { |
| 2025 | 2140 | const tmp = yield* makeTmpDir(); |
| 2026 | 2141 | yield* initRepoWithCommit(tmp); |
| 2027 | | − const core = yield* GitCore; |
| 2142 | + const core = yield* GitVcsDriver.GitVcsDriver; |
| 2028 | 2143 | |
| 2029 | 2144 | yield* writeTextFile(path.join(tmp, "a.txt"), "file a\n"); |
| 2030 | 2145 | yield* writeTextFile(path.join(tmp, "b.txt"), "file b\n"); |
| @@ -2047,7 +2162,7 @@ it.layer(TestLayer)("git integration", (it) => { · 16 unmodified lines |
| 2047 | 2162 | Effect.gen(function* () { |
| 2048 | 2163 | const tmp = yield* makeTmpDir(); |
| 2049 | 2164 | yield* initRepoWithCommit(tmp); |
| 2050 | | − const core = yield* GitCore; |
| 2165 | + const core = yield* GitVcsDriver.GitVcsDriver; |
| 2051 | 2166 | |
| 2052 | 2167 | yield* writeTextFile(path.join(tmp, "a.txt"), "file a\n"); |
| 2053 | 2168 | yield* writeTextFile(path.join(tmp, "b.txt"), "file b\n"); |
| @@ -2063,7 +2178,7 @@ it.layer(TestLayer)("git integration", (it) => { · 9 unmodified lines |
| 2063 | 2178 | Effect.gen(function* () { |
| 2064 | 2179 | const tmp = yield* makeTmpDir(); |
| 2065 | 2180 | yield* initRepoWithCommit(tmp); |
| 2066 | | − const core = yield* GitCore; |
| 2181 | + const core = yield* GitVcsDriver.GitVcsDriver; |
| 2067 | 2182 | |
| 2068 | 2183 | yield* writeTextFile(path.join(tmp, "README.md"), buildLargeText()); |
| 2069 | 2184 | |
| @@ -2078,7 +2193,7 @@ it.layer(TestLayer)("git integration", (it) => { · 8 unmodified lines |
| 2078 | 2193 | Effect.gen(function* () { |
| 2079 | 2194 | const tmp = yield* makeTmpDir(); |
| 2080 | 2195 | const { initialBranch } = yield* initRepoWithCommit(tmp); |
| 2081 | | − const core = yield* GitCore; |
| 2196 | + const core = yield* GitVcsDriver.GitVcsDriver; |
| 2082 | 2197 | |
| 2083 | 2198 | yield* core.createBranch({ cwd: tmp, branch: "feature/large-range-context" }); |
| 2084 | 2199 | yield* core.checkoutBranch({ cwd: tmp, branch: "feature/large-range-context" }); |
| @@ -2100,11 +2215,17 @@ it.layer(TestLayer)("git integration", (it) => { · 15 unmodified lines |
| 2100 | 2215 | yield* initRepoWithCommit(tmp); |
| 2101 | 2216 | yield* git(remote, ["init", "--bare"]); |
| 2102 | 2217 | yield* git(tmp, ["remote", "add", "origin", remote]); |
| 2103 | | − yield* (yield* GitCore).createBranch({ cwd: tmp, branch: "feature/core-push" }); |
| 2104 | | − yield* (yield* GitCore).checkoutBranch({ cwd: tmp, branch: "feature/core-push" }); |
| 2218 | + yield* (yield* GitVcsDriver.GitVcsDriver).createBranch({ |
| 2219 | + cwd: tmp, |
| 2220 | + branch: "feature/core-push", |
| 2221 | + }); |
| 2222 | + yield* (yield* GitVcsDriver.GitVcsDriver).checkoutBranch({ |
| 2223 | + cwd: tmp, |
| 2224 | + branch: "feature/core-push", |
| 2225 | + }); |
| 2105 | 2226 | |
| 2106 | 2227 | yield* writeTextFile(path.join(tmp, "feature.txt"), "push me\n"); |
| 2107 | | − const core = yield* GitCore; |
| 2228 | + const core = yield* GitVcsDriver.GitVcsDriver; |
| 2108 | 2229 | const context = yield* core.prepareCommitContext(tmp); |
| 2109 | 2230 | expect(context).not.toBeNull(); |
| 2110 | 2231 | yield* core.commit(tmp, "Add feature file", ""); |
| @@ -2129,9 +2250,9 @@ it.layer(TestLayer)("git integration", (it) => { · 18 unmodified lines |
| 2129 | 2250 | yield* git(remote, ["init", "--bare"]); |
| 2130 | 2251 | |
| 2131 | 2252 | yield* initRepoWithCommit(source); |
| 2132 | | − const initialBranch = (yield* (yield* GitCore).listBranches({ cwd: source })).branches.find( |
| 2133 | | − (branch) => branch.current, |
| 2134 | | − )!.name; |
| 2253 | + const initialBranch = (yield* (yield* GitVcsDriver.GitVcsDriver).listBranches({ |
| 2254 | + cwd: source, |
| 2255 | + })).branches.find((branch) => branch.current)!.name; |
| 2135 | 2256 | yield* git(source, ["remote", "add", "origin", remote]); |
| 2136 | 2257 | yield* git(source, ["push", "-u", "origin", initialBranch]); |
| 2137 | 2258 | |
| @@ -2143,7 +2264,7 @@ it.layer(TestLayer)("git integration", (it) => { · 5 unmodified lines |
| 2143 | 2264 | yield* git(clone, ["commit", "-m", "remote update"]); |
| 2144 | 2265 | yield* git(clone, ["push", "origin", initialBranch]); |
| 2145 | 2266 | |
| 2146 | | − const core = yield* GitCore; |
| 2267 | + const core = yield* GitVcsDriver.GitVcsDriver; |
| 2147 | 2268 | const pulled = yield* core.pullCurrentBranch(source); |
| 2148 | 2269 | expect(pulled.status).toBe("pulled"); |
| 2149 | 2270 | expect((yield* core.statusDetails(source)).behindCount).toBe(0); |
| @@ -2157,7 +2278,9 @@ it.layer(TestLayer)("git integration", (it) => { · 7 unmodified lines |
| 2157 | 2278 | Effect.gen(function* () { |
| 2158 | 2279 | const tmp = yield* makeTmpDir(); |
| 2159 | 2280 | yield* initRepoWithCommit(tmp); |
| 2160 | | − const result = yield* Effect.result((yield* GitCore).pullCurrentBranch(tmp)); |
| 2281 | + const result = yield* Effect.result( |
| 2282 | + (yield* GitVcsDriver.GitVcsDriver).pullCurrentBranch(tmp), |
| 2283 | + ); |
| 2161 | 2284 | expect(result._tag).toBe("Failure"); |
| 2162 | 2285 | if (result._tag === "Failure") { |
| 2163 | 2286 | expect(result.failure.message.toLowerCase()).toContain("no upstream"); |
| @@ -2169,9 +2292,9 @@ it.layer(TestLayer)("git integration", (it) => { · 5 unmodified lines |
| 2169 | 2292 | Effect.gen(function* () { |
| 2170 | 2293 | const tmp = yield* makeTmpDir(); |
| 2171 | 2294 | yield* initRepoWithCommit(tmp); |
| 2172 | | − const realGitCore = yield* GitCore; |
| 2295 | + const realGitVcsDriver = yield* GitVcsDriver.GitVcsDriver; |
| 2173 | 2296 | let didFailRecency = false; |
| 2174 | | − const core = yield* makeIsolatedGitCore((input) => { |
| 2297 | + const core = yield* makeIsolatedGitVcsDriver((input) => { |
| 2175 | 2298 | if (!didFailRecency && input.args[0] === "for-each-ref") { |
| 2176 | 2299 | didFailRecency = true; |
| 2177 | 2300 | return Effect.fail( |
| @@ -2183,7 +2306,7 @@ it.layer(TestLayer)("git integration", (it) => { · 5 unmodified lines |
| 2183 | 2306 | }), |
| 2184 | 2307 | ); |
| 2185 | 2308 | } |
| 2186 | | − return realGitCore.execute(input); |
| 2309 | + return realGitVcsDriver.execute(input); |
| 2187 | 2310 | }); |
| 2188 | 2311 | |
| 2189 | 2312 | const result = yield* core.listBranches({ cwd: tmp }); |
| @@ -2203,10 +2326,10 @@ it.layer(TestLayer)("git integration", (it) => { · 13 unmodified lines |
| 2203 | 2326 | yield* git(remote, ["init", "--bare"]); |
| 2204 | 2327 | yield* git(tmp, ["remote", "add", "origin", remote]); |
| 2205 | 2328 | |
| 2206 | | − const realGitCore = yield* GitCore; |
| 2329 | + const realGitVcsDriver = yield* GitVcsDriver.GitVcsDriver; |
| 2207 | 2330 | let didFailRemoteBranches = false; |
| 2208 | 2331 | let didFailRemoteNames = false; |
| 2209 | | − const core = yield* makeIsolatedGitCore((input) => { |
| 2332 | + const core = yield* makeIsolatedGitVcsDriver((input) => { |
| 2210 | 2333 | if (input.args.join(" ") === "branch --no-color --no-column --remotes") { |
| 2211 | 2334 | didFailRemoteBranches = true; |
| 2212 | 2335 | return Effect.fail( |
| @@ -2229,7 +2352,7 @@ it.layer(TestLayer)("git integration", (it) => { · 16 unmodified lines |
| 2229 | 2352 | }), |
| 2230 | 2353 | ); |
| 2231 | 2354 | } |
| 2232 | | − return realGitCore.execute(input); |
| 2355 | + return realGitVcsDriver.execute(input); |
| 2233 | 2356 | }); |
| 2234 | 2357 | |
| 2235 | 2358 | const result = yield* core.listBranches({ cwd: tmp }); |