From a94e3dbb6694ef5d36c792619815edda496da9fe Mon Sep 17 00:00:00 2001 From: pyr0ball Date: Mon, 18 May 2026 16:55:06 -0700 Subject: [PATCH] fix(distro): handle single-quoted IDs, add mint, run cargo fmt - parse_id now strips both double and single quotes per os-release spec - distro_family debian arm includes "mint" (legacy Linux Mint ID) - Add tests: single-quoted ID round-trip, mint family classification --- src-tauri/src/distro.rs | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src-tauri/src/distro.rs b/src-tauri/src/distro.rs index 3a92c35..0156d87 100644 --- a/src-tauri/src/distro.rs +++ b/src-tauri/src/distro.rs @@ -7,9 +7,7 @@ pub fn detect() -> String { pub fn distro_family(id: &str) -> &'static str { match id { "arch" | "cachyos" | "endeavouros" | "manjaro" | "garuda" => "arch", - "debian" | "ubuntu" | "linuxmint" | "pop" | "elementary" | "kali" => { - "debian" - } + "debian" | "ubuntu" | "linuxmint" | "mint" | "pop" | "elementary" | "kali" => "debian", "fedora" | "rhel" | "centos" | "rocky" | "alma" => "fedora", "opensuse" | "opensuse-tumbleweed" | "opensuse-leap" => "opensuse", _ => "unknown", @@ -22,7 +20,13 @@ fn parse_id(content: &str) -> String { .find_map(|line| { let (key, val) = line.split_once('=')?; if key.trim() == "ID" { - Some(val.trim().trim_matches('"').to_lowercase()) + let raw = val.trim(); + let unquoted = raw + .strip_prefix('"') + .and_then(|s| s.strip_suffix('"')) + .or_else(|| raw.strip_prefix('\'').and_then(|s| s.strip_suffix('\''))) + .unwrap_or(raw); + Some(unquoted.to_lowercase()) } else { None } @@ -70,4 +74,15 @@ mod tests { fn distro_family_unknown() { assert_eq!(distro_family("slackware"), "unknown"); } + + #[test] + fn parses_single_quoted_id() { + let content = "ID='arch'\nPRETTY_NAME='Arch Linux'\n"; + assert_eq!(parse_id(content), "arch"); + } + + #[test] + fn distro_family_mint_legacy() { + assert_eq!(distro_family("mint"), "debian"); + } }