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:
Marshall Bowers 2024-03-29 12:11:57 -04:00 committed by GitHub
parent 77f1cc95b8
commit 16e6f5643c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
28 changed files with 147 additions and 110 deletions

View file

@ -14,11 +14,12 @@ use futures::{
use gpui::BackgroundExecutor;
use language::LanguageRegistry;
use node_runtime::NodeRuntime;
use semantic_version::SemanticVersion;
use std::{
path::{Path, PathBuf},
sync::{Arc, OnceLock},
};
use util::{http::HttpClient, SemanticVersion};
use util::http::HttpClient;
use wasmtime::{
component::{Component, ResourceTable},
Engine, Store,
@ -203,11 +204,11 @@ pub fn parse_wasm_extension_version(
fn parse_wasm_extension_version_custom_section(data: &[u8]) -> Option<SemanticVersion> {
if data.len() == 6 {
Some(SemanticVersion {
major: u16::from_be_bytes([data[0], data[1]]) as _,
minor: u16::from_be_bytes([data[2], data[3]]) as _,
patch: u16::from_be_bytes([data[4], data[5]]) as _,
})
Some(SemanticVersion::new(
u16::from_be_bytes([data[0], data[1]]) as _,
u16::from_be_bytes([data[2], data[3]]) as _,
u16::from_be_bytes([data[4], data[5]]) as _,
))
} else {
None
}