From 7ecc67bcd57804a161f2d30192f96f48490b20d7 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Thu, 2 Jun 2022 13:00:21 +0200 Subject: [PATCH] Report the correct app version when sending panics to server Previously, we were just relying on the `ZED_APP_VERSION` environment variable without consulting `Platform::app_version`. That would always report "dev" as the app version because `ZED_APP_VERSION` is only used for testing. --- crates/zed/src/main.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/crates/zed/src/main.rs b/crates/zed/src/main.rs index 821b1e2ebc..20d467f276 100644 --- a/crates/zed/src/main.rs +++ b/crates/zed/src/main.rs @@ -55,7 +55,10 @@ fn main() { init_logger(&logs_dir_path); let mut app = gpui::App::new(Assets).unwrap(); - init_panic_hook(logs_dir_path, http.clone(), app.background()); + let app_version = ZED_APP_VERSION + .or_else(|| app.platform().app_version().ok()) + .map_or("dev".to_string(), |v| v.to_string()); + init_panic_hook(logs_dir_path, app_version, http.clone(), app.background()); load_embedded_fonts(&app); @@ -258,7 +261,12 @@ fn init_logger(logs_dir_path: &Path) { } } -fn init_panic_hook(logs_dir_path: PathBuf, http: Arc, background: Arc) { +fn init_panic_hook( + logs_dir_path: PathBuf, + app_version: String, + http: Arc, + background: Arc, +) { background .spawn({ let logs_dir_path = logs_dir_path.clone(); @@ -321,7 +329,6 @@ fn init_panic_hook(logs_dir_path: PathBuf, http: Arc, background }) .detach(); - let app_version = ZED_APP_VERSION.map_or("dev".to_string(), |v| v.to_string()); let is_pty = stdout_is_a_pty(); panic::set_hook(Box::new(move |info| { let backtrace = Backtrace::new();