Skip to content

Commit 158349c

Browse files
fix(server): a failed Git version probe no longer advises installing Git
The Git and Jujutsu discovery probe used the plain install hint for every failure that was not a wrong-CPU spawn error, so a git whose --version exits non-zero or times out was shown with install advice. Share the hosting-CLI repair hint (failedProbeHint) with the VCS probe so it reports the failed command and its exit status or timeout. Fixes #35628 AI-assisted; verified with the tests and tools listed above.
1 parent f936803 commit 158349c

2 files changed

Lines changed: 33 additions & 24 deletions

File tree

‎apps/server/src/sourceControl/SourceControlDiscovery.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import { refreshPathFromLoginShell } from "../os-jank.ts";
1515
import * as VcsProcess from "../vcs/VcsProcess.ts";
1616
import {
1717
detailFromCause,
18+
failedProbeHint,
1819
firstNonEmptyLine,
19-
unavailableInstallHint,
2020
} from "@t3tools/source-control-core/server/discovery";
2121
import * as SourceControlProviderRegistry from "./SourceControlProviderRegistry.ts";
2222

@@ -119,7 +119,7 @@ export const make = Effect.gen(function* () {
119119
),
120120
Effect.catch((cause) =>
121121
Effect.gen(function* () {
122-
const installHint = yield* unavailableInstallHint(executable, input.installHint, cause);
122+
const installHint = yield* failedProbeHint(input, cause);
123123
return {
124124
kind: input.kind,
125125
label: input.label,

‎packages/source-control-core/src/server/discovery.ts‎

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -195,17 +195,6 @@ function isCliRemoteRefinementSpec(
195195
const isVcsProcessTimeoutError = Schema.is(VcsProcessTimeoutError);
196196
const isVcsProcessExitError = Schema.is(VcsProcessExitError);
197197

198-
/** An installed CLI whose version probe failed needs a repair, not install advice. */
199-
function probeFailureHint(spec: SourceControlCliDiscoverySpec, cause: unknown): string {
200-
const command = `\`${[spec.executable, ...spec.versionArgs].join(" ")}\``;
201-
const outcome = isVcsProcessTimeoutError(cause)
202-
? `timed out after ${cause.timeoutMs}ms`
203-
: isVcsProcessExitError(cause)
204-
? `exited with status ${cause.exitCode}`
205-
: "failed";
206-
return `${command} ${outcome}. Check the \`${spec.executable}\` that the server's PATH resolves.`;
207-
}
208-
209198
function probeCli(input: {
210199
readonly spec: SourceControlCliDiscoverySpec;
211200
readonly process: SourceControlHost.SourceControlHost["Service"]["process"];
@@ -238,22 +227,13 @@ function probeCli(input: {
238227
),
239228
Effect.catch((cause) =>
240229
Effect.gen(function* () {
241-
const hint = yield* unavailableInstallHint(
242-
input.spec.executable,
243-
input.spec.installHint,
244-
cause,
245-
);
246230
return {
247231
kind: input.spec.kind,
248232
label: input.spec.label,
249233
executable: input.spec.executable,
250234
status: "missing" as const,
251235
version: Option.none<string>(),
252-
// A wrong-CPU hint or an absent executable keeps its advice; other failures need repair.
253-
installHint:
254-
hint !== input.spec.installHint || isMissingExecutable(cause)
255-
? hint
256-
: probeFailureHint(input.spec, cause),
236+
installHint: yield* failedProbeHint(input.spec, cause),
257237
detail: detailFromCause(cause),
258238
} satisfies DiscoveryProbeResult;
259239
}),
@@ -361,7 +341,7 @@ export function isMissingExecutable(error: unknown): boolean {
361341
// Intel-only `gh` on Apple Silicon without Rosetta.
362342
const BAD_CPU_TYPE_ERRNO = -86;
363343

364-
export const unavailableInstallHint = Effect.fn("discovery.unavailableInstallHint")(function* (
344+
const unavailableInstallHint = Effect.fn("discovery.unavailableInstallHint")(function* (
365345
executable: string,
366346
installHint: string,
367347
cause: unknown,
@@ -382,6 +362,35 @@ export const unavailableInstallHint = Effect.fn("discovery.unavailableInstallHin
382362
return `\`${path ?? executable}\` is built for another CPU architecture, so this ${architecture} machine cannot run it. Remove or replace it. ${installHint}`;
383363
});
384364

365+
/** An installed CLI whose version probe failed needs a repair, not install advice. */
366+
function probeFailureHint(
367+
probe: { readonly executable: string; readonly versionArgs: ReadonlyArray<string> },
368+
cause: unknown,
369+
): string {
370+
const command = `\`${[probe.executable, ...probe.versionArgs].join(" ")}\``;
371+
const outcome = isVcsProcessTimeoutError(cause)
372+
? `timed out after ${cause.timeoutMs}ms`
373+
: isVcsProcessExitError(cause)
374+
? `exited with status ${cause.exitCode}`
375+
: "failed";
376+
return `${command} ${outcome}. Check the \`${probe.executable}\` that the server's PATH resolves.`;
377+
}
378+
379+
export const failedProbeHint = Effect.fn("discovery.failedProbeHint")(function* (
380+
probe: {
381+
readonly executable: string;
382+
readonly versionArgs: ReadonlyArray<string>;
383+
readonly installHint: string;
384+
},
385+
cause: unknown,
386+
) {
387+
const hint = yield* unavailableInstallHint(probe.executable, probe.installHint, cause);
388+
// A wrong-CPU hint or an absent executable keeps its advice; other failures need repair.
389+
return hint !== probe.installHint || isMissingExecutable(cause)
390+
? hint
391+
: probeFailureHint(probe, cause);
392+
});
393+
385394
class UnknownRemoteUnanswered extends Schema.TaggedError<UnknownRemoteUnanswered>()(
386395
"UnknownRemoteUnanswered",
387396
{},

0 commit comments

Comments
 (0)