authorgravatar for julius0216@outlook.comJulius Marminge <julius0216@outlook.com> 2026-05-05 20:31:44-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2026-05-05 20:31:44-07:00
log25c9d267acbf058229a07e9f789be8ac00dec6d7
treef15c6e636e8204c0344085f6af3a26b0ef453533
parent536dcad19e32c66f24eaa14b9b2189b3dfd444bb
signature Signed by PGP key B5690EEEBB952194

Stabilize git workspace and terminal tests (#2540)

Co-authored-by: Julius Marminge <julius@macmini.local>

2 files changed, 61 insertions(+), 42 deletions(-)

apps/server/src/git/GitManager.test.ts+60-39
......@@ -294,6 +294,18 @@ function configureRemote(
294294 });
295295}
296296
297function configureVisibleRemoteUrlWithLocalRewrite(
298 cwd: string,
299 remoteName: string,
300 visibleUrl: string,
301 localRemotePath: string,
302): Effect.Effect<void, GitCommandError, GitVcsDriver.GitVcsDriver> {
303 return Effect.gen(function* () {
304 yield* runGit(cwd, ["config", `remote.${remoteName}.url`, visibleUrl]);
305 yield* runGit(cwd, ["config", `url.${localRemotePath}.insteadOf`, visibleUrl]);
306 });
307}
308
297309function createTextGeneration(overrides: Partial<FakeGitTextGeneration> = {}): TextGenerationShape {
298310 const implementation: FakeGitTextGeneration = {
299311 generateCommitMessage: (input) =>
......@@ -1012,11 +1024,12 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {
10121024 yield* runGit(repoDir, ["push", "-u", "fork-seed", "statemachine"]);
10131025 yield* runGit(repoDir, ["checkout", "-b", "t3code/pr-488/statemachine"]);
10141026 yield* runGit(repoDir, ["branch", "--set-upstream-to", "fork-seed/statemachine"]);
1015 yield* runGit(repoDir, [
1016 "config",
1017 "remote.fork-seed.url",
1027 yield* configureVisibleRemoteUrlWithLocalRewrite(
1028 repoDir,
1029 "fork-seed",
10181030 "git@github.com:jasonLaster/codething-mvp.git",
1019 ]);
1031 forkDir,
1032 );
10201033
10211034 const { manager, ghCalls } = yield* makeManager({
10221035 ghScenario: {
......@@ -1076,17 +1089,19 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {
10761089 yield* runGit(repoDir, ["checkout", "-b", "effect-atom"]);
10771090 yield* runGit(repoDir, ["push", "-u", "origin", "effect-atom"]);
10781091 yield* runGit(repoDir, ["push", "-u", "my-org/upstream", "effect-atom"]);
1079 yield* runGit(repoDir, [
1080 "config",
1081 "remote.origin.url",
1092 yield* configureVisibleRemoteUrlWithLocalRewrite(
1093 repoDir,
1094 "origin",
10821095 "git@github.com:pingdotgg/codething-mvp.git",
1083 ]);
1096 originDir,
1097 );
10841098 yield* runGit(repoDir, ["config", "remote.origin.pushurl", originDir]);
1085 yield* runGit(repoDir, [
1086 "config",
1087 "remote.my-org/upstream.url",
1088 "git@github.com:pingdotgg/codething-mvp.git",
1089 ]);
1099 yield* configureVisibleRemoteUrlWithLocalRewrite(
1100 repoDir,
1101 "my-org/upstream",
1102 "ssh://git@github.com/pingdotgg/codething-mvp.git",
1103 upstreamDir,
1104 );
10901105 yield* runGit(repoDir, ["config", "remote.my-org/upstream.pushurl", upstreamDir]);
10911106 yield* runGit(repoDir, ["checkout", "main"]);
10921107 yield* runGit(repoDir, ["branch", "-D", "effect-atom"]);
......@@ -1861,11 +1876,12 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {
18611876 const forkDir = yield* createBareRemote();
18621877 yield* runGit(repoDir, ["remote", "add", "fork-seed", forkDir]);
18631878 yield* runGit(repoDir, ["push", "-u", "fork-seed", "statemachine"]);
1864 yield* runGit(repoDir, [
1865 "config",
1866 "remote.fork-seed.url",
1879 yield* configureVisibleRemoteUrlWithLocalRewrite(
1880 repoDir,
1881 "fork-seed",
18671882 "git@github.com:octocat/codething-mvp.git",
1868 ]);
1883 forkDir,
1884 );
18691885
18701886 const { manager, ghCalls } = yield* makeManager({
18711887 ghScenario: {
......@@ -1923,17 +1939,19 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {
19231939 yield* runGit(repoDir, ["checkout", "-b", "effect-atom"]);
19241940 yield* runGit(repoDir, ["push", "-u", "origin", "effect-atom"]);
19251941 yield* runGit(repoDir, ["push", "-u", "my-org/upstream", "effect-atom"]);
1926 yield* runGit(repoDir, [
1927 "config",
1928 "remote.origin.url",
1942 yield* configureVisibleRemoteUrlWithLocalRewrite(
1943 repoDir,
1944 "origin",
19291945 "git@github.com:pingdotgg/codething-mvp.git",
1930 ]);
1946 originDir,
1947 );
19311948 yield* runGit(repoDir, ["config", "remote.origin.pushurl", originDir]);
1932 yield* runGit(repoDir, [
1933 "config",
1934 "remote.my-org/upstream.url",
1935 "git@github.com:pingdotgg/codething-mvp.git",
1936 ]);
1949 yield* configureVisibleRemoteUrlWithLocalRewrite(
1950 repoDir,
1951 "my-org/upstream",
1952 "ssh://git@github.com/pingdotgg/codething-mvp.git",
1953 upstreamDir,
1954 );
19371955 yield* runGit(repoDir, ["config", "remote.my-org/upstream.pushurl", upstreamDir]);
19381956 yield* runGit(repoDir, ["checkout", "main"]);
19391957 yield* runGit(repoDir, ["branch", "-D", "effect-atom"]);
......@@ -2013,11 +2031,12 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {
20132031 yield* runGit(repoDir, ["push", "-u", "fork-seed", "statemachine"]);
20142032 yield* runGit(repoDir, ["checkout", "-b", "t3code/pr-142/statemachine"]);
20152033 yield* runGit(repoDir, ["branch", "--set-upstream-to", "fork-seed/statemachine"]);
2016 yield* runGit(repoDir, [
2017 "config",
2018 "remote.fork-seed.url",
2034 yield* configureVisibleRemoteUrlWithLocalRewrite(
2035 repoDir,
2036 "fork-seed",
20192037 "git@github.com:octocat/codething-mvp.git",
2020 ]);
2038 forkDir,
2039 );
20212040
20222041 const { manager, ghCalls } = yield* makeManager({
20232042 ghScenario: {
......@@ -2083,11 +2102,12 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {
20832102 yield* runGit(repoDir, ["push", "-u", "fork-seed", "statemachine"]);
20842103 yield* runGit(repoDir, ["checkout", "-b", "t3code/pr-142/statemachine"]);
20852104 yield* runGit(repoDir, ["branch", "--set-upstream-to", "fork-seed/statemachine"]);
2086 yield* runGit(repoDir, [
2087 "config",
2088 "remote.fork-seed.url",
2105 yield* configureVisibleRemoteUrlWithLocalRewrite(
2106 repoDir,
2107 "fork-seed",
20892108 "git@github.com:octocat/codething-mvp.git",
2090 ]);
2109 forkDir,
2110 );
20912111
20922112 const { manager, ghCalls } = yield* makeManager({
20932113 ghScenario: {
......@@ -2263,11 +2283,12 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {
22632283 yield* runGit(repoDir, ["push", "-u", "fork-seed", "statemachine"]);
22642284 yield* runGit(repoDir, ["checkout", "-b", "t3code/pr-91/statemachine"]);
22652285 yield* runGit(repoDir, ["branch", "--set-upstream-to", "fork-seed/statemachine"]);
2266 yield* runGit(repoDir, [
2267 "config",
2268 "remote.fork-seed.url",
2286 yield* configureVisibleRemoteUrlWithLocalRewrite(
2287 repoDir,
2288 "fork-seed",
22692289 "git@github.com:octocat/codething-mvp.git",
2270 ]);
2290 forkDir,
2291 );
22712292
22722293 const { manager, ghCalls } = yield* makeManager({
22732294 ghScenario: {
......@@ -3147,7 +3168,7 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {
31473168 fs.writeFileSync(path.join(repoDir, "hooked.txt"), "hooked\n");
31483169 fs.writeFileSync(
31493170 path.join(repoDir, ".git", "hooks", "pre-commit"),
3150 '#!/bin/sh\necho "hook: start" >&2\nsleep 1\necho "hook: end" >&2\n',
3171 '#!/bin/sh\necho "hook: start" >&2\nsleep 0.05\necho "hook: end" >&2\n',
31513172 { mode: 0o755 },
31523173 );
31533174
apps/server/src/terminal/Layers/Manager.test.ts+1-3
......@@ -238,9 +238,7 @@ const createManager = (
238238 ...(options.subprocessPollIntervalMs !== undefined
239239 ? { subprocessPollIntervalMs: options.subprocessPollIntervalMs }
240240 : {}),
241 ...(options.processKillGraceMs !== undefined
242 ? { processKillGraceMs: options.processKillGraceMs }
243 : {}),
241 processKillGraceMs: options.processKillGraceMs ?? 1,
244242 ...(options.maxRetainedInactiveSessions !== undefined
245243 ? { maxRetainedInactiveSessions: options.maxRetainedInactiveSessions }
246244 : {}),