Add more logging around git commit failure (#467)

Help with #464

Co-authored-by: William Chen <will@mac.lan>
This commit is contained in:
Will Chen
2025-06-23 13:11:28 -07:00
committed by GitHub
parent c879a4e01d
commit 2f00dc5955
2 changed files with 24 additions and 1 deletions

View File

@@ -18,6 +18,11 @@ const TEST_RESPONSES: Record<string, string> = {
<dyad-add-dependency packages="react-router-dom react-query"></dyad-add-dependency> <dyad-add-dependency packages="react-router-dom react-query"></dyad-add-dependency>
EOM`,
write: `Hello world
<dyad-write path="src/hello.ts" content="Hello world">
console.log("Hello world");
</dyad-write>
EOM`, EOM`,
"string-literal-leak": `BEFORE TAG "string-literal-leak": `BEFORE TAG
<dyad-write path="src/pages/locations/neighborhoods/louisville/Highlands.tsx" description="Updating Highlands neighborhood page to use <a> tags."> <dyad-write path="src/pages/locations/neighborhoods/louisville/Highlands.tsx" description="Updating Highlands neighborhood page to use <a> tags.">

View File

@@ -9,6 +9,23 @@ import { readSettings } from "../../main/settings";
const execAsync = promisify(exec); 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({ export async function gitCommit({
path, path,
message, message,
@@ -24,7 +41,8 @@ export async function gitCommit({
if (amend) { if (amend) {
command += " --amend"; command += " --amend";
} }
await execAsync(command);
await verboseExecAsync(command);
const { stdout } = await execAsync(`git -C "${path}" rev-parse HEAD`); const { stdout } = await execAsync(`git -C "${path}" rev-parse HEAD`);
return stdout.trim(); return stdout.trim();
} else { } else {