Abstract BuildStatus -> String

This commit is contained in:
Graham Christensen 2019-01-24 14:28:20 -05:00
parent e7e6d7314a
commit 6e20832e95
No known key found for this signature in database
GPG key ID: ACA1C1D120C83D5C
2 changed files with 13 additions and 7 deletions

View file

@ -9,6 +9,18 @@ pub enum BuildStatus {
UnexpectedError { err: String },
}
impl From<BuildStatus> for String {
fn from(status: BuildStatus) -> String {
match status {
BuildStatus::Skipped => "No attempt".into(),
BuildStatus::Success => "Success".into(),
BuildStatus::Failure => "Failure".into(),
BuildStatus::TimedOut => "Timed out, unknown build status".into(),
BuildStatus::UnexpectedError { ref err } => format!("Unexpected error: {}", err),
}
}
}
pub struct LegacyBuildResult {
pub repo: Repo,
pub pr: Pr,

View file

@ -166,13 +166,7 @@ fn result_to_comment(result: &LegacyBuildResult) -> String {
reply.push(format!("<!--REQUEST_ID={}-->", result.request_id));
reply.push(format!(
"{} on {}{}",
(match result.status {
BuildStatus::Skipped => "No attempt".into(),
BuildStatus::Success => "Success".into(),
BuildStatus::Failure => "Failure".into(),
BuildStatus::TimedOut => "Timed out, unknown build status".into(),
BuildStatus::UnexpectedError { ref err } => format!("Unexpected error: {}", err),
}),
String::from(result.status.clone()),
result.system,
log_link
));