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(...@@ -294,6 +294,18 @@ function configureRemote(
294 });294 });
295}295}
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
297function createTextGeneration(overrides: Partial<FakeGitTextGeneration> = {}): TextGenerationShape {309function createTextGeneration(overrides: Partial<FakeGitTextGeneration> = {}): TextGenerationShape {
298 const implementation: FakeGitTextGeneration = {310 const implementation: FakeGitTextGeneration = {
299 generateCommitMessage: (input) =>311 generateCommitMessage: (input) =>
...@@ -1012,11 +1024,12 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {...@@ -1012,11 +1024,12 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {
1012 yield* runGit(repoDir, ["push", "-u", "fork-seed", "statemachine"]);1024 yield* runGit(repoDir, ["push", "-u", "fork-seed", "statemachine"]);
1013 yield* runGit(repoDir, ["checkout", "-b", "t3code/pr-488/statemachine"]);1025 yield* runGit(repoDir, ["checkout", "-b", "t3code/pr-488/statemachine"]);
1014 yield* runGit(repoDir, ["branch", "--set-upstream-to", "fork-seed/statemachine"]);1026 yield* runGit(repoDir, ["branch", "--set-upstream-to", "fork-seed/statemachine"]);
1015 yield* runGit(repoDir, [1027 yield* configureVisibleRemoteUrlWithLocalRewrite(
1016 "config",1028 repoDir,
1017 "remote.fork-seed.url",1029 "fork-seed",
1018 "git@github.com:jasonLaster/codething-mvp.git",1030 "git@github.com:jasonLaster/codething-mvp.git",
1019 ]);1031 forkDir,
1032 );
10201033
1021 const { manager, ghCalls } = yield* makeManager({1034 const { manager, ghCalls } = yield* makeManager({
1022 ghScenario: {1035 ghScenario: {
...@@ -1076,17 +1089,19 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {...@@ -1076,17 +1089,19 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {
1076 yield* runGit(repoDir, ["checkout", "-b", "effect-atom"]);1089 yield* runGit(repoDir, ["checkout", "-b", "effect-atom"]);
1077 yield* runGit(repoDir, ["push", "-u", "origin", "effect-atom"]);1090 yield* runGit(repoDir, ["push", "-u", "origin", "effect-atom"]);
1078 yield* runGit(repoDir, ["push", "-u", "my-org/upstream", "effect-atom"]);1091 yield* runGit(repoDir, ["push", "-u", "my-org/upstream", "effect-atom"]);
1079 yield* runGit(repoDir, [1092 yield* configureVisibleRemoteUrlWithLocalRewrite(
1080 "config",1093 repoDir,
1081 "remote.origin.url",1094 "origin",
1082 "git@github.com:pingdotgg/codething-mvp.git",1095 "git@github.com:pingdotgg/codething-mvp.git",
1083 ]);1096 originDir,
1097 );
1084 yield* runGit(repoDir, ["config", "remote.origin.pushurl", originDir]);1098 yield* runGit(repoDir, ["config", "remote.origin.pushurl", originDir]);
1085 yield* runGit(repoDir, [1099 yield* configureVisibleRemoteUrlWithLocalRewrite(
1086 "config",1100 repoDir,
1087 "remote.my-org/upstream.url",1101 "my-org/upstream",
1088 "git@github.com:pingdotgg/codething-mvp.git",1102 "ssh://git@github.com/pingdotgg/codething-mvp.git",
1089 ]);1103 upstreamDir,
1104 );
1090 yield* runGit(repoDir, ["config", "remote.my-org/upstream.pushurl", upstreamDir]);1105 yield* runGit(repoDir, ["config", "remote.my-org/upstream.pushurl", upstreamDir]);
1091 yield* runGit(repoDir, ["checkout", "main"]);1106 yield* runGit(repoDir, ["checkout", "main"]);
1092 yield* runGit(repoDir, ["branch", "-D", "effect-atom"]);1107 yield* runGit(repoDir, ["branch", "-D", "effect-atom"]);
...@@ -1861,11 +1876,12 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {...@@ -1861,11 +1876,12 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {
1861 const forkDir = yield* createBareRemote();1876 const forkDir = yield* createBareRemote();
1862 yield* runGit(repoDir, ["remote", "add", "fork-seed", forkDir]);1877 yield* runGit(repoDir, ["remote", "add", "fork-seed", forkDir]);
1863 yield* runGit(repoDir, ["push", "-u", "fork-seed", "statemachine"]);1878 yield* runGit(repoDir, ["push", "-u", "fork-seed", "statemachine"]);
1864 yield* runGit(repoDir, [1879 yield* configureVisibleRemoteUrlWithLocalRewrite(
1865 "config",1880 repoDir,
1866 "remote.fork-seed.url",1881 "fork-seed",
1867 "git@github.com:octocat/codething-mvp.git",1882 "git@github.com:octocat/codething-mvp.git",
1868 ]);1883 forkDir,
1884 );
18691885
1870 const { manager, ghCalls } = yield* makeManager({1886 const { manager, ghCalls } = yield* makeManager({
1871 ghScenario: {1887 ghScenario: {
...@@ -1923,17 +1939,19 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {...@@ -1923,17 +1939,19 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {
1923 yield* runGit(repoDir, ["checkout", "-b", "effect-atom"]);1939 yield* runGit(repoDir, ["checkout", "-b", "effect-atom"]);
1924 yield* runGit(repoDir, ["push", "-u", "origin", "effect-atom"]);1940 yield* runGit(repoDir, ["push", "-u", "origin", "effect-atom"]);
1925 yield* runGit(repoDir, ["push", "-u", "my-org/upstream", "effect-atom"]);1941 yield* runGit(repoDir, ["push", "-u", "my-org/upstream", "effect-atom"]);
1926 yield* runGit(repoDir, [1942 yield* configureVisibleRemoteUrlWithLocalRewrite(
1927 "config",1943 repoDir,
1928 "remote.origin.url",1944 "origin",
1929 "git@github.com:pingdotgg/codething-mvp.git",1945 "git@github.com:pingdotgg/codething-mvp.git",
1930 ]);1946 originDir,
1947 );
1931 yield* runGit(repoDir, ["config", "remote.origin.pushurl", originDir]);1948 yield* runGit(repoDir, ["config", "remote.origin.pushurl", originDir]);
1932 yield* runGit(repoDir, [1949 yield* configureVisibleRemoteUrlWithLocalRewrite(
1933 "config",1950 repoDir,
1934 "remote.my-org/upstream.url",1951 "my-org/upstream",
1935 "git@github.com:pingdotgg/codething-mvp.git",1952 "ssh://git@github.com/pingdotgg/codething-mvp.git",
1936 ]);1953 upstreamDir,
1954 );
1937 yield* runGit(repoDir, ["config", "remote.my-org/upstream.pushurl", upstreamDir]);1955 yield* runGit(repoDir, ["config", "remote.my-org/upstream.pushurl", upstreamDir]);
1938 yield* runGit(repoDir, ["checkout", "main"]);1956 yield* runGit(repoDir, ["checkout", "main"]);
1939 yield* runGit(repoDir, ["branch", "-D", "effect-atom"]);1957 yield* runGit(repoDir, ["branch", "-D", "effect-atom"]);
...@@ -2013,11 +2031,12 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {...@@ -2013,11 +2031,12 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {
2013 yield* runGit(repoDir, ["push", "-u", "fork-seed", "statemachine"]);2031 yield* runGit(repoDir, ["push", "-u", "fork-seed", "statemachine"]);
2014 yield* runGit(repoDir, ["checkout", "-b", "t3code/pr-142/statemachine"]);2032 yield* runGit(repoDir, ["checkout", "-b", "t3code/pr-142/statemachine"]);
2015 yield* runGit(repoDir, ["branch", "--set-upstream-to", "fork-seed/statemachine"]);2033 yield* runGit(repoDir, ["branch", "--set-upstream-to", "fork-seed/statemachine"]);
2016 yield* runGit(repoDir, [2034 yield* configureVisibleRemoteUrlWithLocalRewrite(
2017 "config",2035 repoDir,
2018 "remote.fork-seed.url",2036 "fork-seed",
2019 "git@github.com:octocat/codething-mvp.git",2037 "git@github.com:octocat/codething-mvp.git",
2020 ]);2038 forkDir,
2039 );
20212040
2022 const { manager, ghCalls } = yield* makeManager({2041 const { manager, ghCalls } = yield* makeManager({
2023 ghScenario: {2042 ghScenario: {
...@@ -2083,11 +2102,12 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {...@@ -2083,11 +2102,12 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {
2083 yield* runGit(repoDir, ["push", "-u", "fork-seed", "statemachine"]);2102 yield* runGit(repoDir, ["push", "-u", "fork-seed", "statemachine"]);
2084 yield* runGit(repoDir, ["checkout", "-b", "t3code/pr-142/statemachine"]);2103 yield* runGit(repoDir, ["checkout", "-b", "t3code/pr-142/statemachine"]);
2085 yield* runGit(repoDir, ["branch", "--set-upstream-to", "fork-seed/statemachine"]);2104 yield* runGit(repoDir, ["branch", "--set-upstream-to", "fork-seed/statemachine"]);
2086 yield* runGit(repoDir, [2105 yield* configureVisibleRemoteUrlWithLocalRewrite(
2087 "config",2106 repoDir,
2088 "remote.fork-seed.url",2107 "fork-seed",
2089 "git@github.com:octocat/codething-mvp.git",2108 "git@github.com:octocat/codething-mvp.git",
2090 ]);2109 forkDir,
2110 );
20912111
2092 const { manager, ghCalls } = yield* makeManager({2112 const { manager, ghCalls } = yield* makeManager({
2093 ghScenario: {2113 ghScenario: {
...@@ -2263,11 +2283,12 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {...@@ -2263,11 +2283,12 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {
2263 yield* runGit(repoDir, ["push", "-u", "fork-seed", "statemachine"]);2283 yield* runGit(repoDir, ["push", "-u", "fork-seed", "statemachine"]);
2264 yield* runGit(repoDir, ["checkout", "-b", "t3code/pr-91/statemachine"]);2284 yield* runGit(repoDir, ["checkout", "-b", "t3code/pr-91/statemachine"]);
2265 yield* runGit(repoDir, ["branch", "--set-upstream-to", "fork-seed/statemachine"]);2285 yield* runGit(repoDir, ["branch", "--set-upstream-to", "fork-seed/statemachine"]);
2266 yield* runGit(repoDir, [2286 yield* configureVisibleRemoteUrlWithLocalRewrite(
2267 "config",2287 repoDir,
2268 "remote.fork-seed.url",2288 "fork-seed",
2269 "git@github.com:octocat/codething-mvp.git",2289 "git@github.com:octocat/codething-mvp.git",
2270 ]);2290 forkDir,
2291 );
22712292
2272 const { manager, ghCalls } = yield* makeManager({2293 const { manager, ghCalls } = yield* makeManager({
2273 ghScenario: {2294 ghScenario: {
...@@ -3147,7 +3168,7 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {...@@ -3147,7 +3168,7 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => {
3147 fs.writeFileSync(path.join(repoDir, "hooked.txt"), "hooked\n");3168 fs.writeFileSync(path.join(repoDir, "hooked.txt"), "hooked\n");
3148 fs.writeFileSync(3169 fs.writeFileSync(
3149 path.join(repoDir, ".git", "hooks", "pre-commit"),3170 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',
3151 { mode: 0o755 },3172 { mode: 0o755 },
3152 );3173 );
31533174
apps/server/src/terminal/Layers/Manager.test.ts+1-3
...@@ -238,9 +238,7 @@ const createManager = (...@@ -238,9 +238,7 @@ const createManager = (
238 ...(options.subprocessPollIntervalMs !== undefined238 ...(options.subprocessPollIntervalMs !== undefined
239 ? { subprocessPollIntervalMs: options.subprocessPollIntervalMs }239 ? { subprocessPollIntervalMs: options.subprocessPollIntervalMs }
240 : {}),240 : {}),
241 ...(options.processKillGraceMs !== undefined241 processKillGraceMs: options.processKillGraceMs ?? 1,
242 ? { processKillGraceMs: options.processKillGraceMs }
243 : {}),
244 ...(options.maxRetainedInactiveSessions !== undefined242 ...(options.maxRetainedInactiveSessions !== undefined
245 ? { maxRetainedInactiveSessions: options.maxRetainedInactiveSessions }243 ? { maxRetainedInactiveSessions: options.maxRetainedInactiveSessions }
246 : {}),244 : {}),