Skip to content

Commit

Permalink
fix: only show actual cargo-binstall versions (#2936)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx authored Nov 5, 2024
1 parent d145c91 commit e13543a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion registry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
14 changes: 12 additions & 2 deletions src/backend/ubi.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::fmt::Debug;

use crate::backend::{Backend, BackendType};
use crate::cache::{CacheManager, CacheManagerBuilder};
use crate::cli::args::BackendArg;
Expand All @@ -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;

Expand Down Expand Up @@ -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)
Expand All @@ -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())
})
Expand Down

0 comments on commit e13543a

Please sign in to comment.