Skip to content

Commit

Permalink
fix: installing jq via new built-in ubi fails (#2771)
Browse files Browse the repository at this point in the history
  • Loading branch information
roele authored Oct 22, 2024
1 parent bd9e881 commit 947b8f1
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/backend/ubi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ use crate::cli::args::BackendArg;
use crate::config::SETTINGS;
use crate::env::GITHUB_TOKEN;
use crate::install_context::InstallContext;
use crate::plugins::VERSION_REGEX;
use crate::toolset::ToolRequest;
use crate::{github, http};
use eyre::eyre;
use regex::Regex;
use ubi::UbiBuilder;
use xx::regex;

Expand Down Expand Up @@ -94,6 +96,29 @@ impl Backend for UbiBackend {
.build()?;
rt.block_on(u.install_binary()).map_err(|e| eyre!(e))
}

fn fuzzy_match_filter(&self, versions: Vec<String>, query: &str) -> eyre::Result<Vec<String>> {
let escaped_query = regex::escape(query);
let query = if query == "latest" {
"\\D*[0-9].*"
} else {
&escaped_query
};
let query_regex = Regex::new(&format!("^{}([-.].+)?$", query))?;
let versions = versions
.into_iter()
.filter(|v| {
if query == v {
return true;
}
if VERSION_REGEX.is_match(v) {
return false;
}
query_regex.is_match(v)
})
.collect();
Ok(versions)
}
}

impl UbiBackend {
Expand Down

0 comments on commit 947b8f1

Please sign in to comment.