| @@ -1,4 +1,4 @@ |
| 1 | import { Context, Effect, Layer } from "effect"; | 1 | import { Context, DateTime, Effect, Layer } from "effect"; |
| 2 | | 2 | |
| 3 | import { | 3 | import { |
| 4 | VcsUnsupportedOperationError, | 4 | VcsUnsupportedOperationError, |
| @@ -7,7 +7,7 @@ import { · 2 unmodified lines |
| 7 | type ReviewDiffPreviewResult, | 7 | type ReviewDiffPreviewResult, |
| 8 | } from "@t3tools/contracts"; | 8 | } from "@t3tools/contracts"; |
| 9 | | 9 | |
| 10 | import { GitVcsDriver } from "../vcs/GitVcsDriver.ts"; | 10 | import * as GitVcsDriver from "../vcs/GitVcsDriver.ts"; |
| 11 | import * as VcsDriverRegistry from "../vcs/VcsDriverRegistry.ts"; | 11 | import * as VcsDriverRegistry from "../vcs/VcsDriverRegistry.ts"; |
| 12 | | 12 | |
| 13 | export interface ReviewServiceShape { | 13 | export interface ReviewServiceShape { |
| @@ -20,24 +20,20 @@ export class ReviewService extends Context.Service<ReviewService, ReviewServiceS · 6 unmodified lines |
| 20 | "t3/review/ReviewService", | 20 | "t3/review/ReviewService", |
| 21 | ) {} | 21 | ) {} |
| 22 | | 22 | |
| 23 | function emptyDiffPreview(input: ReviewDiffPreviewInput): ReviewDiffPreviewResult { | | |
| 24 | return { | | |
| 25 | cwd: input.cwd, | | |
| 26 | generatedAt: new Date().toISOString(), | | |
| 27 | sources: [], | | |
| 28 | }; | | |
| 29 | } | | |
| 30 | | | |
| 31 | export const make = Effect.fn("makeReviewService")(function* () { | 23 | export const make = Effect.fn("makeReviewService")(function* () { |
| 32 | const vcsRegistry = yield* VcsDriverRegistry.VcsDriverRegistry; | 24 | const vcsRegistry = yield* VcsDriverRegistry.VcsDriverRegistry; |
| 33 | const git = yield* GitVcsDriver; | 25 | const git = yield* GitVcsDriver.GitVcsDriver; |
| 34 | | 26 | |
| 35 | const getDiffPreview: ReviewServiceShape["getDiffPreview"] = Effect.fn( | 27 | const getDiffPreview: ReviewServiceShape["getDiffPreview"] = Effect.fn( |
| 36 | "ReviewService.getDiffPreview", | 28 | "ReviewService.getDiffPreview", |
| 37 | )(function* (input) { | 29 | )(function* (input) { |
| 38 | const handle = yield* vcsRegistry.detect({ cwd: input.cwd, requestedKind: "auto" }); | 30 | const handle = yield* vcsRegistry.detect({ cwd: input.cwd, requestedKind: "auto" }); |
| 39 | if (!handle) { | 31 | if (!handle) { |
| 40 | return emptyDiffPreview(input); | 32 | return { |
| | 33 | cwd: input.cwd, |
| | 34 | generatedAt: yield* DateTime.now, |
| | 35 | sources: [], |
| | 36 | }; |
| 41 | } | 37 | } |
| 42 | | 38 | |
| 43 | const getDriverDiffPreview = handle.driver.getDiffPreview; | 39 | const getDriverDiffPreview = handle.driver.getDiffPreview; |