Add VCS driver registry for pluggable git integration
- Route checkpointing and workspace services through a VCS driver registry - Split git driver construction from the driver service wrapper - Update tests and harnesses to mock the registry instead of the raw driver
This commit is contained in:
1 parent
c3300acd4d
commit
8064641451
11 files changed
+236
-42
No files matched your search
@@ -76,6 +76,7 @@ import { deriveServerPaths, ServerConfig } from "../src/config.ts";
|
||||
import { WorkspaceEntriesLive } from "../src/workspace/Layers/WorkspaceEntries.ts";
|
||||
import { WorkspacePathsLive } from "../src/workspace/Layers/WorkspacePaths.ts";
|
||||
import * as GitVcsDriver from "../src/vcs/GitVcsDriver.ts";
|
||||
import * as VcsDriverRegistry from "../src/vcs/VcsDriverRegistry.ts";
|
||||
import * as VcsProcess from "../src/vcs/VcsProcess.ts";
|
||||
|
||||
function runGit(cwd: string, args: ReadonlyArray<string>) {
|
||||
@@ -291,7 +292,7 @@ export const makeOrchestrationIntegrationHarness = (
|
||||
Layer.provide(providerEventLoggersLayer),
|
||||
);
|
||||
|
||||
const checkpointStoreLayer = CheckpointStoreLive.pipe(Layer.provide(GitVcsDriver.vcsLayer));
|
||||
const checkpointStoreLayer = CheckpointStoreLive.pipe(Layer.provide(VcsDriverRegistry.layer));
|
||||
const projectionSnapshotQueryLayer = OrchestrationProjectionSnapshotQueryLive;
|
||||
const runtimeServicesLayer = Layer.mergeAll(
|
||||
projectionSnapshotQueryLayer,
|
||||
@@ -342,7 +343,7 @@ export const makeOrchestrationIntegrationHarness = (
|
||||
Layer.provideMerge(
|
||||
WorkspaceEntriesLive.pipe(
|
||||
Layer.provide(WorkspacePathsLive),
|
||||
Layer.provideMerge(GitVcsDriver.vcsLayer),
|
||||
Layer.provideMerge(VcsDriverRegistry.layer),
|
||||
Layer.provide(NodeServices.layer),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -8,7 +8,7 @@ import { describe, expect } from "vitest";
|
||||
import { checkpointRefForThreadTurn } from "../Utils.ts";
|
||||
import { CheckpointStoreLive } from "./CheckpointStore.ts";
|
||||
import { CheckpointStore } from "../Services/CheckpointStore.ts";
|
||||
import * as GitVcsDriver from "../../vcs/GitVcsDriver.ts";
|
||||
import * as VcsDriverRegistry from "../../vcs/VcsDriverRegistry.ts";
|
||||
import * as VcsProcess from "../../vcs/VcsProcess.ts";
|
||||
import type { VcsError } from "@t3tools/contracts";
|
||||
import { ServerConfig } from "../../config.ts";
|
||||
@@ -18,7 +18,7 @@ const ServerConfigLayer = ServerConfig.layerTest(process.cwd(), {
|
||||
prefix: "t3-checkpoint-store-test-",
|
||||
});
|
||||
const VcsProcessTestLayer = VcsProcess.layer.pipe(Layer.provide(NodeServices.layer));
|
||||
const VcsDriverTestLayer = GitVcsDriver.vcsLayer.pipe(Layer.provide(VcsProcessTestLayer));
|
||||
const VcsDriverTestLayer = VcsDriverRegistry.layer.pipe(Layer.provide(VcsProcessTestLayer));
|
||||
const CheckpointStoreTestLayer = CheckpointStoreLive.pipe(
|
||||
Layer.provideMerge(VcsDriverTestLayer),
|
||||
Layer.provideMerge(NodeServices.layer),
|
||||
|
||||
@@ -15,7 +15,7 @@ import { Effect, Layer, FileSystem, Path } from "effect";
|
||||
|
||||
import { CheckpointInvariantError } from "../Errors.ts";
|
||||
import { VcsProcessExitError } from "@t3tools/contracts";
|
||||
import { VcsDriver } from "../../vcs/VcsDriver.ts";
|
||||
import { VcsDriverRegistry } from "../../vcs/VcsDriverRegistry.ts";
|
||||
import { CheckpointStore, type CheckpointStoreShape } from "../Services/CheckpointStore.ts";
|
||||
import { CheckpointRef } from "@t3tools/contracts";
|
||||
|
||||
@@ -24,7 +24,23 @@ const CHECKPOINT_DIFF_MAX_OUTPUT_BYTES = 10_000_000;
|
||||
const makeCheckpointStore = Effect.gen(function* () {
|
||||
const fs = yield* FileSystem.FileSystem;
|
||||
const path = yield* Path.Path;
|
||||
const vcs = yield* VcsDriver;
|
||||
const vcsRegistry = yield* VcsDriverRegistry;
|
||||
const vcs = {
|
||||
execute: (input: {
|
||||
readonly operation: string;
|
||||
readonly cwd: string;
|
||||
readonly args: ReadonlyArray<string>;
|
||||
readonly stdin?: string;
|
||||
readonly env?: NodeJS.ProcessEnv;
|
||||
readonly allowNonZeroExit?: boolean;
|
||||
readonly timeoutMs?: number;
|
||||
readonly maxOutputBytes?: number;
|
||||
readonly truncateOutputAtMaxBytes?: boolean;
|
||||
}) =>
|
||||
vcsRegistry
|
||||
.resolve({ cwd: input.cwd, requestedKind: "git" })
|
||||
.pipe(Effect.flatMap((handle) => handle.driver.execute(input))),
|
||||
};
|
||||
|
||||
const resolveHeadCommit = (cwd: string) =>
|
||||
vcs
|
||||
|
||||
@@ -25,7 +25,7 @@ import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { CheckpointStoreLive } from "../../checkpointing/Layers/CheckpointStore.ts";
|
||||
import { CheckpointStore } from "../../checkpointing/Services/CheckpointStore.ts";
|
||||
import { GitStatusBroadcaster } from "../../git/Services/GitStatusBroadcaster.ts";
|
||||
import * as GitVcsDriver from "../../vcs/GitVcsDriver.ts";
|
||||
import * as VcsDriverRegistry from "../../vcs/VcsDriverRegistry.ts";
|
||||
import * as VcsProcess from "../../vcs/VcsProcess.ts";
|
||||
import { RepositoryIdentityResolverLive } from "../../project/Layers/RepositoryIdentityResolver.ts";
|
||||
import { CheckpointReactorLive } from "./CheckpointReactor.ts";
|
||||
@@ -307,11 +307,11 @@ describe("CheckpointReactor", () => {
|
||||
Layer.provideMerge(RuntimeReceiptBusLive),
|
||||
Layer.provideMerge(Layer.succeed(ProviderService, provider.service)),
|
||||
Layer.provideMerge(gitStatusBroadcasterLayer),
|
||||
Layer.provideMerge(CheckpointStoreLive.pipe(Layer.provide(GitVcsDriver.vcsLayer))),
|
||||
Layer.provideMerge(CheckpointStoreLive.pipe(Layer.provide(VcsDriverRegistry.layer))),
|
||||
Layer.provideMerge(
|
||||
WorkspaceEntriesLive.pipe(
|
||||
Layer.provide(WorkspacePathsLive),
|
||||
Layer.provideMerge(GitVcsDriver.vcsLayer),
|
||||
Layer.provideMerge(VcsDriverRegistry.layer),
|
||||
),
|
||||
),
|
||||
Layer.provideMerge(WorkspacePathsLive),
|
||||
|
||||
@@ -105,7 +105,12 @@ import { WorkspaceEntriesLive } from "./workspace/Layers/WorkspaceEntries.ts";
|
||||
import { WorkspaceFileSystemLive } from "./workspace/Layers/WorkspaceFileSystem.ts";
|
||||
import { WorkspacePathsLive } from "./workspace/Layers/WorkspacePaths.ts";
|
||||
import * as GitVcsDriver from "./vcs/GitVcsDriver.ts";
|
||||
import { VcsDriver, type VcsDriverShape } from "./vcs/VcsDriver.ts";
|
||||
import type { VcsDriverShape } from "./vcs/VcsDriver.ts";
|
||||
import {
|
||||
VcsDriverRegistry,
|
||||
type VcsDriverRegistryShape,
|
||||
type VcsDriverHandle,
|
||||
} from "./vcs/VcsDriverRegistry.ts";
|
||||
import { ServerSecretStoreLive } from "./auth/Layers/ServerSecretStore.ts";
|
||||
import { ServerAuthLive } from "./auth/Layers/ServerAuth.ts";
|
||||
|
||||
@@ -316,6 +321,7 @@ const buildAppUnderTest = (options?: {
|
||||
serverSettings?: Partial<ServerSettingsShape>;
|
||||
open?: Partial<OpenShape>;
|
||||
vcsDriver?: Partial<VcsDriverShape>;
|
||||
vcsDriverRegistry?: Partial<VcsDriverRegistryShape>;
|
||||
gitVcsDriver?: Partial<GitVcsDriver.GitVcsDriverShape>;
|
||||
gitManager?: Partial<GitManagerShape>;
|
||||
gitStatusBroadcaster?: Partial<GitStatusBroadcasterShape>;
|
||||
@@ -364,7 +370,7 @@ const buildAppUnderTest = (options?: {
|
||||
...options?.config,
|
||||
};
|
||||
const layerConfig = Layer.succeed(ServerConfig, config);
|
||||
const vcsDriverLayer = Layer.mock(VcsDriver)({
|
||||
const defaultVcsDriver: VcsDriverShape = {
|
||||
capabilities: {
|
||||
kind: "git",
|
||||
supportsWorktrees: true,
|
||||
@@ -372,6 +378,14 @@ const buildAppUnderTest = (options?: {
|
||||
supportsAtomicSnapshot: false,
|
||||
supportsPushDefaultRemote: true,
|
||||
},
|
||||
execute: () =>
|
||||
Effect.succeed({
|
||||
exitCode: 0,
|
||||
stdout: "",
|
||||
stderr: "",
|
||||
stdoutTruncated: false,
|
||||
stderrTruncated: false,
|
||||
}),
|
||||
detectRepository: () => Effect.succeed(null),
|
||||
isInsideWorkTree: () => Effect.succeed(false),
|
||||
listWorkspaceFiles: () =>
|
||||
@@ -385,6 +399,56 @@ const buildAppUnderTest = (options?: {
|
||||
}),
|
||||
filterIgnoredPaths: (_cwd, relativePaths) => Effect.succeed(relativePaths),
|
||||
...options?.layers?.vcsDriver,
|
||||
};
|
||||
const vcsDriverRegistryLayer = Layer.mock(VcsDriverRegistry)({
|
||||
detect: (input) =>
|
||||
defaultVcsDriver.detectRepository(input.cwd).pipe(
|
||||
Effect.flatMap((repository) =>
|
||||
repository
|
||||
? Effect.succeed(repository)
|
||||
: defaultVcsDriver.isInsideWorkTree(input.cwd).pipe(
|
||||
Effect.map((isInsideWorkTree) =>
|
||||
isInsideWorkTree
|
||||
? {
|
||||
kind: "git" as const,
|
||||
rootPath: input.cwd,
|
||||
metadataPath: null,
|
||||
freshness: {
|
||||
source: "live-local" as const,
|
||||
observedAt: new Date(0).toISOString(),
|
||||
},
|
||||
}
|
||||
: null,
|
||||
),
|
||||
),
|
||||
),
|
||||
Effect.map((repository) =>
|
||||
repository
|
||||
? ({
|
||||
kind: repository.kind,
|
||||
repository,
|
||||
driver: defaultVcsDriver,
|
||||
} satisfies VcsDriverHandle)
|
||||
: null,
|
||||
),
|
||||
),
|
||||
resolve: (input) =>
|
||||
Effect.succeed({
|
||||
kind:
|
||||
input.requestedKind === "auto" || !input.requestedKind ? "git" : input.requestedKind,
|
||||
repository: {
|
||||
kind:
|
||||
input.requestedKind === "auto" || !input.requestedKind ? "git" : input.requestedKind,
|
||||
rootPath: input.cwd,
|
||||
metadataPath: null,
|
||||
freshness: {
|
||||
source: "live-local",
|
||||
observedAt: new Date(0).toISOString(),
|
||||
},
|
||||
},
|
||||
driver: defaultVcsDriver,
|
||||
}),
|
||||
...options?.layers?.vcsDriverRegistry,
|
||||
});
|
||||
const gitVcsDriverLayer = Layer.mock(GitVcsDriver.GitVcsDriver)({
|
||||
...options?.layers?.gitVcsDriver,
|
||||
@@ -394,7 +458,7 @@ const buildAppUnderTest = (options?: {
|
||||
});
|
||||
const workspaceEntriesLayer = WorkspaceEntriesLive.pipe(
|
||||
Layer.provide(WorkspacePathsLive),
|
||||
Layer.provideMerge(vcsDriverLayer),
|
||||
Layer.provideMerge(vcsDriverRegistryLayer),
|
||||
);
|
||||
const workspaceAndProjectServicesLayer = Layer.mergeAll(
|
||||
WorkspacePathsLive,
|
||||
|
||||
@@ -47,6 +47,7 @@ import { WorkspaceEntriesLive } from "./workspace/Layers/WorkspaceEntries.ts";
|
||||
import { WorkspaceFileSystemLive } from "./workspace/Layers/WorkspaceFileSystem.ts";
|
||||
import { WorkspacePathsLive } from "./workspace/Layers/WorkspacePaths.ts";
|
||||
import * as GitVcsDriver from "./vcs/GitVcsDriver.ts";
|
||||
import * as VcsDriverRegistry from "./vcs/VcsDriverRegistry.ts";
|
||||
import * as VcsProcess from "./vcs/VcsProcess.ts";
|
||||
import { ProjectSetupScriptRunnerLive } from "./project/Layers/ProjectSetupScriptRunner.ts";
|
||||
import { ObservabilityLive } from "./observability/Layers/Observability.ts";
|
||||
@@ -136,7 +137,7 @@ const ReactorLayerLive = Layer.empty.pipe(
|
||||
|
||||
const CheckpointingLayerLive = Layer.empty.pipe(
|
||||
Layer.provideMerge(CheckpointDiffQueryLive),
|
||||
Layer.provideMerge(CheckpointStoreLive.pipe(Layer.provide(GitVcsDriver.vcsLayer))),
|
||||
Layer.provideMerge(CheckpointStoreLive.pipe(Layer.provide(VcsDriverRegistry.layer))),
|
||||
);
|
||||
|
||||
const ProviderSessionDirectoryLayerLive = ProviderSessionDirectoryLive.pipe(
|
||||
@@ -173,7 +174,7 @@ const TerminalLayerLive = TerminalManagerLive.pipe(Layer.provide(PtyAdapterLive)
|
||||
|
||||
const WorkspaceEntriesLayerLive = WorkspaceEntriesLive.pipe(
|
||||
Layer.provide(WorkspacePathsLive),
|
||||
Layer.provideMerge(GitVcsDriver.vcsLayer),
|
||||
Layer.provideMerge(VcsDriverRegistry.layer),
|
||||
);
|
||||
|
||||
const WorkspaceFileSystemLayerLive = WorkspaceFileSystemLive.pipe(
|
||||
|
||||
@@ -278,7 +278,7 @@ const gitCommand = (
|
||||
: {}),
|
||||
});
|
||||
|
||||
export const makeVcsDriver = Effect.fn("makeGitVcsDriver")(function* () {
|
||||
export const makeVcsDriverShape = Effect.fn("makeGitVcsDriverShape")(function* () {
|
||||
const process = yield* VcsProcess;
|
||||
const capabilities = {
|
||||
kind: "git" as const,
|
||||
@@ -427,14 +427,19 @@ export const makeVcsDriver = Effect.fn("makeGitVcsDriver")(function* () {
|
||||
},
|
||||
);
|
||||
|
||||
return VcsDriver.of({
|
||||
return {
|
||||
capabilities,
|
||||
execute,
|
||||
detectRepository,
|
||||
isInsideWorkTree,
|
||||
listWorkspaceFiles,
|
||||
filterIgnoredPaths,
|
||||
});
|
||||
} satisfies VcsDriverShape;
|
||||
});
|
||||
|
||||
export const makeVcsDriver = Effect.fn("makeGitVcsDriver")(function* () {
|
||||
const driver = yield* makeVcsDriverShape();
|
||||
return VcsDriver.of(driver);
|
||||
});
|
||||
|
||||
export const make = Effect.fn("makeGitVcsDriverService")(function* () {
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
import { Context, Effect, Layer } from "effect";
|
||||
|
||||
import type { VcsDriverKind, VcsError, VcsRepositoryIdentity } from "@t3tools/contracts";
|
||||
import { VcsUnsupportedOperationError } from "@t3tools/contracts";
|
||||
import * as GitVcsDriver from "./GitVcsDriver.ts";
|
||||
import type { VcsDriverShape } from "./VcsDriver.ts";
|
||||
|
||||
export interface VcsDriverResolveInput {
|
||||
readonly cwd: string;
|
||||
readonly requestedKind?: VcsDriverKind | "auto";
|
||||
}
|
||||
|
||||
export interface VcsDriverHandle {
|
||||
readonly kind: VcsDriverKind;
|
||||
readonly repository: VcsRepositoryIdentity;
|
||||
readonly driver: VcsDriverShape;
|
||||
}
|
||||
|
||||
export interface VcsDriverRegistryShape {
|
||||
readonly detect: (
|
||||
input: VcsDriverResolveInput,
|
||||
) => Effect.Effect<VcsDriverHandle | null, VcsError>;
|
||||
readonly resolve: (input: VcsDriverResolveInput) => Effect.Effect<VcsDriverHandle, VcsError>;
|
||||
}
|
||||
|
||||
export class VcsDriverRegistry extends Context.Service<VcsDriverRegistry, VcsDriverRegistryShape>()(
|
||||
"t3/vcs/VcsDriverRegistry",
|
||||
) {}
|
||||
|
||||
const unsupported = (operation: string, kind: VcsDriverKind, detail: string) =>
|
||||
new VcsUnsupportedOperationError({
|
||||
operation,
|
||||
kind,
|
||||
detail,
|
||||
});
|
||||
|
||||
export const make = Effect.fn("makeVcsDriverRegistry")(function* () {
|
||||
const git = yield* GitVcsDriver.makeVcsDriverShape();
|
||||
const drivers: Partial<Record<VcsDriverKind, VcsDriverShape>> = {
|
||||
git,
|
||||
};
|
||||
|
||||
const detectWithDriver = Effect.fn("VcsDriverRegistry.detectWithDriver")(function* (
|
||||
kind: VcsDriverKind,
|
||||
driver: VcsDriverShape,
|
||||
cwd: string,
|
||||
) {
|
||||
const repository = yield* driver.detectRepository(cwd);
|
||||
if (!repository) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
kind,
|
||||
repository,
|
||||
driver,
|
||||
} satisfies VcsDriverHandle;
|
||||
});
|
||||
|
||||
const detect: VcsDriverRegistryShape["detect"] = Effect.fn("VcsDriverRegistry.detect")(
|
||||
function* (input) {
|
||||
const requestedKind = input.requestedKind ?? "auto";
|
||||
|
||||
if (requestedKind !== "auto" && requestedKind !== "unknown") {
|
||||
const driver = drivers[requestedKind];
|
||||
if (!driver) {
|
||||
return yield* unsupported(
|
||||
"VcsDriverRegistry.detect",
|
||||
requestedKind,
|
||||
`No ${requestedKind} VCS driver is registered.`,
|
||||
);
|
||||
}
|
||||
return yield* detectWithDriver(requestedKind, driver, input.cwd);
|
||||
}
|
||||
|
||||
return yield* detectWithDriver("git", git, input.cwd);
|
||||
},
|
||||
);
|
||||
|
||||
const resolve: VcsDriverRegistryShape["resolve"] = Effect.fn("VcsDriverRegistry.resolve")(
|
||||
function* (input) {
|
||||
const detected = yield* detect(input);
|
||||
if (detected) {
|
||||
return detected;
|
||||
}
|
||||
|
||||
const requestedKind = input.requestedKind ?? "auto";
|
||||
return yield* unsupported(
|
||||
"VcsDriverRegistry.resolve",
|
||||
requestedKind === "auto" ? "unknown" : requestedKind,
|
||||
requestedKind === "auto"
|
||||
? `No supported VCS repository was detected at ${input.cwd}.`
|
||||
: `No ${requestedKind} repository was detected at ${input.cwd}.`,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
return VcsDriverRegistry.of({
|
||||
detect,
|
||||
resolve,
|
||||
});
|
||||
});
|
||||
|
||||
export const layer = Layer.effect(VcsDriverRegistry, make());
|
||||
@@ -5,7 +5,7 @@ import { it, afterEach, describe, expect, vi } from "@effect/vitest";
|
||||
import { Effect, FileSystem, Layer, Path, PlatformError } from "effect";
|
||||
|
||||
import { ServerConfig } from "../../config.ts";
|
||||
import * as GitVcsDriver from "../../vcs/GitVcsDriver.ts";
|
||||
import * as VcsDriverRegistry from "../../vcs/VcsDriverRegistry.ts";
|
||||
import * as VcsProcess from "../../vcs/VcsProcess.ts";
|
||||
import { WorkspaceEntries } from "../Services/WorkspaceEntries.ts";
|
||||
import { WorkspaceEntriesLive } from "./WorkspaceEntries.ts";
|
||||
@@ -15,7 +15,7 @@ const TestLayer = Layer.empty.pipe(
|
||||
Layer.provideMerge(WorkspaceEntriesLive.pipe(Layer.provide(WorkspacePathsLive))),
|
||||
Layer.provideMerge(WorkspacePathsLive),
|
||||
Layer.provideMerge(VcsProcess.layer),
|
||||
Layer.provideMerge(GitVcsDriver.vcsLayer.pipe(Layer.provide(VcsProcess.layer))),
|
||||
Layer.provideMerge(VcsDriverRegistry.layer.pipe(Layer.provide(VcsProcess.layer))),
|
||||
Layer.provide(
|
||||
ServerConfig.layerTest(process.cwd(), {
|
||||
prefix: "t3-workspace-entries-test-",
|
||||
|
||||
@@ -2,7 +2,7 @@ import * as OS from "node:os";
|
||||
import fsPromises from "node:fs/promises";
|
||||
import type { Dirent } from "node:fs";
|
||||
|
||||
import { Cache, DateTime, Duration, Effect, Exit, Layer, Option, Path } from "effect";
|
||||
import { Cache, DateTime, Duration, Effect, Exit, Layer, Path } from "effect";
|
||||
|
||||
import { type FilesystemBrowseInput, type ProjectEntry } from "@t3tools/contracts";
|
||||
import { isExplicitRelativePath, isWindowsAbsolutePath } from "@t3tools/shared/path";
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
type RankedSearchResult,
|
||||
} from "@t3tools/shared/searchRanking";
|
||||
|
||||
import { VcsDriver } from "../../vcs/VcsDriver.ts";
|
||||
import { VcsDriverRegistry } from "../../vcs/VcsDriverRegistry.ts";
|
||||
import {
|
||||
WorkspaceEntries,
|
||||
WorkspaceEntriesBrowseError,
|
||||
@@ -174,38 +174,39 @@ const resolveBrowseTarget = (
|
||||
|
||||
export const makeWorkspaceEntries = Effect.gen(function* () {
|
||||
const path = yield* Path.Path;
|
||||
const vcsOption = yield* Effect.serviceOption(VcsDriver);
|
||||
const vcsRegistry = yield* VcsDriverRegistry;
|
||||
const workspacePaths = yield* WorkspacePaths;
|
||||
|
||||
const isInsideVcsWorkTree = (cwd: string): Effect.Effect<boolean> =>
|
||||
Option.match(vcsOption, {
|
||||
onSome: (vcs) => vcs.isInsideWorkTree(cwd).pipe(Effect.catch(() => Effect.succeed(false))),
|
||||
onNone: () => Effect.succeed(false),
|
||||
});
|
||||
vcsRegistry.detect({ cwd }).pipe(
|
||||
Effect.map((handle) => handle !== null),
|
||||
Effect.catch(() => Effect.succeed(false)),
|
||||
);
|
||||
|
||||
const filterVcsIgnoredPaths = (
|
||||
cwd: string,
|
||||
relativePaths: string[],
|
||||
): Effect.Effect<string[], never> =>
|
||||
Option.match(vcsOption, {
|
||||
onSome: (vcs) =>
|
||||
vcs.filterIgnoredPaths(cwd, relativePaths).pipe(
|
||||
Effect.map((paths) => [...paths]),
|
||||
Effect.catch(() => Effect.succeed(relativePaths)),
|
||||
),
|
||||
onNone: () => Effect.succeed(relativePaths),
|
||||
});
|
||||
vcsRegistry.detect({ cwd }).pipe(
|
||||
Effect.flatMap((handle) =>
|
||||
handle
|
||||
? handle.driver.filterIgnoredPaths(cwd, relativePaths).pipe(
|
||||
Effect.map((paths) => [...paths]),
|
||||
Effect.catch(() => Effect.succeed(relativePaths)),
|
||||
)
|
||||
: Effect.succeed(relativePaths),
|
||||
),
|
||||
Effect.catch(() => Effect.succeed(relativePaths)),
|
||||
);
|
||||
|
||||
const buildWorkspaceIndexFromVcs = Effect.fn("WorkspaceEntries.buildWorkspaceIndexFromVcs")(
|
||||
function* (cwd: string) {
|
||||
if (Option.isNone(vcsOption)) {
|
||||
return null;
|
||||
}
|
||||
if (!(yield* isInsideVcsWorkTree(cwd))) {
|
||||
const vcs = yield* vcsRegistry.detect({ cwd }).pipe(Effect.catch(() => Effect.succeed(null)));
|
||||
if (!vcs) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const listedFiles = yield* vcsOption.value
|
||||
const listedFiles = yield* vcs.driver
|
||||
.listWorkspaceFiles(cwd)
|
||||
.pipe(Effect.catch(() => Effect.succeed(null)));
|
||||
|
||||
@@ -216,7 +217,10 @@ export const makeWorkspaceEntries = Effect.gen(function* () {
|
||||
const listedPaths = [...listedFiles.paths]
|
||||
.map((entry) => toPosixPath(entry))
|
||||
.filter((entry) => entry.length > 0 && !isPathInIgnoredDirectory(entry));
|
||||
const filePaths = yield* filterVcsIgnoredPaths(cwd, listedPaths);
|
||||
const filePaths = yield* vcs.driver.filterIgnoredPaths(cwd, listedPaths).pipe(
|
||||
Effect.map((paths) => [...paths]),
|
||||
Effect.catch(() => filterVcsIgnoredPaths(cwd, listedPaths)),
|
||||
);
|
||||
|
||||
const directorySet = new Set<string>();
|
||||
for (const filePath of filePaths) {
|
||||
|
||||
@@ -3,7 +3,7 @@ import { it, describe, expect } from "@effect/vitest";
|
||||
import { Effect, FileSystem, Layer, Path } from "effect";
|
||||
|
||||
import { ServerConfig } from "../../config.ts";
|
||||
import * as GitVcsDriver from "../../vcs/GitVcsDriver.ts";
|
||||
import * as VcsDriverRegistry from "../../vcs/VcsDriverRegistry.ts";
|
||||
import * as VcsProcess from "../../vcs/VcsProcess.ts";
|
||||
import { WorkspaceEntries } from "../Services/WorkspaceEntries.ts";
|
||||
import { WorkspaceFileSystem } from "../Services/WorkspaceFileSystem.ts";
|
||||
@@ -20,7 +20,7 @@ const TestLayer = Layer.empty.pipe(
|
||||
Layer.provideMerge(ProjectLayer),
|
||||
Layer.provideMerge(WorkspaceEntriesLive.pipe(Layer.provide(WorkspacePathsLive))),
|
||||
Layer.provideMerge(WorkspacePathsLive),
|
||||
Layer.provideMerge(GitVcsDriver.vcsLayer.pipe(Layer.provide(VcsProcess.layer))),
|
||||
Layer.provideMerge(VcsDriverRegistry.layer.pipe(Layer.provide(VcsProcess.layer))),
|
||||
Layer.provide(
|
||||
ServerConfig.layerTest(process.cwd(), {
|
||||
prefix: "t3-workspace-files-test-",
|
||||
|
||||
Reference in new issue
Block a user