Make the commit sha availabe in the app, via a global
Co-authored-by: Mikayla <mikayla@zed.dev> Co-authored-by: Kirill <kirill@zed.dev>
This commit is contained in:
parent
a8bea41ad8
commit
a03d062120
4 changed files with 29 additions and 7 deletions
|
@ -1,6 +1,5 @@
|
||||||
use std::env;
|
|
||||||
|
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
|
use std::env;
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
pub static ref RELEASE_CHANNEL_NAME: String = if cfg!(debug_assertions) {
|
pub static ref RELEASE_CHANNEL_NAME: String = if cfg!(debug_assertions) {
|
||||||
|
@ -18,6 +17,8 @@ lazy_static! {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub struct AppCommitSha(pub String);
|
||||||
|
|
||||||
#[derive(Copy, Clone, PartialEq, Eq, Default)]
|
#[derive(Copy, Clone, PartialEq, Eq, Default)]
|
||||||
pub enum ReleaseChannel {
|
pub enum ReleaseChannel {
|
||||||
#[default]
|
#[default]
|
||||||
|
@ -40,7 +41,6 @@ impl ReleaseChannel {
|
||||||
pub fn dev_name(&self) -> &'static str {
|
pub fn dev_name(&self) -> &'static str {
|
||||||
match self {
|
match self {
|
||||||
ReleaseChannel::Dev => "dev",
|
ReleaseChannel::Dev => "dev",
|
||||||
// TODO kb need to add DB data
|
|
||||||
ReleaseChannel::Nightly => "nightly",
|
ReleaseChannel::Nightly => "nightly",
|
||||||
ReleaseChannel::Preview => "preview",
|
ReleaseChannel::Preview => "preview",
|
||||||
ReleaseChannel::Stable => "stable",
|
ReleaseChannel::Stable => "stable",
|
||||||
|
@ -69,7 +69,6 @@ impl ReleaseChannel {
|
||||||
pub fn release_query_param(&self) -> Option<&'static str> {
|
pub fn release_query_param(&self) -> Option<&'static str> {
|
||||||
match self {
|
match self {
|
||||||
Self::Dev => None,
|
Self::Dev => None,
|
||||||
// TODO kb need to add server handling
|
|
||||||
Self::Nightly => Some("nightly=1"),
|
Self::Nightly => Some("nightly=1"),
|
||||||
Self::Preview => Some("preview=1"),
|
Self::Preview => Some("preview=1"),
|
||||||
Self::Stable => None,
|
Self::Stable => None,
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
use std::process::Command;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
println!("cargo:rustc-env=MACOSX_DEPLOYMENT_TARGET=10.15.7");
|
println!("cargo:rustc-env=MACOSX_DEPLOYMENT_TARGET=10.15.7");
|
||||||
|
|
||||||
|
@ -21,4 +23,14 @@ fn main() {
|
||||||
|
|
||||||
// Register exported Objective-C selectors, protocols, etc
|
// Register exported Objective-C selectors, protocols, etc
|
||||||
println!("cargo:rustc-link-arg=-Wl,-ObjC");
|
println!("cargo:rustc-link-arg=-Wl,-ObjC");
|
||||||
|
|
||||||
|
// Populate git sha environment variable if git is available
|
||||||
|
if let Ok(output) = Command::new("git").args(["rev-parse", "HEAD"]).output() {
|
||||||
|
if output.status.success() {
|
||||||
|
println!(
|
||||||
|
"cargo:rustc-env=ZED_COMMIT_SHA={}",
|
||||||
|
String::from_utf8_lossy(&output.stdout).trim()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ use std::{
|
||||||
use theme::ActiveTheme;
|
use theme::ActiveTheme;
|
||||||
use util::{
|
use util::{
|
||||||
async_maybe,
|
async_maybe,
|
||||||
channel::{parse_zed_link, ReleaseChannel, RELEASE_CHANNEL},
|
channel::{parse_zed_link, AppCommitSha, ReleaseChannel, RELEASE_CHANNEL},
|
||||||
http::{self, HttpClient},
|
http::{self, HttpClient},
|
||||||
paths, ResultExt,
|
paths, ResultExt,
|
||||||
};
|
};
|
||||||
|
@ -113,6 +113,10 @@ fn main() {
|
||||||
|
|
||||||
app.run(move |cx| {
|
app.run(move |cx| {
|
||||||
cx.set_global(*RELEASE_CHANNEL);
|
cx.set_global(*RELEASE_CHANNEL);
|
||||||
|
if let Some(build_sha) = option_env!("ZED_COMMIT_SHA") {
|
||||||
|
cx.set_global(AppCommitSha(build_sha.into()))
|
||||||
|
}
|
||||||
|
|
||||||
cx.set_global(listener.clone());
|
cx.set_global(listener.clone());
|
||||||
|
|
||||||
load_embedded_fonts(cx);
|
load_embedded_fonts(cx);
|
||||||
|
|
|
@ -23,7 +23,7 @@ use std::{borrow::Cow, ops::Deref, sync::Arc};
|
||||||
use terminal_view::terminal_panel::TerminalPanel;
|
use terminal_view::terminal_panel::TerminalPanel;
|
||||||
use util::{
|
use util::{
|
||||||
asset_str,
|
asset_str,
|
||||||
channel::ReleaseChannel,
|
channel::{AppCommitSha, ReleaseChannel},
|
||||||
paths::{self, LOCAL_SETTINGS_RELATIVE_PATH},
|
paths::{self, LOCAL_SETTINGS_RELATIVE_PATH},
|
||||||
ResultExt,
|
ResultExt,
|
||||||
};
|
};
|
||||||
|
@ -432,9 +432,16 @@ pub fn initialize_workspace(app_state: Arc<AppState>, cx: &mut AppContext) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn about(_: &mut Workspace, _: &About, cx: &mut gpui::ViewContext<Workspace>) {
|
fn about(_: &mut Workspace, _: &About, cx: &mut gpui::ViewContext<Workspace>) {
|
||||||
|
use std::fmt::Write as _;
|
||||||
|
|
||||||
let app_name = cx.global::<ReleaseChannel>().display_name();
|
let app_name = cx.global::<ReleaseChannel>().display_name();
|
||||||
let version = env!("CARGO_PKG_VERSION");
|
let version = env!("CARGO_PKG_VERSION");
|
||||||
let prompt = cx.prompt(PromptLevel::Info, &format!("{app_name} {version}"), &["OK"]);
|
let mut message = format!("{app_name} {version}");
|
||||||
|
if let Some(sha) = cx.try_global::<AppCommitSha>() {
|
||||||
|
write!(&mut message, "\n\n{}", sha.0).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
let prompt = cx.prompt(PromptLevel::Info, &message, &["OK"]);
|
||||||
cx.foreground_executor()
|
cx.foreground_executor()
|
||||||
.spawn(async {
|
.spawn(async {
|
||||||
prompt.await.ok();
|
prompt.await.ok();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue