From 2f00dc59550d68c36a23aefa51fbdf929b2299cc Mon Sep 17 00:00:00 2001 From: Will Chen Date: Mon, 23 Jun 2025 13:11:28 -0700 Subject: [PATCH] Add more logging around git commit failure (#467) Help with #464 Co-authored-by: William Chen --- src/ipc/handlers/testing_chat_handlers.ts | 5 +++++ src/ipc/utils/git_utils.ts | 20 +++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/ipc/handlers/testing_chat_handlers.ts b/src/ipc/handlers/testing_chat_handlers.ts index 780b8fc..75ab241 100644 --- a/src/ipc/handlers/testing_chat_handlers.ts +++ b/src/ipc/handlers/testing_chat_handlers.ts @@ -18,6 +18,11 @@ const TEST_RESPONSES: Record = { + EOM`, + write: `Hello world + + console.log("Hello world"); + EOM`, "string-literal-leak": `BEFORE TAG diff --git a/src/ipc/utils/git_utils.ts b/src/ipc/utils/git_utils.ts index 46533bf..c03d7de 100644 --- a/src/ipc/utils/git_utils.ts +++ b/src/ipc/utils/git_utils.ts @@ -9,6 +9,23 @@ import { readSettings } from "../../main/settings"; const execAsync = promisify(exec); +async function verboseExecAsync( + command: string, +): Promise<{ stdout: string; stderr: string }> { + try { + return await execAsync(command); + } catch (error: any) { + let errorMessage = `Error: ${error.message}`; + if (error.stdout) { + errorMessage += `\nStdout: ${error.stdout}`; + } + if (error.stderr) { + errorMessage += `\nStderr: ${error.stderr}`; + } + throw new Error(errorMessage); + } +} + export async function gitCommit({ path, message, @@ -24,7 +41,8 @@ export async function gitCommit({ if (amend) { command += " --amend"; } - await execAsync(command); + + await verboseExecAsync(command); const { stdout } = await execAsync(`git -C "${path}" rev-parse HEAD`); return stdout.trim(); } else {