Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: java core plugin reports wrong latest version #2798

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/plugins/core/java.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,11 +385,17 @@ impl Backend for JavaPlugin {
}

fn fuzzy_match_filter(&self, versions: Vec<String>, query: &str) -> eyre::Result<Vec<String>> {
let escaped_query = regex::escape(query.trim_end_matches('-'));
let query = if query == "latest" {
"[0-9].*"
} else {
&escaped_query
let query_trim = regex::escape(query.trim_end_matches('-'));
let query_version = format!("{}[0-9.]+", regex::escape(query));
let query_trim_version = format!("{}-[0-9.]+", query_trim);
let query = match query {
"latest" => "[0-9].*",
// ends with a dash; use <query><version>
q if q.ends_with('-') => &query_version,
// not a shorthand version; use <query>-<version>
q if regex!("^[a-zA-Z]+$").is_match(q) => &query_trim_version,
// else; use trimmed query
_ => &query_trim,
};
let query_regex = Regex::new(&format!("^{}([+-.].+)?$", query))?;
let versions = versions
Expand Down
2 changes: 1 addition & 1 deletion src/toolset/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ impl Toolset {
return None;
}
// prefix is something like "temurin-" or "corretto-"
let prefix = regex!(r"^[a-zA-Z]+-")
let prefix = regex!(r"^[a-zA-Z-]+-")
.find(&tv.request.version())
.map(|m| m.as_str().to_string());
let latest_result = if bump {
Expand Down
Loading