app version to server (#7130)
- Send app version and release stage to collab on connect - Read the new header on the server Release Notes: - Added the ability to collaborate with users on different releases of Zed.
This commit is contained in:
parent
5b7b5bfea5
commit
2187513026
14 changed files with 166 additions and 96 deletions
46
crates/util/src/semantic_version.rs
Normal file
46
crates/util/src/semantic_version.rs
Normal file
|
@ -0,0 +1,46 @@
|
|||
use std::{
|
||||
fmt::{self, Display},
|
||||
str::FromStr,
|
||||
};
|
||||
|
||||
use anyhow::{anyhow, Result};
|
||||
use serde::Serialize;
|
||||
|
||||
/// A datastructure representing a semantic version number
|
||||
#[derive(Clone, Copy, Debug, Default, Eq, Ord, PartialEq, PartialOrd, Serialize)]
|
||||
pub struct SemanticVersion {
|
||||
pub major: usize,
|
||||
pub minor: usize,
|
||||
pub patch: usize,
|
||||
}
|
||||
|
||||
impl FromStr for SemanticVersion {
|
||||
type Err = anyhow::Error;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self> {
|
||||
let mut components = s.trim().split('.');
|
||||
let major = components
|
||||
.next()
|
||||
.ok_or_else(|| anyhow!("missing major version number"))?
|
||||
.parse()?;
|
||||
let minor = components
|
||||
.next()
|
||||
.ok_or_else(|| anyhow!("missing minor version number"))?
|
||||
.parse()?;
|
||||
let patch = components
|
||||
.next()
|
||||
.ok_or_else(|| anyhow!("missing patch version number"))?
|
||||
.parse()?;
|
||||
Ok(Self {
|
||||
major,
|
||||
minor,
|
||||
patch,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for SemanticVersion {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{}.{}.{}", self.major, self.minor, self.patch)
|
||||
}
|
||||
}
|
|
@ -3,6 +3,7 @@ pub mod fs;
|
|||
pub mod github;
|
||||
pub mod http;
|
||||
pub mod paths;
|
||||
mod semantic_version;
|
||||
#[cfg(any(test, feature = "test-support"))]
|
||||
pub mod test;
|
||||
|
||||
|
@ -10,6 +11,7 @@ pub use backtrace::Backtrace;
|
|||
use futures::Future;
|
||||
use lazy_static::lazy_static;
|
||||
use rand::{seq::SliceRandom, Rng};
|
||||
pub use semantic_version::SemanticVersion;
|
||||
use std::{
|
||||
borrow::Cow,
|
||||
cmp::{self, Ordering},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue