chore: Better git debug logging (#673)

This commit is contained in:
Brace Sproul 2025-08-04 17:57:08 -07:00 • committed by GitHub
parent 8349cbb763
commit 162d66016e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -284,14 +284,45 @@ export async function checkoutBranchAndCommit(
);
if (pushRes instanceof Error) {
logger.info("Failed to push changes, attempting to pull and push again");
const errorFields =
pushRes instanceof Error
? {
message: pushRes.message,
name: pushRes.name,
}
: pushRes;
logger.error("Failed to push changes, attempting to pull and push again", {
...errorFields,
});
// attempt to git pull, then push again
await sandbox.git.pull(
absoluteRepoDir,
"git",
options.githubInstallationToken,
const pullRes = await withRetry(
async () => {
return await sandbox.git.pull(
absoluteRepoDir,
"git",
options.githubInstallationToken,
);
},
{ retries: 1, delay: 0 },
);
logger.info("Successfully pulled changes. Pushing again.");
if (pullRes instanceof Error) {
const errorFields =
pullRes instanceof Error
? {
message: pullRes.message,
name: pullRes.name,
}
: pullRes;
logger.error("Failed to pull changes after a push failed.", {
...errorFields,
});
} else {
logger.info("Successfully pulled changes. Pushing again.");
}
const pushRes2 = await withRetry(
async () => {
return await sandbox.git.push(
@ -302,6 +333,7 @@ export async function checkoutBranchAndCommit(
},
{ retries: 3, delay: 0 },
);
if (pushRes2 instanceof Error) {
const gitStatus = await sandbox.git.status(absoluteRepoDir);
const errorFields = {