handle http error when pushing/pulling project

This commit is contained in:
Nikita Galaiko 2023-12-15 15:37:28 +01:00 committed by GitButler
parent 2b1c7d21c1
commit 1cb49179d2
2 changed files with 7 additions and 4 deletions

View File

@ -16,6 +16,8 @@ pub enum Error {
Network(git2::Error),
#[error("hook error: {0}")]
Hooks(#[from] git2_hooks::HooksError),
#[error("http error: {0}")]
Http(git2::Error),
#[error(transparent)]
Other(git2::Error),
}
@ -27,6 +29,7 @@ impl From<git2::Error> for Error {
git2::ErrorCode::GenericError | git2::ErrorCode::Auth => Error::Auth(err),
_ => Error::Other(err),
},
git2::ErrorClass::Http => Error::Http(err),
git2::ErrorClass::Net => Error::Network(err),
_ => match err.code() {
git2::ErrorCode::NotFound => Error::NotFound(err),

View File

@ -370,12 +370,12 @@ impl Repository {
);
return Ok(());
}
Err(git::Error::Auth(error)) => {
tracing::warn!(project_id = %self.project.id, ?error, "git push failed",);
Err(git::Error::Auth(error) | git::Error::Http(error)) => {
tracing::warn!(project_id = %self.project.id, ?error, "git push failed");
continue;
}
Err(git::Error::Network(error)) => {
tracing::warn!(project_id = %self.project.id, ?error, "git push failed",);
tracing::warn!(project_id = %self.project.id, ?error, "git push failed");
return Err(RemoteError::Network);
}
Err(error) => return Err(RemoteError::Other(error.into())),
@ -407,7 +407,7 @@ impl Repository {
tracing::info!(project_id = %self.project.id, %refspec, "git fetched");
return Ok(());
}
Err(git::Error::Auth(error)) => {
Err(git::Error::Auth(error) | git::Error::Http(error)) => {
tracing::warn!(project_id = %self.project.id, ?error, "fetch failed");
continue;
}