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(upgrade): support RC release with --version flag #25091

Merged
Merged
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
65 changes: 39 additions & 26 deletions cli/tools/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,13 +380,13 @@ async fn check_for_upgrades_for_lsp_with_provider(
}
}
Ok(Some(LspVersionUpgradeInfo {
latest_version: latest_version.display,
latest_version: latest_version.version_or_hash,
is_canary: false,
}))
}

ReleaseChannel::Canary => Ok(Some(LspVersionUpgradeInfo {
latest_version: latest_version.display,
latest_version: latest_version.version_or_hash,
is_canary: true,
})),

Expand Down Expand Up @@ -488,7 +488,7 @@ pub async fn upgrade(
"{}",
colors::gray(format!(
"Deno is upgrading to version {}",
&selected_version_to_upgrade.display
&selected_version_to_upgrade.version_or_hash
))
);

Expand Down Expand Up @@ -527,13 +527,17 @@ pub async fn upgrade(
check_windows_access_denied_error(output_result, output_exe_path)?;

log::info!(
"\nUpgraded successfully to Deno {}\n",
colors::green(selected_version_to_upgrade.display())
"\nUpgraded successfully to Deno {} {}\n",
colors::green(selected_version_to_upgrade.display()),
colors::gray(&format!(
"({})",
selected_version_to_upgrade.release_channel.name()
))
);
if requested_version.release_channel() == ReleaseChannel::Stable {
print_release_notes(
version::DENO_VERSION_INFO.deno,
&selected_version_to_upgrade.display,
&selected_version_to_upgrade.version_or_hash,
);
}

Expand Down Expand Up @@ -574,10 +578,15 @@ impl RequestedVersion {
}
(ReleaseChannel::Canary, passed_version)
} else {
if Version::parse_standard(&passed_version).is_err() {
let Ok(semver) = Version::parse_standard(&passed_version) else {
bail!("Invalid version passed");
};
(ReleaseChannel::Stable, passed_version)

if semver.pre.contains(&"rc".to_string()) {
(ReleaseChannel::Rc, passed_version)
} else {
(ReleaseChannel::Stable, passed_version)
}
};

Ok(RequestedVersion::SpecificVersion(channel, passed_version))
Expand Down Expand Up @@ -616,9 +625,8 @@ fn select_specific_version_for_upgrade(
}

Ok(Some(AvailableVersion {
version_or_hash: version.to_string(),
version_or_hash: version,
release_channel,
display: version,
}))
}
ReleaseChannel::Canary => {
Expand All @@ -632,13 +640,28 @@ fn select_specific_version_for_upgrade(
}

Ok(Some(AvailableVersion {
version_or_hash: version.to_string(),
version_or_hash: version,
release_channel,
}))
}
ReleaseChannel::Rc => {
let current_is_passed = version::DENO_VERSION_INFO.release_channel
== ReleaseChannel::Rc
&& version::DENO_VERSION_INFO.deno == version;

if !force && current_is_passed {
log::info!(
"Version {} is already installed",
version::DENO_VERSION_INFO.deno
);
return Ok(None);
}

Ok(Some(AvailableVersion {
version_or_hash: version,
release_channel,
display: version,
}))
}
// TODO(bartlomieju)
ReleaseChannel::Rc => unreachable!(),
// TODO(bartlomieju)
ReleaseChannel::Lts => unreachable!(),
}
Expand Down Expand Up @@ -717,17 +740,15 @@ async fn find_latest_version_to_upgrade(
struct AvailableVersion {
version_or_hash: String,
release_channel: ReleaseChannel,
// TODO(bartlomieju): remove this one
display: String,
}

impl AvailableVersion {
/// Format display version, appending `v` before version number
/// for non-canary releases.
fn display(&self) -> Cow<str> {
match self.release_channel {
ReleaseChannel::Canary => Cow::Borrowed(&self.display),
_ => Cow::Owned(format!("v{}", self.display)),
ReleaseChannel::Canary => Cow::Borrowed(&self.version_or_hash),
_ => Cow::Owned(format!("v{}", self.version_or_hash)),
}
}
}
Expand All @@ -754,13 +775,11 @@ fn normalize_version_from_server(
Ok(AvailableVersion {
version_or_hash: v.to_string(),
release_channel,
display: v.to_string(),
})
}
ReleaseChannel::Canary => Ok(AvailableVersion {
version_or_hash: text.to_string(),
release_channel,
display: text.to_string(),
}),
}
}
Expand Down Expand Up @@ -1087,7 +1106,6 @@ mod test {
latest_version: Rc::new(RefCell::new(Ok(AvailableVersion {
version_or_hash: "".to_string(),
release_channel: ReleaseChannel::Stable,
display: "".to_string(),
}))),
time: Rc::new(RefCell::new(chrono::Utc::now())),
}
Expand Down Expand Up @@ -1116,7 +1134,6 @@ mod test {
*self.latest_version.borrow_mut() = Ok(AvailableVersion {
version_or_hash: version.to_string(),
release_channel,
display: version.to_string(),
});
}

Expand Down Expand Up @@ -1413,7 +1430,6 @@ mod test {
AvailableVersion {
version_or_hash: "1.0.0".to_string(),
release_channel: ReleaseChannel::Stable,
display: "1.0.0".to_string()
},
);
// should not replace v after start
Expand All @@ -1426,7 +1442,6 @@ mod test {
AvailableVersion {
version_or_hash: "1.0.0-test-v".to_string(),
release_channel: ReleaseChannel::Stable,
display: "1.0.0-test-v".to_string()
}
);
// should not strip v for canary
Expand All @@ -1439,7 +1454,6 @@ mod test {
AvailableVersion {
version_or_hash: "v1452345asdf".to_string(),
release_channel: ReleaseChannel::Canary,
display: "v1452345asdf".to_string()
}
);
assert_eq!(
Expand All @@ -1448,7 +1462,6 @@ mod test {
AvailableVersion {
version_or_hash: "1.46.0-rc.0".to_string(),
release_channel: ReleaseChannel::Rc,
display: "1.46.0-rc.0".to_string(),
},
);
}
Expand Down