fix(core): reuse location git repository
This commit is contained in:
parent
dba5da7c10
commit
d54d26acd6
5 changed files with 18 additions and 5 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import { Context, Effect, Layer } from "effect"
|
||||
import { Info, Ref, response } from "@opencode-ai/schema/location"
|
||||
import { Project } from "./project"
|
||||
import { Git } from "./git"
|
||||
import { LayerNode } from "@opencode-ai/util/effect/layer-node"
|
||||
import { makeLocationNode, tags } from "@opencode-ai/util/effect/app-node"
|
||||
|
||||
|
|
@ -10,6 +11,7 @@ export { Info, Ref, response }
|
|||
|
||||
export interface Interface extends Info {
|
||||
readonly vcs?: Project.Vcs
|
||||
readonly repository?: Git.Repository
|
||||
}
|
||||
|
||||
export class Service extends Context.Service<Service, Interface>()("@opencode/Location") {}
|
||||
|
|
@ -27,6 +29,7 @@ const layer = (ref: Ref) =>
|
|||
workspaceID: ref.workspaceID,
|
||||
project: { id: resolved.id, directory: resolved.directory },
|
||||
vcs: resolved.vcs,
|
||||
repository: resolved.repository,
|
||||
})
|
||||
}),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ export interface Resolved {
|
|||
readonly id: ID
|
||||
readonly directory: AbsolutePath
|
||||
readonly vcs?: Vcs
|
||||
readonly repository?: Git.Repository
|
||||
}
|
||||
|
||||
// Keep this filesystem-only; permission checks use it and should not execute VCS commands.
|
||||
|
|
@ -217,6 +218,7 @@ const layer = Layer.effect(
|
|||
id: id ?? ID.global,
|
||||
directory: repo.worktree,
|
||||
vcs: { type: "git" as const, store: repo.commonDirectory },
|
||||
repository: repo,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ const layer = Layer.effect(
|
|||
// Cache a scope-owned fiber so caller cancellation stops waiting without poisoning shared initialization.
|
||||
const repositoryFiber = yield* Effect.cached(
|
||||
Effect.gen(function* () {
|
||||
const source = yield* git.repo.discover(location.project.directory)
|
||||
const source = location.repository ?? (yield* git.repo.discover(location.project.directory))
|
||||
if (!source) return yield* new Error({ operation: "capture", message: "Project is not a Git repository" })
|
||||
const worktree = AbsolutePath.make(yield* fs.realPath(source.worktree).pipe(Effect.orDie))
|
||||
const gitDirectory = AbsolutePath.make(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue