Add more logging around git commit failure (#467)
Help with #464 Co-authored-by: William Chen <will@mac.lan>
This commit is contained in:
@@ -18,6 +18,11 @@ const TEST_RESPONSES: Record<string, string> = {
|
||||
|
||||
<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`,
|
||||
"string-literal-leak": `BEFORE TAG
|
||||
<dyad-write path="src/pages/locations/neighborhoods/louisville/Highlands.tsx" description="Updating Highlands neighborhood page to use <a> tags.">
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user