Skip to content

Commit

Permalink
src/repology.rs: make version field optional
Browse files Browse the repository at this point in the history
Today the diff strated failing on the following entry:

    Repology { repo: "aur", visiblename: Some("hyprland-git"), version: None, status: "rolling" }
  • Loading branch information
trofi committed Jun 27, 2024
1 parent bfff60a commit 38f2c80
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/repology.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ pub(crate) struct Package {
/// nixpkgs 'pname' from available packages
pub(crate) name: String,

version: String,
version: Option<String>,
/// repology's characterization of the state: outdated, dev-only, etc.
status: String,
status: Option<String>,

/// latest version available in some other repository
/// Might not exist if latest version was added and then
Expand Down Expand Up @@ -68,8 +68,8 @@ pub(crate) fn get_packages(
struct Repology {
repo: String,
visiblename: Option<String>,
version: String,
status: String,
version: Option<String>,
status: Option<String>,
}

let pkgs: BTreeMap<String, Vec<Repology>> = serde_json::from_slice(contents_u8.as_slice())?;
Expand All @@ -79,13 +79,19 @@ pub(crate) fn get_packages(
next_suffix = n.clone() + "/";

let olatest_entry = vs.iter().find_map(|e| {
if e.status == "newest" || e.status == "unique" {
if e.status == Some("newest".to_string()) || e.status == Some("unique".to_string()) {
Some(e)
} else {
None
}
});
let latest = olatest_entry.map(|e| e.version.clone());
let latest = match olatest_entry {
None => None,
Some (oe) => match &oe.version {
None => None,
Some(v) => Some(v.clone()),
},
};

// There can be multiple nix_unstable package entries for a
// single repology entry: pycropto vs pycryptodome.
Expand Down

0 comments on commit 38f2c80

Please sign in to comment.