Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c4945aad27 |
No files matched your search
@@ -638,6 +638,7 @@ function makeManager(input?: {
|
|||||||
ghScenario?: FakeGhScenario;
|
ghScenario?: FakeGhScenario;
|
||||||
textGeneration?: Partial<FakeGitTextGeneration>;
|
textGeneration?: Partial<FakeGitTextGeneration>;
|
||||||
setupScriptRunner?: ProjectSetupScriptRunner.ProjectSetupScriptRunner["Service"];
|
setupScriptRunner?: ProjectSetupScriptRunner.ProjectSetupScriptRunner["Service"];
|
||||||
|
vcsDriverLayer?: Layer.Layer<GitVcsDriver.GitVcsDriver>;
|
||||||
}) {
|
}) {
|
||||||
const { service: gitHubCli, ghCalls } = createGitHubCliWithFakeGh(input?.ghScenario);
|
const { service: gitHubCli, ghCalls } = createGitHubCliWithFakeGh(input?.ghScenario);
|
||||||
const textGeneration = createTextGeneration(input?.textGeneration);
|
const textGeneration = createTextGeneration(input?.textGeneration);
|
||||||
@@ -647,11 +648,13 @@ function makeManager(input?: {
|
|||||||
|
|
||||||
const serverSettingsLayer = ServerSettings.ServerSettingsService.layerTest();
|
const serverSettingsLayer = ServerSettings.ServerSettingsService.layerTest();
|
||||||
|
|
||||||
const vcsDriverLayer = GitVcsDriver.layer.pipe(
|
const vcsDriverLayer =
|
||||||
Layer.provideMerge(VcsProcess.layer),
|
input?.vcsDriverLayer ??
|
||||||
Layer.provideMerge(NodeServices.layer),
|
GitVcsDriver.layer.pipe(
|
||||||
Layer.provideMerge(serverConfigLayer),
|
Layer.provideMerge(VcsProcess.layer),
|
||||||
);
|
Layer.provideMerge(NodeServices.layer),
|
||||||
|
Layer.provideMerge(serverConfigLayer),
|
||||||
|
);
|
||||||
const sourceControlRegistryLayer = Layer.effect(
|
const sourceControlRegistryLayer = Layer.effect(
|
||||||
SourceControlProviderRegistry.SourceControlProviderRegistry,
|
SourceControlProviderRegistry.SourceControlProviderRegistry,
|
||||||
GitHubSourceControlProvider.make.pipe(
|
GitHubSourceControlProvider.make.pipe(
|
||||||
@@ -934,6 +937,30 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
it.effect("does not classify Git command failures from message text", () =>
|
||||||
|
Effect.gen(function* () {
|
||||||
|
const cwd = "/workspace";
|
||||||
|
const cause = new Error("spawn failed");
|
||||||
|
const commandError = new GitCommandError({
|
||||||
|
operation: "GitVcsDriver.statusDetails.status",
|
||||||
|
command: "git",
|
||||||
|
cwd,
|
||||||
|
detail: "not a git repository",
|
||||||
|
cause,
|
||||||
|
});
|
||||||
|
const { manager } = yield* makeManager({
|
||||||
|
vcsDriverLayer: Layer.mock(GitVcsDriver.GitVcsDriver)({
|
||||||
|
statusDetailsLocal: () => Effect.fail(commandError),
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
const error = yield* manager.localStatus({ cwd }).pipe(Effect.flip);
|
||||||
|
|
||||||
|
expect(error).toBe(commandError);
|
||||||
|
expect(error.cause).toBe(cause);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
it.effect("status briefly caches repeated lookups for the same cwd", () =>
|
it.effect("status briefly caches repeated lookups for the same cwd", () =>
|
||||||
Effect.gen(function* () {
|
Effect.gen(function* () {
|
||||||
const repoDir = yield* makeTempDir("t3code-git-manager-");
|
const repoDir = yield* makeTempDir("t3code-git-manager-");
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import * as Ref from "effect/Ref";
|
|||||||
import {
|
import {
|
||||||
GitActionProgressEvent,
|
GitActionProgressEvent,
|
||||||
GitActionProgressPhase,
|
GitActionProgressPhase,
|
||||||
GitCommandError,
|
|
||||||
GitPreparePullRequestThreadInput,
|
GitPreparePullRequestThreadInput,
|
||||||
GitPreparePullRequestThreadResult,
|
GitPreparePullRequestThreadResult,
|
||||||
GitPullRequestRefInput,
|
GitPullRequestRefInput,
|
||||||
@@ -99,10 +98,6 @@ type StripProgressContext<T> = T extends any ? Omit<T, "actionId" | "cwd" | "act
|
|||||||
type GitActionProgressPayload = StripProgressContext<GitActionProgressEvent>;
|
type GitActionProgressPayload = StripProgressContext<GitActionProgressEvent>;
|
||||||
type GitActionProgressEmitter = (event: GitActionProgressPayload) => Effect.Effect<void, never>;
|
type GitActionProgressEmitter = (event: GitActionProgressPayload) => Effect.Effect<void, never>;
|
||||||
|
|
||||||
function isNotGitRepositoryError(error: GitCommandError): boolean {
|
|
||||||
return error.message.toLowerCase().includes("not a git repository");
|
|
||||||
}
|
|
||||||
|
|
||||||
interface OpenPrInfo {
|
interface OpenPrInfo {
|
||||||
number: number;
|
number: number;
|
||||||
title: string;
|
title: string;
|
||||||
@@ -727,25 +722,8 @@ export const make = Effect.gen(function* () {
|
|||||||
const canonicalizeExistingPath = (value: string) =>
|
const canonicalizeExistingPath = (value: string) =>
|
||||||
fileSystem.realPath(value).pipe(Effect.orElseSucceed(() => value));
|
fileSystem.realPath(value).pipe(Effect.orElseSucceed(() => value));
|
||||||
const normalizeStatusCacheKey = canonicalizeExistingPath;
|
const normalizeStatusCacheKey = canonicalizeExistingPath;
|
||||||
const nonRepositoryStatusDetails = {
|
|
||||||
isRepo: false,
|
|
||||||
hasOriginRemote: false,
|
|
||||||
isDefaultBranch: false,
|
|
||||||
branch: null,
|
|
||||||
upstreamRef: null,
|
|
||||||
hasWorkingTreeChanges: false,
|
|
||||||
workingTree: { files: [], insertions: 0, deletions: 0 },
|
|
||||||
hasUpstream: false,
|
|
||||||
aheadCount: 0,
|
|
||||||
behindCount: 0,
|
|
||||||
aheadOfDefaultCount: 0,
|
|
||||||
} satisfies GitVcsDriver.GitStatusDetails;
|
|
||||||
const readLocalStatus = Effect.fn("readLocalStatus")(function* (cwd: string) {
|
const readLocalStatus = Effect.fn("readLocalStatus")(function* (cwd: string) {
|
||||||
const details = yield* gitCore
|
const details = yield* gitCore.statusDetailsLocal(cwd);
|
||||||
.statusDetailsLocal(cwd)
|
|
||||||
.pipe(
|
|
||||||
Effect.catchIf(isNotGitRepositoryError, () => Effect.succeed(nonRepositoryStatusDetails)),
|
|
||||||
);
|
|
||||||
const hostingProvider = details.isRepo
|
const hostingProvider = details.isRepo
|
||||||
? yield* resolveHostingProvider(cwd, details.branch)
|
? yield* resolveHostingProvider(cwd, details.branch)
|
||||||
: null;
|
: null;
|
||||||
@@ -772,9 +750,7 @@ export const make = Effect.gen(function* () {
|
|||||||
cwd: string,
|
cwd: string,
|
||||||
options?: GitVcsDriver.GitRemoteStatusOptions,
|
options?: GitVcsDriver.GitRemoteStatusOptions,
|
||||||
) {
|
) {
|
||||||
const details = yield* gitCore
|
const details = yield* gitCore.statusDetailsRemote(cwd, options);
|
||||||
.statusDetailsRemote(cwd, options)
|
|
||||||
.pipe(Effect.catchIf(isNotGitRepositoryError, () => Effect.succeed(null)));
|
|
||||||
if (details === null || !details.isRepo) {
|
if (details === null || !details.isRepo) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user