Skip to content

Commit ae8379b

Browse files
committed
Disable SSH askpass for upstream status fetches
- Extended `ExecuteGitOptions` with `env` field - Pass `SSH_ASKPASS_REQUIRE=never` to upstream status fetch to prevent annoying popups that cannot be usefully responded
1 parent 5467d11 commit ae8379b

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

apps/server/src/git/Layers/GitCore.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,9 +1023,11 @@ it.layer(TestLayer)("git integration", (it) => {
10231023
expect(yield* git(source, ["branch", "--show-current"])).toBe("upstream/feature");
10241024
const realGitCore = yield* GitCore;
10251025
let fetchArgs: readonly string[] | null = null;
1026+
let fetchEnv: NodeJS.ProcessEnv | undefined;
10261027
const core = yield* makeIsolatedGitCore((input) => {
10271028
if (input.args[0] === "--git-dir" && input.args[2] === "fetch") {
10281029
fetchArgs = [...input.args];
1030+
fetchEnv = input.env;
10291031
return Effect.succeed({
10301032
code: 0,
10311033
stdout: "",
@@ -1049,6 +1051,9 @@ it.layer(TestLayer)("git integration", (it) => {
10491051
remoteName,
10501052
`+refs/heads/${featureBranch}:refs/remotes/${remoteName}/${featureBranch}`,
10511053
]);
1054+
expect(fetchEnv).toEqual({
1055+
SSH_ASKPASS_REQUIRE: "never",
1056+
});
10521057
}),
10531058
);
10541059

apps/server/src/git/Layers/GitCore.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ class StatusUpstreamRefreshCacheKey extends Data.Class<{
8787

8888
interface ExecuteGitOptions {
8989
stdin?: string | undefined;
90+
env?: NodeJS.ProcessEnv | undefined;
9091
timeoutMs?: number | undefined;
9192
allowNonZeroExit?: boolean | undefined;
9293
fallbackErrorMessage?: string | undefined;
@@ -799,6 +800,7 @@ export const makeGitCore = Effect.fn("makeGitCore")(function* (options?: {
799800
cwd,
800801
args,
801802
...(options.stdin !== undefined ? { stdin: options.stdin } : {}),
803+
...(options.env !== undefined ? { env: options.env } : {}),
802804
allowNonZeroExit: true,
803805
...(options.timeoutMs !== undefined ? { timeoutMs: options.timeoutMs } : {}),
804806
...(options.maxOutputBytes !== undefined ? { maxOutputBytes: options.maxOutputBytes } : {}),
@@ -932,6 +934,9 @@ export const makeGitCore = Effect.fn("makeGitCore")(function* (options?: {
932934
["--git-dir", gitCommonDir, "fetch", "--quiet", "--no-tags", upstream.remoteName, refspec],
933935
{
934936
allowNonZeroExit: true,
937+
env: {
938+
SSH_ASKPASS_REQUIRE: "never",
939+
},
935940
timeoutMs: Duration.toMillis(STATUS_UPSTREAM_REFRESH_TIMEOUT),
936941
},
937942
).pipe(Effect.asVoid);

0 commit comments

Comments
 (0)