Fix clean function not stripping the package version

Signed-off-by: Trivernis <trivernis@protonmail.com>
i18n
Trivernis 2 years ago
parent 813c06d31d
commit 362c2cf6ea

@ -3,18 +3,13 @@ use regex::Regex;
/// Strips packages from versioning and other extraneous information.
pub fn clean(a: &[String]) -> Vec<String> {
// Strip versioning from package names
let r = Regex::new(r"(\S+)((?:>=|<=|>|<|=\W)\S+$)").unwrap();
let mut cleaned: Vec<String> = vec![];
// Push cleaned package names to vector
for b in a {
if r.captures_iter(b).count() > 0 {
let c = r.captures(b).unwrap().get(1).map_or("", |m| m.as_str());
cleaned.push(c.to_string());
} else {
cleaned.push(b.to_string());
}
}
let cleaned = a.iter()
.map(|name|
name
.split_once("=")
.map(|n| n.0.to_string())
.unwrap_or(name.to_string()))
.collect();
tracing::debug!("Cleaned: {:?}\nInto: {:?}", a, cleaned);

@ -6,7 +6,7 @@ use std::{
use futures::future;
use tokio::fs;
#[tracing::instrument(level = "debug")]
#[tracing::instrument(level = "trace")]
pub async fn rmdir_recursive(path: &Path) -> std::io::Result<()> {
let mut files: Vec<PathBuf> = Vec::new();
let mut folders: Vec<PathBuf> = Vec::new();

Loading…
Cancel
Save