Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion src/dist/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,9 +464,16 @@ impl ToolchainDesc {
}
}

/// Toolchain channels are considered 'tracking' if it is one of the named channels
/// such as `stable`, or is an incomplete version such as `1.48`, and the
/// date field is empty.
pub fn is_tracking(&self) -> bool {
let channels = ["nightly", "beta", "stable"];
channels.iter().any(|x| *x == self.channel) && self.date.is_none()
lazy_static! {
static ref TRACKING_VERSION: Regex = Regex::new(r"^\d{1}\.\d{1,3}$").unwrap();
}
(channels.iter().any(|x| *x == self.channel) || TRACKING_VERSION.is_match(&self.channel))
&& self.date.is_none()
}
}

Expand Down Expand Up @@ -1079,4 +1086,22 @@ mod tests {
);
}
}

#[test]
fn test_tracking_channels() {
static CASES: &[(&str, bool)] = &[
("stable", true),
("beta", true),
("nightly", true),
("nightly-2020-10-04", false),
("1.48", true),
("1.47.0", false),
];
for case in CASES {
let full_tcn = format!("{}-x86_64-unknown-linux-gnu", case.0);
let tcd = ToolchainDesc::from_str(&full_tcn).unwrap();
eprintln!("Considering {}", case.0);
assert_eq!(tcd.is_tracking(), case.1);
}
}
}