fix(core): reuse location git repository

This commit is contained in:
Aiden Cline 2026-07-22 10:29:39 -05:00
commit d54d26acd6
5 changed files with 18 additions and 5 deletions

View file

@ -3,12 +3,18 @@ import { Effect, Layer } from "effect"
import { AppNodeBuilder } from "@opencode-ai/core/effect/app-node-builder"
import { Location } from "@opencode-ai/core/location"
import { Project } from "@opencode-ai/core/project"
import { Git } from "@opencode-ai/core/git"
import { AbsolutePath } from "@opencode-ai/core/schema"
import { WorkspaceV2 } from "@opencode-ai/core/workspace"
import { testEffect } from "./lib/effect"
const workspaceID = WorkspaceV2.ID.make("wrk_test")
const ref = { directory: AbsolutePath.make("/repo/packages/app"), workspaceID }
const repository = new Git.Repository({
worktree: AbsolutePath.make("/repo"),
gitDirectory: AbsolutePath.make("/repo/.git"),
commonDirectory: AbsolutePath.make("/repo/.git"),
})
const projectLayer = Layer.succeed(
Project.Service,
Project.Service.of({
@ -19,6 +25,7 @@ const projectLayer = Layer.succeed(
id: Project.ID.make("project"),
directory: AbsolutePath.make("/repo"),
vcs: { type: "git", store: AbsolutePath.make("/repo/.git") },
repository,
}),
commit: () => Effect.void,
}),
@ -38,6 +45,7 @@ describe("Location", () => {
type: "git",
store: AbsolutePath.make("/repo/.git"),
})
expect(location.repository).toBe(repository)
}),
)
})

View file

@ -14,7 +14,7 @@ import { tmpdir } from "./fixture/tmpdir"
import { testEffect } from "./lib/effect"
describe("Snapshot", () => {
testEffect(Layer.empty).live("keeps lazy repository discovery after the first caller is interrupted", () =>
testEffect(Layer.empty).live("reuses the Location repository after the first caller is interrupted", () =>
Effect.acquireUseRelease(
Effect.promise(() => tmpdir()),
(tmp) =>
@ -65,16 +65,16 @@ describe("Snapshot", () => {
const interrupted = yield* snapshot.capture().pipe(Effect.forkChild)
yield* Deferred.await(started)
expect(discoveries).toBe(1)
expect(discoveries).toBe(0)
expect(creations).toBe(1)
yield* Fiber.interrupt(interrupted)
const capture = yield* snapshot.capture().pipe(Effect.forkChild)
expect(discoveries).toBe(1)
expect(discoveries).toBe(0)
expect(creations).toBe(1)
yield* Deferred.succeed(release, undefined)
expect(yield* Fiber.join(capture)).toBeDefined()
expect(discoveries).toBe(1)
expect(discoveries).toBe(0)
expect(creations).toBe(1)
}).pipe(Effect.provide(layer))
}),