From f1b41389b32f2d8f081fcc7dc345846999a1c078 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 26 Oct 2022 15:50:30 -0700 Subject: [PATCH] Allow overriding release channel at runtime via env var --- crates/client/src/client.rs | 2 +- crates/zed/src/zed.rs | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/crates/client/src/client.rs b/crates/client/src/client.rs index ce6bbe6f31..4c468059ff 100644 --- a/crates/client/src/client.rs +++ b/crates/client/src/client.rs @@ -991,13 +991,13 @@ impl Client { .zip(rpc_url.port_or_known_default()) .ok_or_else(|| anyhow!("missing host in rpc url"))?; let stream = smol::net::TcpStream::connect(rpc_host).await?; + rpc_url.set_query(if is_preview { Some("preview=1") } else { None }); log::info!("connected to rpc endpoint {}", rpc_url); match rpc_url.scheme() { "https" => { rpc_url.set_scheme("wss").unwrap(); - rpc_url.set_query(if is_preview { Some("preview=1") } else { None }); let request = request.uri(rpc_url.as_str()).body(())?; let (stream, _) = async_tungstenite::async_tls::client_async_tls(request, stream).await?; diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rs index 4463a4537c..6536d83ce6 100644 --- a/crates/zed/src/zed.rs +++ b/crates/zed/src/zed.rs @@ -69,14 +69,15 @@ actions!( ); const MIN_FONT_SIZE: f32 = 6.0; -const RELEASE_CHANNEL_NAME: &str = include_str!("../RELEASE_CHANNEL"); lazy_static! { - pub static ref RELEASE_CHANNEL: ReleaseChannel = match RELEASE_CHANNEL_NAME { + static ref RELEASE_CHANNEL_NAME: String = + env::var("ZED_RELEASE_CHANNEL").unwrap_or(include_str!("../RELEASE_CHANNEL").to_string()); + pub static ref RELEASE_CHANNEL: ReleaseChannel = match RELEASE_CHANNEL_NAME.as_str() { "dev" => ReleaseChannel::Dev, "preview" => ReleaseChannel::Preview, "stable" => ReleaseChannel::Preview, - _ => panic!("invalid release channel {RELEASE_CHANNEL_NAME}"), + _ => panic!("invalid release channel {}", *RELEASE_CHANNEL_NAME), }; }