From 6f459691056b68c2c99d8341b5f8dd4b811a53c1 Mon Sep 17 00:00:00 2001 From: Ogulcan Celik Date: Sun, 7 Jun 2026 21:53:59 +0300 Subject: fix(update): keep windows installs on preview --- src/cli.rs | 46 +++++++++++++++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 9 deletions(-) (limited to 'src/cli.rs') diff --git a/src/cli.rs b/src/cli.rs index 3650ebdb..88408fc8 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -79,7 +79,7 @@ fn channel_set(args: &[String]) -> std::io::Result { return Ok(2); }; - if let Some(reason) = channel_set_preview_rejection( + if let Some(reason) = channel_set_rejection( channel, crate::update::preview_channel_rejection_for_current_install(), ) { @@ -151,13 +151,21 @@ fn parse_channel_set_arg(args: &[String]) -> Option<&str> { } } -fn channel_set_preview_rejection( +fn channel_set_rejection( channel: &str, install_rejection: Option<&'static str>, ) -> Option<&'static str> { - (channel == "preview") - .then_some(install_rejection) - .flatten() + if cfg!(windows) && channel == "stable" { + return Some( + "stable channel is not available on Windows yet; Windows builds are preview-only", + ); + } + + if channel == "preview" { + return install_rejection; + } + + None } #[derive(Debug, Clone, Copy, PartialEq, Eq)] @@ -898,14 +906,34 @@ mod tests { #[test] fn channel_set_rejects_package_managed_preview_before_config_write() { assert_eq!( - super::channel_set_preview_rejection("preview", Some("no preview")), + super::channel_set_rejection("preview", Some("no preview")), Some("no preview") ); assert_eq!( - super::channel_set_preview_rejection("stable", Some("no preview")), - None + super::channel_set_rejection("stable", Some("no preview")), + if cfg!(windows) { + Some( + "stable channel is not available on Windows yet; Windows builds are preview-only", + ) + } else { + None + } + ); + assert_eq!(super::channel_set_rejection("preview", None), None); + } + + #[test] + fn channel_set_rejects_stable_only_on_windows() { + assert_eq!( + super::channel_set_rejection("stable", None), + if cfg!(windows) { + Some( + "stable channel is not available on Windows yet; Windows builds are preview-only", + ) + } else { + None + } ); - assert_eq!(super::channel_set_preview_rejection("preview", None), None); } #[test] -- cgit v1.2.3