Add build SHA to panic reports and zed --version (on nightly/dev) (#24258)

Release Notes:

- N/A
This commit is contained in:
Michael Sloan 2025-02-06 02:09:24 -07:00 committed by GitHub
parent f08b1d78ec
commit 69e6910c9c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 76 additions and 33 deletions

View file

@ -188,9 +188,12 @@ fn main() {
let session_id = Uuid::new_v4().to_string();
let session = app.background_executor().block(Session::new());
let app_version = AppVersion::init(env!("CARGO_PKG_VERSION"));
let app_commit_sha =
option_env!("ZED_COMMIT_SHA").map(|commit_sha| AppCommitSha(commit_sha.to_string()));
reliability::init_panic_hook(
app_version,
app_commit_sha.clone(),
system_id.as_ref().map(|id| id.to_string()),
installation_id.as_ref().map(|id| id.to_string()),
session_id.clone(),
@ -281,8 +284,8 @@ fn main() {
app.run(move |cx| {
release_channel::init(app_version, cx);
gpui_tokio::init(cx);
if let Some(build_sha) = option_env!("ZED_COMMIT_SHA") {
AppCommitSha::set_global(AppCommitSha(build_sha.into()), cx);
if let Some(app_commit_sha) = app_commit_sha {
AppCommitSha::set_global(app_commit_sha, cx);
}
settings::init(cx);
handle_settings_file_changes(user_settings_file_rx, cx, handle_settings_changed);

View file

@ -8,7 +8,7 @@ use gpui::{App, SemanticVersion};
use http_client::{self, HttpClient, HttpClientWithUrl, HttpRequestExt, Method};
use paths::{crashes_dir, crashes_retired_dir};
use project::Project;
use release_channel::{ReleaseChannel, RELEASE_CHANNEL};
use release_channel::{AppCommitSha, ReleaseChannel, RELEASE_CHANNEL};
use settings::Settings;
use smol::stream::StreamExt;
use std::{
@ -25,6 +25,7 @@ static PANIC_COUNT: AtomicU32 = AtomicU32::new(0);
pub fn init_panic_hook(
app_version: SemanticVersion,
app_commit_sha: Option<AppCommitSha>,
system_id: Option<String>,
installation_id: Option<String>,
session_id: String,
@ -54,12 +55,22 @@ pub fn init_panic_hook(
let location = info.location().unwrap();
let backtrace = Backtrace::new();
eprintln!(
"Thread {:?} panicked with {:?} at {}:{}:{}\n{:?}",
"Thread {:?} panicked with {:?} at {}:{}:{}\n{}{:?}",
thread_name,
payload,
location.file(),
location.line(),
location.column(),
match app_commit_sha.as_ref() {
Some(commit_sha) => format!(
"https://github.com/zed-industries/zed/blob/{}/src/{}#L{} \
(may not be uploaded, line may be incorrect if files modified)\n",
commit_sha.0,
location.file(),
location.line()
),
None => "".to_string(),
},
backtrace,
);
std::process::exit(-1);
@ -103,6 +114,7 @@ pub fn init_panic_hook(
line: location.line(),
}),
app_version: app_version.to_string(),
app_commit_sha: app_commit_sha.as_ref().map(|sha| sha.0.clone()),
release_channel: RELEASE_CHANNEL.dev_name().into(),
target: env!("TARGET").to_owned().into(),
os_name: telemetry::os_name(),