From 248957ae62ff5aab48d5603261c235d5a770786f Mon Sep 17 00:00:00 2001 From: Brace Sproul Date: Fri, 25 Jul 2025 15:46:26 -0700 Subject: [PATCH] fix: Pulling and pushing bug (#535) --- apps/open-swe/src/utils/github/git.ts | 36 +++++++++++++++------------ 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/apps/open-swe/src/utils/github/git.ts b/apps/open-swe/src/utils/github/git.ts index 13c40fc4..58d675bf 100644 --- a/apps/open-swe/src/utils/github/git.ts +++ b/apps/open-swe/src/utils/github/git.ts @@ -146,22 +146,26 @@ export async function checkoutBranchAndCommit( }, { retries: 3, delay: 0 }, ); - const gitStatus = await sandbox.git.status(absoluteRepoDir); - const errorFields = { - ...(pushRes2 instanceof Error - ? { - name: pushRes2.name, - message: pushRes2.message, - stack: pushRes2.stack, - cause: pushRes2.cause, - } - : pushRes2), - }; - logger.error("Failed to push changes", { - ...errorFields, - gitStatus: JSON.stringify(gitStatus, null, 2), - }); - throw new Error("Failed to push changes"); + if (pushRes2 instanceof Error) { + const gitStatus = await sandbox.git.status(absoluteRepoDir); + const errorFields = { + ...(pushRes2 instanceof Error + ? { + name: pushRes2.name, + message: pushRes2.message, + stack: pushRes2.stack, + cause: pushRes2.cause, + } + : pushRes2), + }; + logger.error("Failed to push changes", { + ...errorFields, + gitStatus: JSON.stringify(gitStatus, null, 2), + }); + throw new Error("Failed to push changes"); + } else { + logger.info("Pulling changes before pushing succeeded"); + } } else { logger.info("Successfully pushed changes"); }