Use shortened SHA when displaying version to install (#31281)
This PR uses a shortened SHA when displaying the nightly version to install in the update status, for nicer tooltip formatting. Release Notes: - N/A
This commit is contained in:
parent
14d9a4189f
commit
3a1053bf0c
10 changed files with 78 additions and 35 deletions
|
@ -35,14 +35,19 @@ pub fn app_identifier() -> &'static str {
|
|||
}
|
||||
|
||||
/// The Git commit SHA that Zed was built at.
|
||||
#[derive(Clone)]
|
||||
pub struct AppCommitSha(pub String);
|
||||
#[derive(Clone, Eq, Debug, PartialEq)]
|
||||
pub struct AppCommitSha(String);
|
||||
|
||||
struct GlobalAppCommitSha(AppCommitSha);
|
||||
|
||||
impl Global for GlobalAppCommitSha {}
|
||||
|
||||
impl AppCommitSha {
|
||||
/// Creates a new [`AppCommitSha`].
|
||||
pub fn new(sha: String) -> Self {
|
||||
AppCommitSha(sha)
|
||||
}
|
||||
|
||||
/// Returns the global [`AppCommitSha`], if one is set.
|
||||
pub fn try_global(cx: &App) -> Option<AppCommitSha> {
|
||||
cx.try_global::<GlobalAppCommitSha>()
|
||||
|
@ -53,6 +58,16 @@ impl AppCommitSha {
|
|||
pub fn set_global(sha: AppCommitSha, cx: &mut App) {
|
||||
cx.set_global(GlobalAppCommitSha(sha))
|
||||
}
|
||||
|
||||
/// Returns the full commit SHA.
|
||||
pub fn full(&self) -> String {
|
||||
self.0.to_string()
|
||||
}
|
||||
|
||||
/// Returns the short (7 character) commit SHA.
|
||||
pub fn short(&self) -> String {
|
||||
self.0.chars().take(7).collect()
|
||||
}
|
||||
}
|
||||
|
||||
struct GlobalAppVersion(SemanticVersion);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue