Skip to content

Commit d14df26

Browse files
committed
Make parent in download_auto_job_metrics optional
1 parent 94015d3 commit d14df26

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

src/ci/citool/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ fn postprocess_metrics(
180180
}
181181

182182
fn post_merge_report(db: JobDatabase, current: String, parent: String) -> anyhow::Result<()> {
183-
let metrics = download_auto_job_metrics(&db, &parent, &current)?;
183+
let metrics = download_auto_job_metrics(&db, Some(&parent), &current)?;
184184

185185
println!("\nComparing {parent} (parent) -> {current} (this PR)\n");
186186

src/ci/citool/src/metrics.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,24 +46,25 @@ pub struct JobMetrics {
4646
/// `parent` and `current` should be commit SHAs.
4747
pub fn download_auto_job_metrics(
4848
job_db: &JobDatabase,
49-
parent: &str,
49+
parent: Option<&str>,
5050
current: &str,
5151
) -> anyhow::Result<HashMap<JobName, JobMetrics>> {
5252
let mut jobs = HashMap::default();
5353

5454
for job in &job_db.auto_jobs {
5555
eprintln!("Downloading metrics of job {}", job.name);
56-
let metrics_parent = match download_job_metrics(&job.name, parent) {
57-
Ok(metrics) => Some(metrics),
58-
Err(error) => {
59-
eprintln!(
60-
r#"Did not find metrics for job `{}` at `{parent}`: {error:?}.
56+
let metrics_parent =
57+
parent.and_then(|parent| match download_job_metrics(&job.name, parent) {
58+
Ok(metrics) => Some(metrics),
59+
Err(error) => {
60+
eprintln!(
61+
r#"Did not find metrics for job `{}` at `{parent}`: {error:?}.
6162
Maybe it was newly added?"#,
62-
job.name
63-
);
64-
None
65-
}
66-
};
63+
job.name
64+
);
65+
None
66+
}
67+
});
6768
let metrics_current = download_job_metrics(&job.name, current)?;
6869
jobs.insert(
6970
job.name.clone(),

0 commit comments

Comments
 (0)