Add (flatpak) and (snap) suffixes to Zed version in system info (#32903)

Release Notes:

- N/A
This commit is contained in:
Michael Sloan 2025-06-17 14:39:35 -06:00 committed by GitHub
parent 051fa06c7c
commit a422345224
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 54 additions and 10 deletions

View file

@ -15,6 +15,7 @@ pub struct SystemSpecs {
memory: u64, memory: u64,
architecture: &'static str, architecture: &'static str,
commit_sha: Option<String>, commit_sha: Option<String>,
bundle_type: Option<String>,
gpu_specs: Option<String>, gpu_specs: Option<String>,
} }
@ -34,6 +35,7 @@ impl SystemSpecs {
} }
_ => None, _ => None,
}; };
let bundle_type = bundle_type();
let gpu_specs = window.gpu_specs().map(|specs| { let gpu_specs = window.gpu_specs().map(|specs| {
format!( format!(
@ -47,6 +49,7 @@ impl SystemSpecs {
SystemSpecs { SystemSpecs {
app_version, app_version,
release_channel: release_channel.display_name(), release_channel: release_channel.display_name(),
bundle_type,
os_name, os_name,
os_version, os_version,
memory, memory,
@ -73,6 +76,7 @@ impl SystemSpecs {
ReleaseChannel::Dev | ReleaseChannel::Nightly => app_commit_sha.map(|sha| sha.full()), ReleaseChannel::Dev | ReleaseChannel::Nightly => app_commit_sha.map(|sha| sha.full()),
_ => None, _ => None,
}; };
let bundle_type = bundle_type();
Self { Self {
app_version: app_version.to_string(), app_version: app_version.to_string(),
@ -82,6 +86,7 @@ impl SystemSpecs {
memory, memory,
architecture, architecture,
commit_sha, commit_sha,
bundle_type,
gpu_specs: try_determine_available_gpus(), gpu_specs: try_determine_available_gpus(),
} }
} }
@ -91,12 +96,17 @@ impl Display for SystemSpecs {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let os_information = format!("OS: {} {}", self.os_name, self.os_version); let os_information = format!("OS: {} {}", self.os_name, self.os_version);
let app_version_information = format!( let app_version_information = format!(
"Zed: v{} ({}) {}", "Zed: v{} ({}) {}{}",
self.app_version, self.app_version,
match &self.commit_sha { match &self.commit_sha {
Some(commit_sha) => format!("{} {}", self.release_channel, commit_sha), Some(commit_sha) => format!("{} {}", self.release_channel, commit_sha),
None => self.release_channel.to_string(), None => self.release_channel.to_string(),
}, },
if let Some(bundle_type) = &self.bundle_type {
format!("({bundle_type})")
} else {
"".to_string()
},
if cfg!(debug_assertions) { if cfg!(debug_assertions) {
"(Taylor's Version)" "(Taylor's Version)"
} else { } else {
@ -147,3 +157,16 @@ fn try_determine_available_gpus() -> Option<String> {
return None; return None;
} }
} }
/// Returns value of `ZED_BUNDLE_TYPE` set at compiletime or else at runtime.
///
/// The compiletime value is used by flatpak since it doesn't seem to have a way to provide a
/// runtime environment variable.
///
/// The runtime value is used by snap since the Zed snaps use release binaries directly, and so
/// cannot have this baked in.
fn bundle_type() -> Option<String> {
option_env!("ZED_BUNDLE_TYPE")
.map(|bundle_type| bundle_type.to_string())
.or_else(|| env::var("ZED_BUNDLE_TYPE").ok())
}

View file

@ -55,3 +55,5 @@ apps:
zed: zed:
command: usr/bin/zed command: usr/bin/zed
common-id: dev.zed.Zed common-id: dev.zed.Zed
environment:
ZED_BUNDLE_TYPE: snap

View file

@ -10,17 +10,36 @@ Usage: ${0##*/} [options]
Build a release .tar.gz for Linux. Build a release .tar.gz for Linux.
Options: Options:
-h Display this help and exit. -h, --help Display this help and exit.
--flatpak Set ZED_BUNDLE_TYPE=flatpak so that this can be included in system info
" "
} }
while getopts 'h' flag # Parse all arguments manually
do while [[ $# -gt 0 ]]; do
case "${flag}" in case $1 in
h) -h|--help)
help_info help_info
exit 0 exit 0
;; ;;
--flatpak)
export ZED_BUNDLE_TYPE=flatpak
shift
;;
--)
shift
break
;;
-*)
echo "Unknown option: $1" >&2
help_info
exit 1
;;
*)
echo "Error: Unexpected argument: $1" >&2
help_info
exit 1
;;
esac esac
done done

View file

@ -4,7 +4,7 @@ set -euo pipefail
cd "$(dirname "$0")/../.." cd "$(dirname "$0")/../.."
shopt -s extglob shopt -s extglob
script/bundle-linux script/bundle-linux --flatpak
archive_match="zed(-[a-zA-Z0-9]+)?-linux-$(uname -m)\.tar\.gz" archive_match="zed(-[a-zA-Z0-9]+)?-linux-$(uname -m)\.tar\.gz"
archive=$(ls "target/release" | grep -E ${archive_match}) archive=$(ls "target/release" | grep -E ${archive_match})
channel=$(<crates/zed/RELEASE_CHANNEL) channel=$(<crates/zed/RELEASE_CHANNEL)