diff --git a/apps/server/src/git/Layers/GitHubCli.test.ts b/apps/server/src/git/Layers/GitHubCli.test.ts index 5a7b9cb8b1..1a89fca6b0 100644 --- a/apps/server/src/git/Layers/GitHubCli.test.ts +++ b/apps/server/src/git/Layers/GitHubCli.test.ts @@ -205,6 +205,50 @@ layer("GitHubCliLive", (it) => { }), ); + it.effect("creates pull requests with the title passed as a single argv value", () => + Effect.gen(function* () { + mockedRunProcess.mockResolvedValueOnce({ + stdout: "https://github.com/pingdotgg/codething-mvp/pull/42\n", + stderr: "", + code: 0, + signal: null, + timedOut: false, + }); + + yield* Effect.gen(function* () { + const gh = yield* GitHubCli; + yield* gh.createPullRequest({ + cwd: "/repo", + baseBranch: "main", + headSelector: "dev", + title: "Stabilize map selection, pricing badges, and camera handling", + bodyFile: + "C:\\Users\\leo20\\AppData\\Local\\Temp\\t3code-pr-body-38228-73481782-d57c-4b4d-ab5e-9906dc728b2b.md", + }); + }); + + expect(mockedRunProcess).toHaveBeenCalledWith( + "gh", + [ + "pr", + "create", + "--base", + "main", + "--head", + "dev", + "--title", + "Stabilize map selection, pricing badges, and camera handling", + "--body-file", + "C:\\Users\\leo20\\AppData\\Local\\Temp\\t3code-pr-body-38228-73481782-d57c-4b4d-ab5e-9906dc728b2b.md", + ], + expect.objectContaining({ + cwd: "/repo", + shell: false, + }), + ); + }), + ); + it.effect("surfaces a friendly error when the pull request is not found", () => Effect.gen(function* () { mockedRunProcess.mockRejectedValueOnce( diff --git a/apps/server/src/git/Layers/GitHubCli.ts b/apps/server/src/git/Layers/GitHubCli.ts index dbacdf6322..6efd9decfa 100644 --- a/apps/server/src/git/Layers/GitHubCli.ts +++ b/apps/server/src/git/Layers/GitHubCli.ts @@ -107,6 +107,7 @@ const makeGitHubCli = Effect.sync(() => { try: () => runProcess("gh", input.args, { cwd: input.cwd, + shell: false, timeoutMs: input.timeoutMs ?? DEFAULT_TIMEOUT_MS, }), catch: (error) => normalizeGitHubCliError("execute", error), diff --git a/apps/server/src/processRunner.ts b/apps/server/src/processRunner.ts index 03b164fc24..ee5312fe19 100644 --- a/apps/server/src/processRunner.ts +++ b/apps/server/src/processRunner.ts @@ -5,6 +5,7 @@ export interface ProcessRunOptions { timeoutMs?: number | undefined; env?: NodeJS.ProcessEnv | undefined; stdin?: string | undefined; + shell?: boolean | string | undefined; allowNonZeroExit?: boolean | undefined; maxBufferBytes?: number | undefined; outputMode?: "error" | "truncate" | undefined; @@ -152,7 +153,7 @@ export async function runProcess( cwd: options.cwd, env: options.env, stdio: "pipe", - shell: process.platform === "win32", + shell: options.shell ?? process.platform === "win32", }); let stdout = "";