Skip to content

Commit 2370f97

Browse files
committed
More docs
1 parent 368af5b commit 2370f97

File tree

2 files changed

+25
-11
lines changed

2 files changed

+25
-11
lines changed

collector/src/lib.rs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,33 @@ pub use self_profile::{QueryData, SelfProfile};
1515
#[derive(Debug, Copy, Clone, PartialEq, PartialOrd, Deserialize)]
1616
pub struct DeltaTime(#[serde(with = "round_float")] pub f64);
1717

18+
/// The bound of a range changes in codebase
19+
///
20+
/// This can either be the upper or lower bound
1821
#[derive(Debug, Clone, PartialEq, Eq)]
1922
pub enum Bound {
20-
// sha, unverified
23+
/// An unverified git commit (in sha form)
2124
Commit(String),
25+
/// A date in time
2226
Date(NaiveDate),
27+
/// No bound
2328
None,
2429
}
2530

2631
impl Bound {
32+
/// Tests whether self bounds the commit to the left
2733
pub fn left_match(&self, commit: &Commit) -> bool {
28-
let last_month = chrono::Utc::now().date().naive_utc() - chrono::Duration::days(30);
2934
match self {
3035
Bound::Commit(sha) => commit.sha == **sha,
3136
Bound::Date(date) => commit.date.0.naive_utc().date() >= *date,
32-
Bound::None => last_month <= commit.date.0.naive_utc().date(),
37+
Bound::None => {
38+
let last_month = chrono::Utc::now().date().naive_utc() - chrono::Duration::days(30);
39+
last_month <= commit.date.0.naive_utc().date()
40+
}
3341
}
3442
}
3543

44+
/// Tests whether self bounds the commit to the right
3645
pub fn right_match(&self, commit: &Commit) -> bool {
3746
match self {
3847
Bound::Commit(sha) => commit.sha == **sha,
@@ -148,7 +157,7 @@ pub fn run_command(cmd: &mut Command) -> anyhow::Result<()> {
148157
pub fn robocopy(
149158
from: &std::path::Path,
150159
to: &std::path::Path,
151-
extra_args: &[&dyn AsRef<std::ffi::OsStr>]
160+
extra_args: &[&dyn AsRef<std::ffi::OsStr>],
152161
) -> anyhow::Result<()> {
153162
let mut cmd = Command::new("robocopy");
154163
cmd.arg(from).arg(to).arg("/s").arg("/e");
@@ -219,7 +228,7 @@ pub fn command_output(cmd: &mut Command) -> anyhow::Result<process::Output> {
219228
output.status,
220229
String::from_utf8_lossy(&output.stderr),
221230
String::from_utf8_lossy(&output.stdout)
222-
));
231+
));
223232
}
224233

225234
Ok(output)
@@ -246,7 +255,8 @@ pub struct MasterCommit {
246255
/// Note that this does not contain try commits today, so it should not be used
247256
/// to validate hashes or expand them generally speaking. This may also change
248257
/// in the future.
249-
pub async fn master_commits() -> Result<Vec<MasterCommit>, Box<dyn std::error::Error + Sync + Send>> {
258+
pub async fn master_commits() -> Result<Vec<MasterCommit>, Box<dyn std::error::Error + Sync + Send>>
259+
{
250260
let response = reqwest::get("https://triage.rust-lang.org/bors-commit-list").await?;
251261
Ok(response.json().await?)
252-
}
262+
}

site/src/selector.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,26 @@ use std::fmt;
3333
use std::ops::RangeInclusive;
3434
use std::sync::Arc;
3535

36-
pub fn data_for(data: &Index, is_left: bool, query: Bound) -> Option<ArtifactId> {
36+
/// Gets an artifact id for the given bound
37+
///
38+
/// Searches in the indexed commits either from the right or left
39+
/// If not found in the indexed commits, searches through the artifacts cache
40+
pub fn data_for(data: &Index, is_left: bool, bound: Bound) -> Option<ArtifactId> {
3741
let commits = data.commits();
3842
let commit = if is_left {
3943
commits
4044
.iter()
41-
.find(|commit| query.left_match(commit))
45+
.find(|commit| bound.left_match(commit))
4246
.cloned()
4347
} else {
4448
commits
4549
.iter()
46-
.rfind(|commit| query.left_match(commit))
50+
.rfind(|commit| bound.left_match(commit))
4751
.cloned()
4852
};
4953
commit.map(|c| ArtifactId::Commit(c)).or_else(|| {
5054
data.artifacts()
51-
.find(|aid| match &query {
55+
.find(|aid| match &bound {
5256
Bound::Commit(c) => *c == **aid,
5357
Bound::Date(_) => false,
5458
Bound::None => false,

0 commit comments

Comments
 (0)