|
|
@ -16,7 +16,7 @@ use super::VersionInfo;
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Serialize, Deserialize)]
|
|
|
|
#[derive(Clone, Serialize, Deserialize)]
|
|
|
|
pub struct Versions {
|
|
|
|
pub struct Versions {
|
|
|
|
lts_versions: HashMap<String, u16>,
|
|
|
|
lts_versions: HashMap<String, u8>,
|
|
|
|
versions: HashMap<SimpleVersion, VersionMetadata>,
|
|
|
|
versions: HashMap<SimpleVersion, VersionMetadata>,
|
|
|
|
// as this field is not serialized
|
|
|
|
// as this field is not serialized
|
|
|
|
// it needs to be calculated after serialization
|
|
|
|
// it needs to be calculated after serialization
|
|
|
@ -53,7 +53,7 @@ impl Versions {
|
|
|
|
pub fn new(all_versions: Vec<VersionInfo>) -> Self {
|
|
|
|
pub fn new(all_versions: Vec<VersionInfo>) -> Self {
|
|
|
|
let lts_versions = all_versions
|
|
|
|
let lts_versions = all_versions
|
|
|
|
.iter()
|
|
|
|
.iter()
|
|
|
|
.filter_map(|v| Some((v.lts.lts_ref()?.to_lowercase(), v.version.major as u16)))
|
|
|
|
.filter_map(|v| Some((v.lts.lts_ref()?.to_lowercase(), v.version.major as u8)))
|
|
|
|
.collect::<HashMap<_, _>>();
|
|
|
|
.collect::<HashMap<_, _>>();
|
|
|
|
let mut sorted_versions = all_versions
|
|
|
|
let mut sorted_versions = all_versions
|
|
|
|
.iter()
|
|
|
|
.iter()
|
|
|
@ -133,7 +133,7 @@ impl Versions {
|
|
|
|
|
|
|
|
|
|
|
|
/// Returns any version that fulfills the given requirement
|
|
|
|
/// Returns any version that fulfills the given requirement
|
|
|
|
#[tracing::instrument(level = "debug", skip(self))]
|
|
|
|
#[tracing::instrument(level = "debug", skip(self))]
|
|
|
|
fn get_latest_for_major(&self, major: u16) -> Option<&VersionMetadata> {
|
|
|
|
fn get_latest_for_major(&self, major: u8) -> Option<&VersionMetadata> {
|
|
|
|
let fulfilling_versions = self
|
|
|
|
let fulfilling_versions = self
|
|
|
|
.sorted_versions
|
|
|
|
.sorted_versions
|
|
|
|
.iter()
|
|
|
|
.iter()
|
|
|
|