mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-19 16:40:48 +00:00
chore: generate
This commit is contained in:
parent
94828eb44b
commit
0a945219a9
1 changed files with 32 additions and 17 deletions
|
|
@ -73,11 +73,14 @@ export class LockFailedError extends Schema.TaggedErrorClass<LockFailedError>()(
|
|||
message: Schema.String,
|
||||
}) {}
|
||||
|
||||
export class CacheOperationError extends Schema.TaggedErrorClass<CacheOperationError>()("RepositoryCacheOperationError", {
|
||||
operation: Schema.String,
|
||||
path: Schema.String,
|
||||
message: Schema.String,
|
||||
}) {}
|
||||
export class CacheOperationError extends Schema.TaggedErrorClass<CacheOperationError>()(
|
||||
"RepositoryCacheOperationError",
|
||||
{
|
||||
operation: Schema.String,
|
||||
path: Schema.String,
|
||||
message: Schema.String,
|
||||
},
|
||||
) {}
|
||||
|
||||
export type Error =
|
||||
| InvalidRepositoryError
|
||||
|
|
@ -178,13 +181,19 @@ const ensureWithServices = Effect.fn("RepositoryCache.ensureWithServices")(funct
|
|||
),
|
||||
() =>
|
||||
Effect.gen(function* () {
|
||||
yield* services.fs.ensureDir(path.dirname(localPath)).pipe(
|
||||
Effect.catch((error: unknown) =>
|
||||
Effect.fail(
|
||||
new CacheOperationError({ operation: "ensure cache directory", path: localPath, message: errorMessage(error) }),
|
||||
yield* services.fs
|
||||
.ensureDir(path.dirname(localPath))
|
||||
.pipe(
|
||||
Effect.catch((error: unknown) =>
|
||||
Effect.fail(
|
||||
new CacheOperationError({
|
||||
operation: "ensure cache directory",
|
||||
path: localPath,
|
||||
message: errorMessage(error),
|
||||
}),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
const exists = yield* services.fs.existsSafe(localPath)
|
||||
const hasGitDir = yield* services.fs.existsSafe(path.join(localPath, ".git"))
|
||||
|
|
@ -194,13 +203,19 @@ const ensureWithServices = Effect.fn("RepositoryCache.ensureWithServices")(funct
|
|||
const originReference = origin?.exitCode === 0 ? parseRepositoryReference(origin.text().trim()) : undefined
|
||||
const reuse = hasGitDir && Boolean(originReference && sameRepositoryReference(originReference, cloneTarget))
|
||||
if (exists && !reuse) {
|
||||
yield* services.fs.remove(localPath, { recursive: true }).pipe(
|
||||
Effect.catch((error: unknown) =>
|
||||
Effect.fail(
|
||||
new CacheOperationError({ operation: "remove stale cache", path: localPath, message: errorMessage(error) }),
|
||||
yield* services.fs
|
||||
.remove(localPath, { recursive: true })
|
||||
.pipe(
|
||||
Effect.catch((error: unknown) =>
|
||||
Effect.fail(
|
||||
new CacheOperationError({
|
||||
operation: "remove stale cache",
|
||||
path: localPath,
|
||||
message: errorMessage(error),
|
||||
}),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
const currentBranch = hasGitDir ? yield* services.git.branch(localPath) : undefined
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue