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 }, 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 struct LegacyBuildResult {
pub repo: Repo, pub repo: Repo,
pub pr: Pr, 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!("<!--REQUEST_ID={}-->", result.request_id));
reply.push(format!( reply.push(format!(
"{} on {}{}", "{} on {}{}",
(match result.status { String::from(result.status.clone()),
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),
}),
result.system, result.system,
log_link log_link
)); ));