mirror of
https://github.com/Sea-Haven-Industries/open-swe.git
synced 2026-10-04 12:32:12 +00:00
fix: Pull branch if push errors (#534)
This commit is contained in:
parent
3ec90ef6e6
commit
2d17904153
1 changed files with 24 additions and 6 deletions
|
|
@ -128,16 +128,34 @@ export async function checkoutBranchAndCommit(
|
||||||
);
|
);
|
||||||
|
|
||||||
if (pushRes instanceof Error) {
|
if (pushRes instanceof Error) {
|
||||||
|
logger.info("Failed to push changes, attempting to pull and push again");
|
||||||
|
// attempt to git pull, then push again
|
||||||
|
await sandbox.git.pull(
|
||||||
|
absoluteRepoDir,
|
||||||
|
"git",
|
||||||
|
options.githubInstallationToken,
|
||||||
|
);
|
||||||
|
logger.info("Successfully pulled changes. Pushing again.");
|
||||||
|
const pushRes2 = await withRetry(
|
||||||
|
async () => {
|
||||||
|
return await sandbox.git.push(
|
||||||
|
absoluteRepoDir,
|
||||||
|
"git",
|
||||||
|
options.githubInstallationToken,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
{ retries: 3, delay: 0 },
|
||||||
|
);
|
||||||
const gitStatus = await sandbox.git.status(absoluteRepoDir);
|
const gitStatus = await sandbox.git.status(absoluteRepoDir);
|
||||||
const errorFields = {
|
const errorFields = {
|
||||||
...(pushRes instanceof Error
|
...(pushRes2 instanceof Error
|
||||||
? {
|
? {
|
||||||
name: pushRes.name,
|
name: pushRes2.name,
|
||||||
message: pushRes.message,
|
message: pushRes2.message,
|
||||||
stack: pushRes.stack,
|
stack: pushRes2.stack,
|
||||||
cause: pushRes.cause,
|
cause: pushRes2.cause,
|
||||||
}
|
}
|
||||||
: pushRes),
|
: pushRes2),
|
||||||
};
|
};
|
||||||
logger.error("Failed to push changes", {
|
logger.error("Failed to push changes", {
|
||||||
...errorFields,
|
...errorFields,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue