refactor(repository): type cache failures (#28188)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { Effect, Schema } from "effect"
|
||||
import DESCRIPTION from "./repo_clone.txt"
|
||||
import * as Tool from "./tool"
|
||||
import { parseRemoteRepositoryReference, repositoryCachePath, validateRepositoryBranch } from "@/util/repository"
|
||||
import { repositoryCachePath } from "@/util/repository"
|
||||
import { RepositoryCache } from "@/reference/repository-cache"
|
||||
|
||||
export const Parameters = Schema.Struct({
|
||||
@@ -36,8 +36,8 @@ export const RepoCloneTool = Tool.define<typeof Parameters, Metadata, Repository
|
||||
parameters: Parameters,
|
||||
execute: (params: Schema.Schema.Type<typeof Parameters>, ctx: Tool.Context<Metadata>) =>
|
||||
Effect.gen(function* () {
|
||||
const reference = parseRemoteRepositoryReference(params.repository)
|
||||
if (params.branch) validateRepositoryBranch(params.branch)
|
||||
const reference = yield* RepositoryCache.parseRemoteReference(params.repository)
|
||||
if (params.branch) yield* RepositoryCache.validateBranch(params.branch)
|
||||
|
||||
const repository = reference.label
|
||||
const remote = reference.remote
|
||||
@@ -68,7 +68,10 @@ export const RepoCloneTool = Tool.define<typeof Parameters, Metadata, Repository
|
||||
...(result.head ? [`HEAD: ${result.head}`] : []),
|
||||
].join("\n"),
|
||||
}
|
||||
}).pipe(Effect.orDie),
|
||||
}).pipe(
|
||||
Effect.catchIf(RepositoryCache.isError, (error) => Effect.fail(new Error(error.message))),
|
||||
Effect.orDie,
|
||||
),
|
||||
} satisfies Tool.DefWithoutID<typeof Parameters, Metadata>
|
||||
}),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user