chore: generate
This commit is contained in:
@@ -73,11 +73,14 @@ export class LockFailedError extends Schema.TaggedErrorClass<LockFailedError>()(
|
|||||||
message: Schema.String,
|
message: Schema.String,
|
||||||
}) {}
|
}) {}
|
||||||
|
|
||||||
export class CacheOperationError extends Schema.TaggedErrorClass<CacheOperationError>()("RepositoryCacheOperationError", {
|
export class CacheOperationError extends Schema.TaggedErrorClass<CacheOperationError>()(
|
||||||
operation: Schema.String,
|
"RepositoryCacheOperationError",
|
||||||
path: Schema.String,
|
{
|
||||||
message: Schema.String,
|
operation: Schema.String,
|
||||||
}) {}
|
path: Schema.String,
|
||||||
|
message: Schema.String,
|
||||||
|
},
|
||||||
|
) {}
|
||||||
|
|
||||||
export type Error =
|
export type Error =
|
||||||
| InvalidRepositoryError
|
| InvalidRepositoryError
|
||||||
@@ -178,13 +181,19 @@ const ensureWithServices = Effect.fn("RepositoryCache.ensureWithServices")(funct
|
|||||||
),
|
),
|
||||||
() =>
|
() =>
|
||||||
Effect.gen(function* () {
|
Effect.gen(function* () {
|
||||||
yield* services.fs.ensureDir(path.dirname(localPath)).pipe(
|
yield* services.fs
|
||||||
Effect.catch((error: unknown) =>
|
.ensureDir(path.dirname(localPath))
|
||||||
Effect.fail(
|
.pipe(
|
||||||
new CacheOperationError({ operation: "ensure cache directory", path: localPath, message: errorMessage(error) }),
|
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 exists = yield* services.fs.existsSafe(localPath)
|
||||||
const hasGitDir = yield* services.fs.existsSafe(path.join(localPath, ".git"))
|
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 originReference = origin?.exitCode === 0 ? parseRepositoryReference(origin.text().trim()) : undefined
|
||||||
const reuse = hasGitDir && Boolean(originReference && sameRepositoryReference(originReference, cloneTarget))
|
const reuse = hasGitDir && Boolean(originReference && sameRepositoryReference(originReference, cloneTarget))
|
||||||
if (exists && !reuse) {
|
if (exists && !reuse) {
|
||||||
yield* services.fs.remove(localPath, { recursive: true }).pipe(
|
yield* services.fs
|
||||||
Effect.catch((error: unknown) =>
|
.remove(localPath, { recursive: true })
|
||||||
Effect.fail(
|
.pipe(
|
||||||
new CacheOperationError({ operation: "remove stale cache", path: localPath, message: errorMessage(error) }),
|
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
|
const currentBranch = hasGitDir ? yield* services.git.branch(localPath) : undefined
|
||||||
|
|||||||
Reference in New Issue
Block a user