Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: git push force to github on second retry #1313

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 22 additions & 20 deletions src/services/db/GitFileSystemService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -750,28 +750,30 @@ export default class GitFileSystemService {
.orElse(() =>
// Retry push twice
// TODO: To eliminate duplicate code by using a backoff or retry package
ResultAsync.fromPromise(
isForce
? this.git
.cwd({ path: `${efsVolPath}/${repoName}`, root: false })
.push([...gitOptions, "--force"])
: this.git
.cwd({ path: `${efsVolPath}/${repoName}`, root: false })
.push(gitOptions),
(error) => {
logger.error(
`Both retries for git push have failed. Error when pushing ${repoName}: ${error}`
)

if (error instanceof GitError) {
return new GitFileSystemError(
"Unable to push latest changes of repo"
// As a last resort, we do a force push to GitHub as EFS is the source of truth
{
logger.info(
`Performing a force push to GitHub as earlier retries have failed for ${repoName}`
)
harishv7 marked this conversation as resolved.
Show resolved Hide resolved
return ResultAsync.fromPromise(
this.git
.cwd({ path: `${efsVolPath}/${repoName}`, root: false })
.push([...gitOptions, "--force"]),
(error) => {
logger.error(
`Both retries for git push have failed. Error when pushing ${repoName}: ${error}`
)
}

return new GitFileSystemError("An unknown error occurred")
}
)
if (error instanceof GitError) {
return new GitFileSystemError(
"Unable to push latest changes of repo"
)
}

return new GitFileSystemError("An unknown error occurred")
}
)
}
)
.map(() => `${efsVolPath}/${repoName}`)
})
Expand Down
Loading