Skip to content

Commit b383a18

Browse files
Do not load missing commits if github token doesn't exist
If running locally, generally you don't expect to benchmark missing commits, rather just display data, and shouldn't require a github token.
1 parent 4425072 commit b383a18

File tree

1 file changed

+27
-12
lines changed

1 file changed

+27
-12
lines changed

site/src/load.rs

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ use std::sync::Arc;
1616
use anyhow::Context;
1717
use chrono::{Duration, Utc};
1818
use parking_lot::Mutex;
19-
use serde::{Deserialize, Serialize};
2019
use reqwest::Client;
20+
use serde::{Deserialize, Serialize};
2121

2222
use crate::git;
2323
use crate::util;
@@ -479,7 +479,9 @@ impl InputData {
479479

480480
let persistent = Persistent::load();
481481
Ok(InputData {
482-
missing_commits: Self::missing_commits(&data, &config, &persistent).await.unwrap(),
482+
missing_commits: Self::missing_commits(&data, &config, &persistent)
483+
.await
484+
.unwrap(),
483485
stats_list: stats_list.into_iter().collect(),
484486
interpolated,
485487
last_date: last_date,
@@ -496,11 +498,18 @@ impl InputData {
496498
config: &Config,
497499
persistent: &Persistent,
498500
) -> anyhow::Result<Vec<(Commit, MissingReason)>> {
501+
let github_token = match config.keys.github.as_deref() {
502+
Some(token) => token,
503+
None => {
504+
println!("Skipping collection of missing commits, no github token configured");
505+
return Ok(Vec::new());
506+
}
507+
};
499508
println!("Updating rust.git clone...");
500-
let commits = rustc_artifacts::master_commits(
501-
&Client::new(),
502-
Some(config.keys.github.as_deref().expect("needs rust-timer token")),
503-
).await.map_err(|e| anyhow::anyhow!("{:?}", e)).context("getting master commit list")?;
509+
let commits = rustc_artifacts::master_commits(&Client::new(), Some(github_token))
510+
.await
511+
.map_err(|e| anyhow::anyhow!("{:?}", e))
512+
.context("getting master commit list")?;
504513
println!("Update of rust.git complete");
505514

506515
let have = data
@@ -568,12 +577,18 @@ impl InputData {
568577
}
569578
}
570579

571-
Ok(commits.into_iter().map(|(c, mr)| {
572-
(Commit {
573-
sha: c.sha.as_str().into(),
574-
date: Date(c.date),
575-
}, mr)
576-
}).collect())
580+
Ok(commits
581+
.into_iter()
582+
.map(|(c, mr)| {
583+
(
584+
Commit {
585+
sha: c.sha.as_str().into(),
586+
date: Date(c.date),
587+
},
588+
mr,
589+
)
590+
})
591+
.collect())
577592
}
578593
}
579594

0 commit comments

Comments
 (0)