Skip to content
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
13 changes: 13 additions & 0 deletions e2e/core/test_v_prefix_bump_query
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

# Regression test for aqua-backed tools pinned with a leading v prefix.
# `mise upgrade --bump` used to derive the fuzzy latest query `v3` from
# `v3.12.0`, but aqua normalizes shfmt releases to bare versions like 3.13.1.
# That mismatch triggered: "no latest version found".
cat <<'TOML' >mise.toml
[tools]
shfmt = "v3.12.0"
TOML

assert_not_contains "mise upgrade shfmt --bump --dry-run 2>&1" "no latest version found"
Comment thread
greptile-apps[bot] marked this conversation as resolved.
assert_contains "mise upgrade shfmt --bump --dry-run 2>&1" "Would bump shfmt@v3.13.1 in ~/workdir/mise.toml"
29 changes: 26 additions & 3 deletions src/toolset/outdated_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ impl OutdatedInfo {
}
if bump {
let old = oi.tool_version.request.version();
let old = old.strip_prefix(&prefix).unwrap_or_default();
let new = oi.latest.strip_prefix(&prefix).unwrap_or_default();
let old = old.strip_prefix(&prefix).unwrap_or(old.as_str());
let new = oi.latest.strip_prefix(&prefix).unwrap_or(&oi.latest);
if let Some(bumped_version) = check_semver_bump(old, new)
&& bumped_version != oi.tool_version.request.version()
{
Expand Down Expand Up @@ -216,7 +216,14 @@ impl Display for OutdatedInfo {

fn prefixed_latest_query(prefix: &str, prefix_version: &str) -> Option<String> {
let prefix = prefix.trim();
if prefix.is_empty() || prefix_version.is_empty() || prefix.contains(':') {
if prefix.is_empty()
|| prefix_version.is_empty()
|| prefix.contains(':')
// A lone leading v/V is version syntax, not a backend/vendor prefix.
// Treat it as unprefixed so backends with normalized bare versions like
// 3.13.1 still resolve their latest release during --bump.
|| matches!(prefix, "v" | "V")
{
return None;
}

Expand Down Expand Up @@ -504,10 +511,26 @@ mod tests {
Some("corretto-2024".to_string())
);
assert_eq!(prefixed_latest_query("prefix:1.", "24"), None);
assert_eq!(prefixed_latest_query("v", "3.13.1"), None);
assert_eq!(prefixed_latest_query("V", "3.13.1"), None);
assert_eq!(prefixed_latest_query("", "17.0.7"), None);
assert_eq!(prefixed_latest_query("temurin-", ""), None);
}

#[test]
fn test_v_prefix_bump_preserves_bare_latest_version() {
let prefix = "v";
let old = "v3.12.0";
let latest = "3.13.1";

let old = old.strip_prefix(prefix).unwrap_or(old);
let new = latest.strip_prefix(prefix).unwrap_or(latest);
let bumped = check_semver_bump(old, new).unwrap();

assert_eq!(bumped, "3.13.1");
assert_eq!(format!("{prefix}{bumped}"), "v3.13.1");
}

#[tokio::test]
async fn current_version_uses_installed_version_matching_request() {
let config = Config::get().await.unwrap();
Expand Down
Loading