diff --git a/registry.toml b/registry.toml index 5f0d40e79..5f9fdee7f 100644 --- a/registry.toml +++ b/registry.toml @@ -92,7 +92,7 @@ caddy = ["asdf:salasrod/asdf-caddy"] calendarsync = ["asdf:FeryET/asdf-calendarsync"] calicoctl = ["asdf:TheCubicleJockey/asdf-calicoctl"] camunda-modeler = ["asdf:barmac/asdf-camunda-modeler"] -cargo-binstall = ["ubi:cargo-bins/cargo-binstall", "cargo:cargo-binstall"] +cargo-binstall = ['ubi:cargo-bins/cargo-binstall[tag_regex=^\\d\\.]', "cargo:cargo-binstall"] cargo-insta = ["ubi:mitsuhiko/insta"] cargo-make = ["asdf:mise-plugins/asdf-cargo-make"] carp = ["asdf:susurri/asdf-carp"] diff --git a/src/backend/ubi.rs b/src/backend/ubi.rs index ded9c1bb7..3fde100d2 100644 --- a/src/backend/ubi.rs +++ b/src/backend/ubi.rs @@ -1,5 +1,3 @@ -use std::fmt::Debug; - use crate::backend::{Backend, BackendType}; use crate::cache::{CacheManager, CacheManagerBuilder}; use crate::cli::args::BackendArg; @@ -11,6 +9,8 @@ use crate::plugins::VERSION_REGEX; use crate::toolset::ToolRequest; use eyre::bail; use regex::Regex; +use std::fmt::Debug; +use std::sync::OnceLock; use ubi::UbiBuilder; use xx::regex; @@ -40,6 +40,8 @@ impl Backend for UbiBackend { } else { self.remote_version_cache .get_or_try_init(|| { + let opts = self.ba.opts.clone().unwrap_or_default(); + let tag_regex = OnceLock::new(); Ok(github::list_releases(self.name())? .into_iter() .map(|r| r.tag_name) @@ -48,6 +50,14 @@ impl Backend for UbiBackend { true => t[1..].to_string(), false => t, }) + .filter(|v| { + if let Some(re) = opts.get("tag_regex") { + let re = tag_regex.get_or_init(|| Regex::new(re).unwrap()); + re.is_match(v) + } else { + true + } + }) .rev() .collect()) })