merge: update PR 2829 with latest main

Co-authored-by: codex <[email protected]>
This commit is contained in:
Julius Marmingeandcodex committed 2026-07-29 18:21:34 +02:00
commit 6643f4eb9c
2 files changed
+49 -1

No files matched your search

@@ -92,4 +92,49 @@ describe("VcsDriverRegistry", () => {
);
}).pipe(Effect.provide(layer));
});
it.effect("detects a repository created after a negative lookup", () => {
let insideWorkTreeChecks = 0;
const layer = Layer.effect(VcsDriverRegistry.VcsDriverRegistry, VcsDriverRegistry.make).pipe(
Layer.provide(NodeServices.layer),
Layer.provide(
Layer.mock(VcsProjectConfig.VcsProjectConfig)({
resolveKind: (input) => Effect.succeed(input.requestedKind ?? "auto"),
}),
),
Layer.provide(
Layer.mock(VcsProcess.VcsProcess)({
run: (input) =>
Effect.sync(() => {
const command = normalizeGitArgs(input.args).join(" ");
if (command === "rev-parse --is-inside-work-tree") {
insideWorkTreeChecks += 1;
return insideWorkTreeChecks === 1
? {
...processOutput(""),
exitCode: ChildProcessSpawner.ExitCode(128),
stderr: "fatal: not a git repository",
}
: processOutput("true\n");
}
if (command === "rev-parse --show-toplevel") {
return processOutput("/repo\n");
}
if (command === "rev-parse --git-common-dir") {
return processOutput("/repo/.git\n");
}
return processOutput("");
}),
}),
),
);
return Effect.gen(function* () {
const registry = yield* VcsDriverRegistry.VcsDriverRegistry;
assert.equal(yield* registry.detect({ cwd: "/repo" }), null);
assert.equal((yield* registry.detect({ cwd: "/repo" }))?.repository.rootPath, "/repo");
assert.equal(insideWorkTreeChecks, 2);
}).pipe(Effect.provide(layer));
});
});
+4 -1
View File
@@ -115,7 +115,10 @@ export const make = Effect.gen(function* () {
(key) => detectResolvedKind(parseDetectionCacheKey(key)),
{
capacity: DETECTION_CACHE_CAPACITY,
timeToLive: (exit) => (Exit.isSuccess(exit) ? DETECTION_CACHE_TTL : Duration.zero),
timeToLive: Exit.match({
onSuccess: (detected) => (detected === null ? Duration.zero : DETECTION_CACHE_TTL),
onFailure: () => Duration.zero,
}),
},
);