Extract SemanticVersion
into its own crate (#9956)
This PR extracts the `SemanticVersion` out of `util` and into its own `SemanticVersion` crate. This allows for making use of `SemanticVersion` without needing to pull in some of the heavier dependencies included in the `util` crate. As part of this the public API for `SemanticVersion` has been tidied up a bit. Release Notes: - N/A
This commit is contained in:
parent
77f1cc95b8
commit
16e6f5643c
14
Cargo.lock
generated
14
Cargo.lock
generated
@ -2265,6 +2265,7 @@ dependencies = [
|
|||||||
"rustc-demangle",
|
"rustc-demangle",
|
||||||
"scrypt",
|
"scrypt",
|
||||||
"sea-orm",
|
"sea-orm",
|
||||||
|
"semantic_version",
|
||||||
"semver",
|
"semver",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
@ -3558,6 +3559,7 @@ dependencies = [
|
|||||||
"parking_lot",
|
"parking_lot",
|
||||||
"project",
|
"project",
|
||||||
"schemars",
|
"schemars",
|
||||||
|
"semantic_version",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"serde_json_lenient",
|
"serde_json_lenient",
|
||||||
@ -3610,6 +3612,7 @@ dependencies = [
|
|||||||
"language",
|
"language",
|
||||||
"picker",
|
"picker",
|
||||||
"project",
|
"project",
|
||||||
|
"semantic_version",
|
||||||
"serde",
|
"serde",
|
||||||
"settings",
|
"settings",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
@ -4446,6 +4449,7 @@ dependencies = [
|
|||||||
"resvg",
|
"resvg",
|
||||||
"schemars",
|
"schemars",
|
||||||
"seahash",
|
"seahash",
|
||||||
|
"semantic_version",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
@ -8496,6 +8500,14 @@ version = "1.0.3"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "58bf37232d3bb9a2c4e641ca2a11d83b5062066f88df7fed36c28772046d65ba"
|
checksum = "58bf37232d3bb9a2c4e641ca2a11d83b5062066f88df7fed36c28772046d65ba"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "semantic_version"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "semver"
|
name = "semver"
|
||||||
version = "1.0.18"
|
version = "1.0.18"
|
||||||
@ -9659,8 +9671,8 @@ dependencies = [
|
|||||||
name = "telemetry_events"
|
name = "telemetry_events"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"semantic_version",
|
||||||
"serde",
|
"serde",
|
||||||
"util",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -70,6 +70,7 @@ members = [
|
|||||||
"crates/task",
|
"crates/task",
|
||||||
"crates/tasks_ui",
|
"crates/tasks_ui",
|
||||||
"crates/search",
|
"crates/search",
|
||||||
|
"crates/semantic_version",
|
||||||
"crates/settings",
|
"crates/settings",
|
||||||
"crates/snippet",
|
"crates/snippet",
|
||||||
"crates/sqlez",
|
"crates/sqlez",
|
||||||
@ -184,6 +185,7 @@ rpc = { path = "crates/rpc" }
|
|||||||
task = { path = "crates/task" }
|
task = { path = "crates/task" }
|
||||||
tasks_ui = { path = "crates/tasks_ui" }
|
tasks_ui = { path = "crates/tasks_ui" }
|
||||||
search = { path = "crates/search" }
|
search = { path = "crates/search" }
|
||||||
|
semantic_version = { path = "crates/semantic_version" }
|
||||||
settings = { path = "crates/settings" }
|
settings = { path = "crates/settings" }
|
||||||
snippet = { path = "crates/snippet" }
|
snippet = { path = "crates/snippet" }
|
||||||
sqlez = { path = "crates/sqlez" }
|
sqlez = { path = "crates/sqlez" }
|
||||||
|
@ -46,6 +46,7 @@ reqwest = { version = "0.11", features = ["json"] }
|
|||||||
rpc.workspace = true
|
rpc.workspace = true
|
||||||
scrypt = "0.7"
|
scrypt = "0.7"
|
||||||
sea-orm = { version = "0.12.x", features = ["sqlx-postgres", "postgres-array", "runtime-tokio-rustls", "with-uuid"] }
|
sea-orm = { version = "0.12.x", features = ["sqlx-postgres", "postgres-array", "runtime-tokio-rustls", "with-uuid"] }
|
||||||
|
semantic_version.workspace = true
|
||||||
semver.workspace = true
|
semver.workspace = true
|
||||||
serde.workspace = true
|
serde.workspace = true
|
||||||
serde_derive.workspace = true
|
serde_derive.workspace = true
|
||||||
|
@ -10,6 +10,7 @@ use axum::{
|
|||||||
Extension, Router, TypedHeader,
|
Extension, Router, TypedHeader,
|
||||||
};
|
};
|
||||||
use rpc::ExtensionMetadata;
|
use rpc::ExtensionMetadata;
|
||||||
|
use semantic_version::SemanticVersion;
|
||||||
use serde::{Serialize, Serializer};
|
use serde::{Serialize, Serializer};
|
||||||
use sha2::{Digest, Sha256};
|
use sha2::{Digest, Sha256};
|
||||||
use std::sync::{Arc, OnceLock};
|
use std::sync::{Arc, OnceLock};
|
||||||
@ -17,7 +18,6 @@ use telemetry_events::{
|
|||||||
ActionEvent, AppEvent, AssistantEvent, CallEvent, CopilotEvent, CpuEvent, EditEvent,
|
ActionEvent, AppEvent, AssistantEvent, CallEvent, CopilotEvent, CpuEvent, EditEvent,
|
||||||
EditorEvent, Event, EventRequestBody, EventWrapper, ExtensionEvent, MemoryEvent, SettingEvent,
|
EditorEvent, Event, EventRequestBody, EventWrapper, ExtensionEvent, MemoryEvent, SettingEvent,
|
||||||
};
|
};
|
||||||
use util::SemanticVersion;
|
|
||||||
|
|
||||||
pub fn router() -> Router {
|
pub fn router() -> Router {
|
||||||
Router::new()
|
Router::new()
|
||||||
@ -528,9 +528,9 @@ impl EditorEventRow {
|
|||||||
|
|
||||||
Self {
|
Self {
|
||||||
app_version: body.app_version.clone(),
|
app_version: body.app_version.clone(),
|
||||||
major: semver.map(|s| s.major as i32),
|
major: semver.map(|v| v.major() as i32),
|
||||||
minor: semver.map(|s| s.minor as i32),
|
minor: semver.map(|v| v.minor() as i32),
|
||||||
patch: semver.map(|s| s.patch as i32),
|
patch: semver.map(|v| v.patch() as i32),
|
||||||
release_channel: body.release_channel.clone().unwrap_or_default(),
|
release_channel: body.release_channel.clone().unwrap_or_default(),
|
||||||
os_name: body.os_name.clone(),
|
os_name: body.os_name.clone(),
|
||||||
os_version: body.os_version.clone().unwrap_or_default(),
|
os_version: body.os_version.clone().unwrap_or_default(),
|
||||||
@ -590,9 +590,9 @@ impl CopilotEventRow {
|
|||||||
|
|
||||||
Self {
|
Self {
|
||||||
app_version: body.app_version.clone(),
|
app_version: body.app_version.clone(),
|
||||||
major: semver.map(|s| s.major as i32),
|
major: semver.map(|v| v.major() as i32),
|
||||||
minor: semver.map(|s| s.minor as i32),
|
minor: semver.map(|v| v.minor() as i32),
|
||||||
patch: semver.map(|s| s.patch as i32),
|
patch: semver.map(|v| v.patch() as i32),
|
||||||
release_channel: body.release_channel.clone().unwrap_or_default(),
|
release_channel: body.release_channel.clone().unwrap_or_default(),
|
||||||
os_name: body.os_name.clone(),
|
os_name: body.os_name.clone(),
|
||||||
os_version: body.os_version.clone().unwrap_or_default(),
|
os_version: body.os_version.clone().unwrap_or_default(),
|
||||||
@ -645,9 +645,9 @@ impl CallEventRow {
|
|||||||
|
|
||||||
Self {
|
Self {
|
||||||
app_version: body.app_version.clone(),
|
app_version: body.app_version.clone(),
|
||||||
major: semver.map(|s| s.major as i32),
|
major: semver.map(|v| v.major() as i32),
|
||||||
minor: semver.map(|s| s.minor as i32),
|
minor: semver.map(|v| v.minor() as i32),
|
||||||
patch: semver.map(|s| s.patch as i32),
|
patch: semver.map(|v| v.patch() as i32),
|
||||||
release_channel: body.release_channel.clone().unwrap_or_default(),
|
release_channel: body.release_channel.clone().unwrap_or_default(),
|
||||||
installation_id: body.installation_id.clone().unwrap_or_default(),
|
installation_id: body.installation_id.clone().unwrap_or_default(),
|
||||||
session_id: body.session_id.clone(),
|
session_id: body.session_id.clone(),
|
||||||
@ -694,9 +694,9 @@ impl AssistantEventRow {
|
|||||||
|
|
||||||
Self {
|
Self {
|
||||||
app_version: body.app_version.clone(),
|
app_version: body.app_version.clone(),
|
||||||
major: semver.map(|s| s.major as i32),
|
major: semver.map(|v| v.major() as i32),
|
||||||
minor: semver.map(|s| s.minor as i32),
|
minor: semver.map(|v| v.minor() as i32),
|
||||||
patch: semver.map(|s| s.patch as i32),
|
patch: semver.map(|v| v.patch() as i32),
|
||||||
release_channel: body.release_channel.clone().unwrap_or_default(),
|
release_channel: body.release_channel.clone().unwrap_or_default(),
|
||||||
installation_id: body.installation_id.clone(),
|
installation_id: body.installation_id.clone(),
|
||||||
session_id: body.session_id.clone(),
|
session_id: body.session_id.clone(),
|
||||||
@ -738,9 +738,9 @@ impl CpuEventRow {
|
|||||||
|
|
||||||
Self {
|
Self {
|
||||||
app_version: body.app_version.clone(),
|
app_version: body.app_version.clone(),
|
||||||
major: semver.map(|s| s.major as i32),
|
major: semver.map(|v| v.major() as i32),
|
||||||
minor: semver.map(|s| s.minor as i32),
|
minor: semver.map(|v| v.minor() as i32),
|
||||||
patch: semver.map(|s| s.patch as i32),
|
patch: semver.map(|v| v.patch() as i32),
|
||||||
release_channel: body.release_channel.clone().unwrap_or_default(),
|
release_channel: body.release_channel.clone().unwrap_or_default(),
|
||||||
installation_id: body.installation_id.clone(),
|
installation_id: body.installation_id.clone(),
|
||||||
session_id: body.session_id.clone(),
|
session_id: body.session_id.clone(),
|
||||||
@ -785,9 +785,9 @@ impl MemoryEventRow {
|
|||||||
|
|
||||||
Self {
|
Self {
|
||||||
app_version: body.app_version.clone(),
|
app_version: body.app_version.clone(),
|
||||||
major: semver.map(|s| s.major as i32),
|
major: semver.map(|v| v.major() as i32),
|
||||||
minor: semver.map(|s| s.minor as i32),
|
minor: semver.map(|v| v.minor() as i32),
|
||||||
patch: semver.map(|s| s.patch as i32),
|
patch: semver.map(|v| v.patch() as i32),
|
||||||
release_channel: body.release_channel.clone().unwrap_or_default(),
|
release_channel: body.release_channel.clone().unwrap_or_default(),
|
||||||
installation_id: body.installation_id.clone(),
|
installation_id: body.installation_id.clone(),
|
||||||
session_id: body.session_id.clone(),
|
session_id: body.session_id.clone(),
|
||||||
@ -831,9 +831,9 @@ impl AppEventRow {
|
|||||||
|
|
||||||
Self {
|
Self {
|
||||||
app_version: body.app_version.clone(),
|
app_version: body.app_version.clone(),
|
||||||
major: semver.map(|s| s.major as i32),
|
major: semver.map(|v| v.major() as i32),
|
||||||
minor: semver.map(|s| s.minor as i32),
|
minor: semver.map(|v| v.minor() as i32),
|
||||||
patch: semver.map(|s| s.patch as i32),
|
patch: semver.map(|v| v.patch() as i32),
|
||||||
release_channel: body.release_channel.clone().unwrap_or_default(),
|
release_channel: body.release_channel.clone().unwrap_or_default(),
|
||||||
installation_id: body.installation_id.clone(),
|
installation_id: body.installation_id.clone(),
|
||||||
session_id: body.session_id.clone(),
|
session_id: body.session_id.clone(),
|
||||||
@ -876,9 +876,9 @@ impl SettingEventRow {
|
|||||||
|
|
||||||
Self {
|
Self {
|
||||||
app_version: body.app_version.clone(),
|
app_version: body.app_version.clone(),
|
||||||
major: semver.map(|s| s.major as i32),
|
major: semver.map(|v| v.major() as i32),
|
||||||
minor: semver.map(|s| s.minor as i32),
|
minor: semver.map(|v| v.minor() as i32),
|
||||||
patch: semver.map(|s| s.patch as i32),
|
patch: semver.map(|v| v.patch() as i32),
|
||||||
release_channel: body.release_channel.clone().unwrap_or_default(),
|
release_channel: body.release_channel.clone().unwrap_or_default(),
|
||||||
installation_id: body.installation_id.clone(),
|
installation_id: body.installation_id.clone(),
|
||||||
session_id: body.session_id.clone(),
|
session_id: body.session_id.clone(),
|
||||||
@ -927,9 +927,9 @@ impl ExtensionEventRow {
|
|||||||
|
|
||||||
Self {
|
Self {
|
||||||
app_version: body.app_version.clone(),
|
app_version: body.app_version.clone(),
|
||||||
major: semver.map(|s| s.major as i32),
|
major: semver.map(|v| v.major() as i32),
|
||||||
minor: semver.map(|s| s.minor as i32),
|
minor: semver.map(|v| v.minor() as i32),
|
||||||
patch: semver.map(|s| s.patch as i32),
|
patch: semver.map(|v| v.patch() as i32),
|
||||||
release_channel: body.release_channel.clone().unwrap_or_default(),
|
release_channel: body.release_channel.clone().unwrap_or_default(),
|
||||||
installation_id: body.installation_id.clone(),
|
installation_id: body.installation_id.clone(),
|
||||||
session_id: body.session_id.clone(),
|
session_id: body.session_id.clone(),
|
||||||
@ -991,9 +991,9 @@ impl EditEventRow {
|
|||||||
|
|
||||||
Self {
|
Self {
|
||||||
app_version: body.app_version.clone(),
|
app_version: body.app_version.clone(),
|
||||||
major: semver.map(|s| s.major as i32),
|
major: semver.map(|v| v.major() as i32),
|
||||||
minor: semver.map(|s| s.minor as i32),
|
minor: semver.map(|v| v.minor() as i32),
|
||||||
patch: semver.map(|s| s.patch as i32),
|
patch: semver.map(|v| v.patch() as i32),
|
||||||
release_channel: body.release_channel.clone().unwrap_or_default(),
|
release_channel: body.release_channel.clone().unwrap_or_default(),
|
||||||
installation_id: body.installation_id.clone(),
|
installation_id: body.installation_id.clone(),
|
||||||
session_id: body.session_id.clone(),
|
session_id: body.session_id.clone(),
|
||||||
@ -1040,9 +1040,9 @@ impl ActionEventRow {
|
|||||||
|
|
||||||
Self {
|
Self {
|
||||||
app_version: body.app_version.clone(),
|
app_version: body.app_version.clone(),
|
||||||
major: semver.map(|s| s.major as i32),
|
major: semver.map(|v| v.major() as i32),
|
||||||
minor: semver.map(|s| s.minor as i32),
|
minor: semver.map(|v| v.minor() as i32),
|
||||||
patch: semver.map(|s| s.patch as i32),
|
patch: semver.map(|v| v.patch() as i32),
|
||||||
release_channel: body.release_channel.clone().unwrap_or_default(),
|
release_channel: body.release_channel.clone().unwrap_or_default(),
|
||||||
installation_id: body.installation_id.clone(),
|
installation_id: body.installation_id.clone(),
|
||||||
session_id: body.session_id.clone(),
|
session_id: body.session_id.clone(),
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
use collections::HashMap;
|
use collections::HashMap;
|
||||||
|
|
||||||
use serde_derive::Deserialize;
|
use semantic_version::SemanticVersion;
|
||||||
use serde_derive::Serialize;
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
use util::SemanticVersion;
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct IpsFile {
|
pub struct IpsFile {
|
||||||
|
@ -46,6 +46,7 @@ use rpc::{
|
|||||||
},
|
},
|
||||||
Connection, ConnectionId, ErrorCode, ErrorCodeExt, ErrorExt, Peer, Receipt, TypedEnvelope,
|
Connection, ConnectionId, ErrorCode, ErrorCodeExt, ErrorExt, Peer, Receipt, TypedEnvelope,
|
||||||
};
|
};
|
||||||
|
use semantic_version::SemanticVersion;
|
||||||
use serde::{Serialize, Serializer};
|
use serde::{Serialize, Serializer};
|
||||||
use std::{
|
use std::{
|
||||||
any::TypeId,
|
any::TypeId,
|
||||||
@ -68,7 +69,7 @@ use tracing::{
|
|||||||
field::{self},
|
field::{self},
|
||||||
info_span, instrument, Instrument,
|
info_span, instrument, Instrument,
|
||||||
};
|
};
|
||||||
use util::{http::IsahcHttpClient, SemanticVersion};
|
use util::http::IsahcHttpClient;
|
||||||
|
|
||||||
pub const RECONNECT_TIMEOUT: Duration = Duration::from_secs(30);
|
pub const RECONNECT_TIMEOUT: Duration = Duration::from_secs(30);
|
||||||
|
|
||||||
|
@ -2,9 +2,10 @@ use crate::db::{ChannelId, ChannelRole, UserId};
|
|||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use collections::{BTreeMap, HashMap, HashSet};
|
use collections::{BTreeMap, HashMap, HashSet};
|
||||||
use rpc::ConnectionId;
|
use rpc::ConnectionId;
|
||||||
|
use semantic_version::SemanticVersion;
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
use std::fmt;
|
||||||
use tracing::instrument;
|
use tracing::instrument;
|
||||||
use util::{semver, SemanticVersion};
|
|
||||||
|
|
||||||
#[derive(Default, Serialize)]
|
#[derive(Default, Serialize)]
|
||||||
pub struct ConnectionPool {
|
pub struct ConnectionPool {
|
||||||
@ -20,7 +21,6 @@ struct ConnectedUser {
|
|||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize)]
|
||||||
pub struct ZedVersion(pub SemanticVersion);
|
pub struct ZedVersion(pub SemanticVersion);
|
||||||
use std::fmt;
|
|
||||||
|
|
||||||
impl fmt::Display for ZedVersion {
|
impl fmt::Display for ZedVersion {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
@ -30,7 +30,7 @@ impl fmt::Display for ZedVersion {
|
|||||||
|
|
||||||
impl ZedVersion {
|
impl ZedVersion {
|
||||||
pub fn can_collaborate(&self) -> bool {
|
pub fn can_collaborate(&self) -> bool {
|
||||||
self.0 >= semver(0, 127, 3)
|
self.0 >= SemanticVersion::new(0, 127, 3)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@ use futures::{channel::oneshot, StreamExt as _};
|
|||||||
use gpui::{BackgroundExecutor, Context, Model, Task, TestAppContext, View, VisualTestContext};
|
use gpui::{BackgroundExecutor, Context, Model, Task, TestAppContext, View, VisualTestContext};
|
||||||
use language::LanguageRegistry;
|
use language::LanguageRegistry;
|
||||||
use node_runtime::FakeNodeRuntime;
|
use node_runtime::FakeNodeRuntime;
|
||||||
|
|
||||||
use notifications::NotificationStore;
|
use notifications::NotificationStore;
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use project::{Project, WorktreeId};
|
use project::{Project, WorktreeId};
|
||||||
@ -27,6 +26,7 @@ use rpc::{
|
|||||||
proto::{self, ChannelRole},
|
proto::{self, ChannelRole},
|
||||||
RECEIVE_TIMEOUT,
|
RECEIVE_TIMEOUT,
|
||||||
};
|
};
|
||||||
|
use semantic_version::SemanticVersion;
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use settings::SettingsStore;
|
use settings::SettingsStore;
|
||||||
use std::{
|
use std::{
|
||||||
@ -39,7 +39,7 @@ use std::{
|
|||||||
Arc,
|
Arc,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use util::{http::FakeHttpClient, SemanticVersion};
|
use util::http::FakeHttpClient;
|
||||||
use workspace::{Workspace, WorkspaceId, WorkspaceStore};
|
use workspace::{Workspace, WorkspaceId, WorkspaceStore};
|
||||||
|
|
||||||
pub struct TestServer {
|
pub struct TestServer {
|
||||||
|
@ -33,6 +33,7 @@ lsp.workspace = true
|
|||||||
node_runtime.workspace = true
|
node_runtime.workspace = true
|
||||||
project.workspace = true
|
project.workspace = true
|
||||||
schemars.workspace = true
|
schemars.workspace = true
|
||||||
|
semantic_version.workspace = true
|
||||||
serde.workspace = true
|
serde.workspace = true
|
||||||
serde_json.workspace = true
|
serde_json.workspace = true
|
||||||
settings.workspace = true
|
settings.workspace = true
|
||||||
|
@ -2,6 +2,7 @@ use anyhow::{anyhow, Context, Result};
|
|||||||
use collections::BTreeMap;
|
use collections::BTreeMap;
|
||||||
use fs::Fs;
|
use fs::Fs;
|
||||||
use language::LanguageServerName;
|
use language::LanguageServerName;
|
||||||
|
use semantic_version::SemanticVersion;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::{
|
use std::{
|
||||||
ffi::OsStr,
|
ffi::OsStr,
|
||||||
@ -9,7 +10,6 @@ use std::{
|
|||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
use util::SemanticVersion;
|
|
||||||
|
|
||||||
/// This is the old version of the extension manifest, from when it was `extension.json`.
|
/// This is the old version of the extension manifest, from when it was `extension.json`.
|
||||||
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize)]
|
||||||
|
@ -33,6 +33,7 @@ use language::{
|
|||||||
QUERY_FILENAME_PREFIXES,
|
QUERY_FILENAME_PREFIXES,
|
||||||
};
|
};
|
||||||
use node_runtime::NodeRuntime;
|
use node_runtime::NodeRuntime;
|
||||||
|
use semantic_version::SemanticVersion;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use settings::Settings;
|
use settings::Settings;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
@ -44,7 +45,6 @@ use std::{
|
|||||||
};
|
};
|
||||||
use theme::{ThemeRegistry, ThemeSettings};
|
use theme::{ThemeRegistry, ThemeSettings};
|
||||||
use url::Url;
|
use url::Url;
|
||||||
use util::SemanticVersion;
|
|
||||||
use util::{
|
use util::{
|
||||||
http::{AsyncBody, HttpClient, HttpClientWithUrl},
|
http::{AsyncBody, HttpClient, HttpClientWithUrl},
|
||||||
maybe,
|
maybe,
|
||||||
|
@ -14,11 +14,12 @@ use futures::{
|
|||||||
use gpui::BackgroundExecutor;
|
use gpui::BackgroundExecutor;
|
||||||
use language::LanguageRegistry;
|
use language::LanguageRegistry;
|
||||||
use node_runtime::NodeRuntime;
|
use node_runtime::NodeRuntime;
|
||||||
|
use semantic_version::SemanticVersion;
|
||||||
use std::{
|
use std::{
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
sync::{Arc, OnceLock},
|
sync::{Arc, OnceLock},
|
||||||
};
|
};
|
||||||
use util::{http::HttpClient, SemanticVersion};
|
use util::http::HttpClient;
|
||||||
use wasmtime::{
|
use wasmtime::{
|
||||||
component::{Component, ResourceTable},
|
component::{Component, ResourceTable},
|
||||||
Engine, Store,
|
Engine, Store,
|
||||||
@ -203,11 +204,11 @@ pub fn parse_wasm_extension_version(
|
|||||||
|
|
||||||
fn parse_wasm_extension_version_custom_section(data: &[u8]) -> Option<SemanticVersion> {
|
fn parse_wasm_extension_version_custom_section(data: &[u8]) -> Option<SemanticVersion> {
|
||||||
if data.len() == 6 {
|
if data.len() == 6 {
|
||||||
Some(SemanticVersion {
|
Some(SemanticVersion::new(
|
||||||
major: u16::from_be_bytes([data[0], data[1]]) as _,
|
u16::from_be_bytes([data[0], data[1]]) as _,
|
||||||
minor: u16::from_be_bytes([data[2], data[3]]) as _,
|
u16::from_be_bytes([data[2], data[3]]) as _,
|
||||||
patch: u16::from_be_bytes([data[4], data[5]]) as _,
|
u16::from_be_bytes([data[4], data[5]]) as _,
|
||||||
})
|
))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,8 @@ mod v0_0_4;
|
|||||||
use super::{wasm_engine, WasmState};
|
use super::{wasm_engine, WasmState};
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
use language::LspAdapterDelegate;
|
use language::LspAdapterDelegate;
|
||||||
|
use semantic_version::SemanticVersion;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use util::SemanticVersion;
|
|
||||||
use wasmtime::{
|
use wasmtime::{
|
||||||
component::{Component, Instance, Linker, Resource},
|
component::{Component, Instance, Linker, Resource},
|
||||||
Store,
|
Store,
|
||||||
|
@ -3,15 +3,11 @@ use crate::wasm_host::WasmState;
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use language::{LanguageServerBinaryStatus, LspAdapterDelegate};
|
use language::{LanguageServerBinaryStatus, LspAdapterDelegate};
|
||||||
|
use semantic_version::SemanticVersion;
|
||||||
use std::sync::{Arc, OnceLock};
|
use std::sync::{Arc, OnceLock};
|
||||||
use util::SemanticVersion;
|
|
||||||
use wasmtime::component::{Linker, Resource};
|
use wasmtime::component::{Linker, Resource};
|
||||||
|
|
||||||
pub const VERSION: SemanticVersion = SemanticVersion {
|
pub const VERSION: SemanticVersion = SemanticVersion::new(0, 0, 1);
|
||||||
major: 0,
|
|
||||||
minor: 0,
|
|
||||||
patch: 1,
|
|
||||||
};
|
|
||||||
|
|
||||||
wasmtime::component::bindgen!({
|
wasmtime::component::bindgen!({
|
||||||
async: true,
|
async: true,
|
||||||
|
@ -5,19 +5,16 @@ use async_tar::Archive;
|
|||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use futures::io::BufReader;
|
use futures::io::BufReader;
|
||||||
use language::{LanguageServerBinaryStatus, LspAdapterDelegate};
|
use language::{LanguageServerBinaryStatus, LspAdapterDelegate};
|
||||||
|
use semantic_version::SemanticVersion;
|
||||||
use std::{
|
use std::{
|
||||||
env,
|
env,
|
||||||
path::PathBuf,
|
path::PathBuf,
|
||||||
sync::{Arc, OnceLock},
|
sync::{Arc, OnceLock},
|
||||||
};
|
};
|
||||||
use util::{maybe, SemanticVersion};
|
use util::maybe;
|
||||||
use wasmtime::component::{Linker, Resource};
|
use wasmtime::component::{Linker, Resource};
|
||||||
|
|
||||||
pub const VERSION: SemanticVersion = SemanticVersion {
|
pub const VERSION: SemanticVersion = SemanticVersion::new(0, 0, 4);
|
||||||
major: 0,
|
|
||||||
minor: 0,
|
|
||||||
patch: 4,
|
|
||||||
};
|
|
||||||
|
|
||||||
wasmtime::component::bindgen!({
|
wasmtime::component::bindgen!({
|
||||||
async: true,
|
async: true,
|
||||||
|
@ -26,6 +26,7 @@ gpui.workspace = true
|
|||||||
language.workspace = true
|
language.workspace = true
|
||||||
picker.workspace = true
|
picker.workspace = true
|
||||||
project.workspace = true
|
project.workspace = true
|
||||||
|
semantic_version.workspace = true
|
||||||
serde.workspace = true
|
serde.workspace = true
|
||||||
settings.workspace = true
|
settings.workspace = true
|
||||||
smallvec.workspace = true
|
smallvec.workspace = true
|
||||||
|
@ -9,9 +9,10 @@ use gpui::{
|
|||||||
prelude::*, AppContext, DismissEvent, EventEmitter, FocusableView, Task, View, WeakView,
|
prelude::*, AppContext, DismissEvent, EventEmitter, FocusableView, Task, View, WeakView,
|
||||||
};
|
};
|
||||||
use picker::{Picker, PickerDelegate};
|
use picker::{Picker, PickerDelegate};
|
||||||
|
use semantic_version::SemanticVersion;
|
||||||
use settings::update_settings_file;
|
use settings::update_settings_file;
|
||||||
use ui::{prelude::*, HighlightedLabel, ListItem, ListItemSpacing};
|
use ui::{prelude::*, HighlightedLabel, ListItem, ListItemSpacing};
|
||||||
use util::{ResultExt, SemanticVersion};
|
use util::ResultExt;
|
||||||
use workspace::ModalView;
|
use workspace::ModalView;
|
||||||
|
|
||||||
pub struct ExtensionVersionSelector {
|
pub struct ExtensionVersionSelector {
|
||||||
|
@ -57,6 +57,7 @@ refineable.workspace = true
|
|||||||
resvg = "0.40"
|
resvg = "0.40"
|
||||||
schemars.workspace = true
|
schemars.workspace = true
|
||||||
seahash = "4.1"
|
seahash = "4.1"
|
||||||
|
semantic_version.workspace = true
|
||||||
serde.workspace = true
|
serde.workspace = true
|
||||||
serde_derive.workspace = true
|
serde_derive.workspace = true
|
||||||
serde_json.workspace = true
|
serde_json.workspace = true
|
||||||
|
@ -53,10 +53,10 @@ pub use keystroke::*;
|
|||||||
pub(crate) use linux::*;
|
pub(crate) use linux::*;
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
pub(crate) use mac::*;
|
pub(crate) use mac::*;
|
||||||
|
pub use semantic_version::SemanticVersion;
|
||||||
#[cfg(any(test, feature = "test-support"))]
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
pub(crate) use test::*;
|
pub(crate) use test::*;
|
||||||
use time::UtcOffset;
|
use time::UtcOffset;
|
||||||
pub use util::SemanticVersion;
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
pub(crate) use windows::*;
|
pub(crate) use windows::*;
|
||||||
|
|
||||||
|
@ -353,19 +353,11 @@ impl Platform for LinuxPlatform {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn os_version(&self) -> Result<SemanticVersion> {
|
fn os_version(&self) -> Result<SemanticVersion> {
|
||||||
Ok(SemanticVersion {
|
Ok(SemanticVersion::new(1, 0, 0))
|
||||||
major: 1,
|
|
||||||
minor: 0,
|
|
||||||
patch: 0,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn app_version(&self) -> Result<SemanticVersion> {
|
fn app_version(&self) -> Result<SemanticVersion> {
|
||||||
Ok(SemanticVersion {
|
Ok(SemanticVersion::new(1, 0, 0))
|
||||||
major: 1,
|
|
||||||
minor: 0,
|
|
||||||
patch: 0,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn app_path(&self) -> Result<PathBuf> {
|
fn app_path(&self) -> Result<PathBuf> {
|
||||||
|
@ -718,11 +718,11 @@ impl Platform for MacPlatform {
|
|||||||
unsafe {
|
unsafe {
|
||||||
let process_info = NSProcessInfo::processInfo(nil);
|
let process_info = NSProcessInfo::processInfo(nil);
|
||||||
let version = process_info.operatingSystemVersion();
|
let version = process_info.operatingSystemVersion();
|
||||||
Ok(SemanticVersion {
|
Ok(SemanticVersion::new(
|
||||||
major: version.majorVersion as usize,
|
version.majorVersion as usize,
|
||||||
minor: version.minorVersion as usize,
|
version.minorVersion as usize,
|
||||||
patch: version.patchVersion as usize,
|
version.patchVersion as usize,
|
||||||
})
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,13 +12,14 @@ use std::{
|
|||||||
sync::{Arc, OnceLock},
|
sync::{Arc, OnceLock},
|
||||||
};
|
};
|
||||||
|
|
||||||
use ::util::{ResultExt, SemanticVersion};
|
use ::util::ResultExt;
|
||||||
use anyhow::{anyhow, Context, Result};
|
use anyhow::{anyhow, Context, Result};
|
||||||
use async_task::Runnable;
|
use async_task::Runnable;
|
||||||
use copypasta::{ClipboardContext, ClipboardProvider};
|
use copypasta::{ClipboardContext, ClipboardProvider};
|
||||||
use futures::channel::oneshot::{self, Receiver};
|
use futures::channel::oneshot::{self, Receiver};
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use parking_lot::{Mutex, RwLock};
|
use parking_lot::{Mutex, RwLock};
|
||||||
|
use semantic_version::SemanticVersion;
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use time::UtcOffset;
|
use time::UtcOffset;
|
||||||
use windows::{
|
use windows::{
|
||||||
@ -513,11 +514,11 @@ impl Platform for WindowsPlatform {
|
|||||||
let mut info = unsafe { std::mem::zeroed() };
|
let mut info = unsafe { std::mem::zeroed() };
|
||||||
let status = unsafe { RtlGetVersion(&mut info) };
|
let status = unsafe { RtlGetVersion(&mut info) };
|
||||||
if status.is_ok() {
|
if status.is_ok() {
|
||||||
Ok(SemanticVersion {
|
Ok(SemanticVersion::new(
|
||||||
major: info.dwMajorVersion as _,
|
info.dwMajorVersion as _,
|
||||||
minor: info.dwMinorVersion as _,
|
info.dwMinorVersion as _,
|
||||||
patch: info.dwBuildNumber as _,
|
info.dwBuildNumber as _,
|
||||||
})
|
))
|
||||||
} else {
|
} else {
|
||||||
Err(anyhow::anyhow!(
|
Err(anyhow::anyhow!(
|
||||||
"unable to get Windows version: {}",
|
"unable to get Windows version: {}",
|
||||||
@ -606,11 +607,11 @@ impl Platform for WindowsPlatform {
|
|||||||
let version_info = unsafe { &*(version_info_raw as *mut VS_FIXEDFILEINFO) };
|
let version_info = unsafe { &*(version_info_raw as *mut VS_FIXEDFILEINFO) };
|
||||||
// https://learn.microsoft.com/en-us/windows/win32/api/verrsrc/ns-verrsrc-vs_fixedfileinfo
|
// https://learn.microsoft.com/en-us/windows/win32/api/verrsrc/ns-verrsrc-vs_fixedfileinfo
|
||||||
if version_info.dwSignature == 0xFEEF04BD {
|
if version_info.dwSignature == 0xFEEF04BD {
|
||||||
return Ok(SemanticVersion {
|
return Ok(SemanticVersion::new(
|
||||||
major: ((version_info.dwProductVersionMS >> 16) & 0xFFFF) as usize,
|
((version_info.dwProductVersionMS >> 16) & 0xFFFF) as usize,
|
||||||
minor: (version_info.dwProductVersionMS & 0xFFFF) as usize,
|
(version_info.dwProductVersionMS & 0xFFFF) as usize,
|
||||||
patch: ((version_info.dwProductVersionLS >> 16) & 0xFFFF) as usize,
|
((version_info.dwProductVersionLS >> 16) & 0xFFFF) as usize,
|
||||||
});
|
));
|
||||||
} else {
|
} else {
|
||||||
log::error!(
|
log::error!(
|
||||||
"no version info present: {}",
|
"no version info present: {}",
|
||||||
|
16
crates/semantic_version/Cargo.toml
Normal file
16
crates/semantic_version/Cargo.toml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
[package]
|
||||||
|
name = "semantic_version"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
publish = false
|
||||||
|
license = "Apache-2.0"
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
path = "src/semantic_version.rs"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
anyhow.workspace = true
|
||||||
|
serde.workspace = true
|
1
crates/semantic_version/LICENSE-APACHE
Symbolic link
1
crates/semantic_version/LICENSE-APACHE
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../LICENSE-APACHE
|
@ -1,3 +1,7 @@
|
|||||||
|
//! Constructs for working with [semantic versions](https://semver.org/).
|
||||||
|
|
||||||
|
#![deny(missing_docs)]
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
fmt::{self, Display},
|
fmt::{self, Display},
|
||||||
str::FromStr,
|
str::FromStr,
|
||||||
@ -6,34 +10,46 @@ use std::{
|
|||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use serde::{de::Error, Deserialize, Serialize};
|
use serde::{de::Error, Deserialize, Serialize};
|
||||||
|
|
||||||
/// A datastructure representing a semantic version number
|
/// A [semantic version](https://semver.org/) number.
|
||||||
#[derive(Clone, Copy, Debug, Default, Eq, Ord, PartialEq, PartialOrd)]
|
#[derive(Clone, Copy, Debug, Default, Eq, Ord, PartialEq, PartialOrd)]
|
||||||
pub struct SemanticVersion {
|
pub struct SemanticVersion {
|
||||||
pub major: usize,
|
major: usize,
|
||||||
pub minor: usize,
|
minor: usize,
|
||||||
pub patch: usize,
|
patch: usize,
|
||||||
}
|
|
||||||
|
|
||||||
pub fn semver(major: usize, minor: usize, patch: usize) -> SemanticVersion {
|
|
||||||
SemanticVersion {
|
|
||||||
major,
|
|
||||||
minor,
|
|
||||||
patch,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SemanticVersion {
|
impl SemanticVersion {
|
||||||
pub fn new(major: usize, minor: usize, patch: usize) -> Self {
|
/// Returns a new [`SemanticVersion`] from the given components.
|
||||||
|
pub const fn new(major: usize, minor: usize, patch: usize) -> Self {
|
||||||
Self {
|
Self {
|
||||||
major,
|
major,
|
||||||
minor,
|
minor,
|
||||||
patch,
|
patch,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns the major version number.
|
||||||
|
#[inline(always)]
|
||||||
|
pub fn major(&self) -> usize {
|
||||||
|
self.major
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns the minor version number.
|
||||||
|
#[inline(always)]
|
||||||
|
pub fn minor(&self) -> usize {
|
||||||
|
self.minor
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns the patch version number.
|
||||||
|
#[inline(always)]
|
||||||
|
pub fn patch(&self) -> usize {
|
||||||
|
self.patch
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FromStr for SemanticVersion {
|
impl FromStr for SemanticVersion {
|
||||||
type Err = anyhow::Error;
|
type Err = anyhow::Error;
|
||||||
|
|
||||||
fn from_str(s: &str) -> Result<Self> {
|
fn from_str(s: &str) -> Result<Self> {
|
||||||
let mut components = s.trim().split('.');
|
let mut components = s.trim().split('.');
|
||||||
let major = components
|
let major = components
|
@ -12,5 +12,5 @@ workspace = true
|
|||||||
path = "src/telemetry_events.rs"
|
path = "src/telemetry_events.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
semantic_version.workspace = true
|
||||||
serde.workspace = true
|
serde.workspace = true
|
||||||
util.workspace = true
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
use semantic_version::SemanticVersion;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::{fmt::Display, sync::Arc};
|
use std::{fmt::Display, sync::Arc};
|
||||||
use util::SemanticVersion;
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
pub struct EventRequestBody {
|
pub struct EventRequestBody {
|
||||||
|
@ -3,14 +3,12 @@ pub mod fs;
|
|||||||
pub mod github;
|
pub mod github;
|
||||||
pub mod http;
|
pub mod http;
|
||||||
pub mod paths;
|
pub mod paths;
|
||||||
mod semantic_version;
|
|
||||||
#[cfg(any(test, feature = "test-support"))]
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
pub mod test;
|
pub mod test;
|
||||||
|
|
||||||
use futures::Future;
|
use futures::Future;
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use rand::{seq::SliceRandom, Rng};
|
use rand::{seq::SliceRandom, Rng};
|
||||||
pub use semantic_version::*;
|
|
||||||
use std::{
|
use std::{
|
||||||
borrow::Cow,
|
borrow::Cow,
|
||||||
cmp::{self, Ordering},
|
cmp::{self, Ordering},
|
||||||
|
Loading…
Reference in New Issue
Block a user