#[must_use]
pub fn is_name_manjaro(name: &str) -> bool {
name.to_lowercase().starts_with("manjaro-")
}
#[must_use]
pub fn is_manjaro_name_or_owner(name: &str, owner: &str) -> bool {
let name_l = name.to_lowercase();
let owner_l = owner.to_lowercase();
name_l.starts_with("manjaro-") || owner_l.contains("manjaro")
}
#[must_use]
pub fn is_eos_repo(repo: &str) -> bool {
let r = repo.to_lowercase();
r == "eos" || r == "endeavouros"
}
#[must_use]
pub fn is_cachyos_repo(repo: &str) -> bool {
let r = repo.to_lowercase();
r.starts_with("cachyos")
}
#[must_use]
pub fn is_artix_repo(repo: &str) -> bool {
let r = repo.to_lowercase();
matches!(
r.as_str(),
"omniverse" | "universe" | "lib32" | "galaxy" | "world" | "system"
)
}
#[must_use]
pub const fn is_artix_omniverse(repo: &str) -> bool {
repo.eq_ignore_ascii_case("omniverse")
}
#[must_use]
pub const fn is_artix_universe(repo: &str) -> bool {
repo.eq_ignore_ascii_case("universe")
}
#[must_use]
pub const fn is_artix_lib32(repo: &str) -> bool {
repo.eq_ignore_ascii_case("lib32")
}
#[must_use]
pub const fn is_artix_galaxy(repo: &str) -> bool {
repo.eq_ignore_ascii_case("galaxy")
}
#[must_use]
pub const fn is_artix_world(repo: &str) -> bool {
repo.eq_ignore_ascii_case("world")
}
#[must_use]
pub const fn is_artix_system(repo: &str) -> bool {
repo.eq_ignore_ascii_case("system")
}
#[cfg(not(target_os = "windows"))]
pub const fn eos_repo_names() -> &'static [&'static str] {
&["endeavouros"]
}
#[cfg(not(target_os = "windows"))]
pub const fn cachyos_repo_names() -> &'static [&'static str] {
&[
"cachyos",
"cachyos-core",
"cachyos-extra",
"cachyos-v3",
"cachyos-core-v3",
"cachyos-extra-v3",
"cachyos-v4",
"cachyos-core-v4",
"cachyos-extra-v4",
]
}
#[cfg(not(target_os = "windows"))]
pub const fn artix_repo_names() -> &'static [&'static str] {
&[
"omniverse",
"universe",
"lib32",
"galaxy",
"world",
"system",
]
}
#[must_use]
pub const fn is_blackarch_repo(repo: &str) -> bool {
repo.eq_ignore_ascii_case("blackarch")
}
#[cfg(not(target_os = "windows"))]
pub const fn blackarch_repo_names() -> &'static [&'static str] {
&["blackarch"]
}
#[must_use]
pub fn is_eos_name(name: &str) -> bool {
name.to_lowercase().contains("eos-")
}
#[cfg(test)]
mod tests {
#[test]
fn manjaro_name_detection() {
assert!(super::is_name_manjaro("manjaro-alsa"));
assert!(super::is_name_manjaro("Manjaro-foo"));
assert!(!super::is_name_manjaro("alsa"));
}
#[test]
fn manjaro_name_or_owner_detection() {
assert!(super::is_manjaro_name_or_owner("manjaro-alsa", ""));
assert!(super::is_manjaro_name_or_owner("alsa", "Manjaro Team"));
assert!(!super::is_manjaro_name_or_owner("alsa", "Arch Linux"));
}
#[test]
fn eos_and_cachyos_repo_rules() {
assert!(super::is_eos_repo("eos"));
assert!(super::is_eos_repo("EndeavourOS"));
assert!(!super::is_eos_repo("core"));
assert!(super::is_cachyos_repo("cachyos-core"));
assert!(super::is_cachyos_repo("CachyOS-extra"));
assert!(!super::is_cachyos_repo("extra"));
}
#[test]
fn eos_name_rule() {
assert!(super::is_eos_name("eos-hello"));
assert!(super::is_eos_name("my-eos-helper"));
assert!(!super::is_eos_name("hello"));
}
#[test]
fn blackarch_repo_rules() {
assert!(super::is_blackarch_repo("blackarch"));
assert!(super::is_blackarch_repo("BlackArch"));
assert!(super::is_blackarch_repo("BLACKARCH"));
assert!(!super::is_blackarch_repo("blackarch-extra"));
assert!(!super::is_blackarch_repo("core"));
assert!(!super::is_blackarch_repo("cachyos"));
assert!(!super::is_blackarch_repo("eos"));
}
#[test]
fn artix_repo_rules() {
assert!(super::is_artix_repo("omniverse"));
assert!(super::is_artix_repo("Omniverse"));
assert!(super::is_artix_repo("universe"));
assert!(super::is_artix_repo("lib32"));
assert!(super::is_artix_repo("galaxy"));
assert!(super::is_artix_repo("world"));
assert!(super::is_artix_repo("system"));
assert!(!super::is_artix_repo("core"));
assert!(!super::is_artix_repo("extra"));
assert!(!super::is_artix_repo("cachyos"));
}
}