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
28 changed files with 147 additions and 110 deletions
|
@ -12,13 +12,14 @@ use std::{
|
|||
sync::{Arc, OnceLock},
|
||||
};
|
||||
|
||||
use ::util::{ResultExt, SemanticVersion};
|
||||
use ::util::ResultExt;
|
||||
use anyhow::{anyhow, Context, Result};
|
||||
use async_task::Runnable;
|
||||
use copypasta::{ClipboardContext, ClipboardProvider};
|
||||
use futures::channel::oneshot::{self, Receiver};
|
||||
use itertools::Itertools;
|
||||
use parking_lot::{Mutex, RwLock};
|
||||
use semantic_version::SemanticVersion;
|
||||
use smallvec::SmallVec;
|
||||
use time::UtcOffset;
|
||||
use windows::{
|
||||
|
@ -513,11 +514,11 @@ impl Platform for WindowsPlatform {
|
|||
let mut info = unsafe { std::mem::zeroed() };
|
||||
let status = unsafe { RtlGetVersion(&mut info) };
|
||||
if status.is_ok() {
|
||||
Ok(SemanticVersion {
|
||||
major: info.dwMajorVersion as _,
|
||||
minor: info.dwMinorVersion as _,
|
||||
patch: info.dwBuildNumber as _,
|
||||
})
|
||||
Ok(SemanticVersion::new(
|
||||
info.dwMajorVersion as _,
|
||||
info.dwMinorVersion as _,
|
||||
info.dwBuildNumber as _,
|
||||
))
|
||||
} else {
|
||||
Err(anyhow::anyhow!(
|
||||
"unable to get Windows version: {}",
|
||||
|
@ -606,11 +607,11 @@ impl Platform for WindowsPlatform {
|
|||
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
|
||||
if version_info.dwSignature == 0xFEEF04BD {
|
||||
return Ok(SemanticVersion {
|
||||
major: ((version_info.dwProductVersionMS >> 16) & 0xFFFF) as usize,
|
||||
minor: (version_info.dwProductVersionMS & 0xFFFF) as usize,
|
||||
patch: ((version_info.dwProductVersionLS >> 16) & 0xFFFF) as usize,
|
||||
});
|
||||
return Ok(SemanticVersion::new(
|
||||
((version_info.dwProductVersionMS >> 16) & 0xFFFF) as usize,
|
||||
(version_info.dwProductVersionMS & 0xFFFF) as usize,
|
||||
((version_info.dwProductVersionLS >> 16) & 0xFFFF) as usize,
|
||||
));
|
||||
} else {
|
||||
log::error!(
|
||||
"no version info present: {}",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue