Skip to content

Commit c1be4c9

Browse files
committed
Use batch SSH for upstream status fetches
- Add `core.sshCommand=ssh -o BatchMode=yes` to `git fetch` used for upstream status refresh - Update tests to assert the new fetch invocation
1 parent 5467d11 commit c1be4c9

2 files changed

Lines changed: 18 additions & 6 deletions

File tree

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ it.layer(TestLayer)("git integration", (it) => {
759759
const realGitCore = yield* GitCore;
760760
let refreshFetchAttempts = 0;
761761
const core = yield* makeIsolatedGitCore((input) => {
762-
if (input.args[0] === "--git-dir" && input.args[2] === "fetch") {
762+
if (input.operation === "GitCore.fetchUpstreamRefForStatus") {
763763
refreshFetchAttempts += 1;
764764
return Effect.fail(
765765
new GitCommandError({
@@ -805,7 +805,7 @@ it.layer(TestLayer)("git integration", (it) => {
805805
const realGitCore = yield* GitCore;
806806
let refreshFetchAttempts = 0;
807807
const core = yield* makeIsolatedGitCore((input) => {
808-
if (input.args[0] === "--git-dir" && input.args[2] === "fetch") {
808+
if (input.operation === "GitCore.fetchUpstreamRefForStatus") {
809809
refreshFetchAttempts += 1;
810810
return Effect.succeed({
811811
code: 0,
@@ -853,7 +853,7 @@ it.layer(TestLayer)("git integration", (it) => {
853853
if (input.args[0] === "rev-parse" && input.args[1] === "--git-common-dir") {
854854
return ok("/repo/.git\n");
855855
}
856-
if (input.args[0] === "--git-dir" && input.args[2] === "fetch") {
856+
if (input.operation === "GitCore.fetchUpstreamRefForStatus") {
857857
fetchCount += 1;
858858
expect(input.cwd).toBe("/repo");
859859
return ok();
@@ -913,7 +913,7 @@ it.layer(TestLayer)("git integration", (it) => {
913913
if (input.args[0] === "rev-parse" && input.args[1] === "--git-common-dir") {
914914
return ok("/repo/.git\n");
915915
}
916-
if (input.args[0] === "--git-dir" && input.args[2] === "fetch") {
916+
if (input.operation === "GitCore.fetchUpstreamRefForStatus") {
917917
fetchCount += 1;
918918
return Effect.fail(
919919
new GitCommandError({
@@ -1024,7 +1024,7 @@ it.layer(TestLayer)("git integration", (it) => {
10241024
const realGitCore = yield* GitCore;
10251025
let fetchArgs: readonly string[] | null = null;
10261026
const core = yield* makeIsolatedGitCore((input) => {
1027-
if (input.args[0] === "--git-dir" && input.args[2] === "fetch") {
1027+
if (input.operation === "GitCore.fetchUpstreamRefForStatus") {
10281028
fetchArgs = [...input.args];
10291029
return Effect.succeed({
10301030
code: 0,
@@ -1041,6 +1041,8 @@ it.layer(TestLayer)("git integration", (it) => {
10411041
expect(status.branch).toBe("upstream/feature");
10421042
expect(status.upstreamRef).toBe(`${remoteName}/${featureBranch}`);
10431043
expect(fetchArgs).toEqual([
1044+
"-c",
1045+
"core.sshCommand=ssh -o BatchMode=yes",
10441046
"--git-dir",
10451047
path.join(source, ".git"),
10461048
"fetch",

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,17 @@ export const makeGitCore = Effect.fn("makeGitCore")(function* (options?: {
929929
return executeGit(
930930
"GitCore.fetchUpstreamRefForStatus",
931931
fetchCwd,
932-
["--git-dir", gitCommonDir, "fetch", "--quiet", "--no-tags", upstream.remoteName, refspec],
932+
[
933+
"-c",
934+
"core.sshCommand=ssh -o BatchMode=yes",
935+
"--git-dir",
936+
gitCommonDir,
937+
"fetch",
938+
"--quiet",
939+
"--no-tags",
940+
upstream.remoteName,
941+
refspec,
942+
],
933943
{
934944
allowNonZeroExit: true,
935945
timeoutMs: Duration.toMillis(STATUS_UPSTREAM_REFRESH_TIMEOUT),

0 commit comments

Comments
 (0)