aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan <sentrycraft123@gmail.com>2023-07-20 14:02:46 +0200
committerGitHub <noreply@github.com>2023-07-20 14:02:46 +0200
commit99920002511676f55b8a45e51b5c735f50db4bd6 (patch)
treecd711195ea9781fb93ec0f2b67a8208cb61d0393
parent2c25450985e799d39481d29f4a78abcbae4ad6c4 (diff)
downloadFlightCore-99920002511676f55b8a45e51b5c735f50db4bd6.tar.gz
FlightCore-99920002511676f55b8a45e51b5c735f50db4bd6.zip
feat: Compare Flightcore versions as semver (#423)
development versions are checked with: current_version < newest_version release versions are checked with: current_version != newest_version
-rw-r--r--src-tauri/src/github/release_notes.rs15
1 files changed, 9 insertions, 6 deletions
diff --git a/src-tauri/src/github/release_notes.rs b/src-tauri/src/github/release_notes.rs
index 6db5b617..16b65183 100644
--- a/src-tauri/src/github/release_notes.rs
+++ b/src-tauri/src/github/release_notes.rs
@@ -58,14 +58,17 @@ pub async fn get_newest_flightcore_version() -> Result<FlightCoreVersion, String
#[tauri::command]
pub async fn check_is_flightcore_outdated() -> Result<bool, String> {
let newest_flightcore_release = get_newest_flightcore_version().await?;
+ // Parse version number excluding leading `v`
+ let newest_version = semver::Version::parse(&newest_flightcore_release.tag_name[1..]).unwrap();
- // Get version of installed FlightCore...
- let version = env!("CARGO_PKG_VERSION");
- // ...and format it
- let version = format!("v{}", version);
+ // Get version of installed FlightCore
+ let current_version = env!("CARGO_PKG_VERSION");
+ let current_version = semver::Version::parse(current_version).unwrap();
- // TODO: This shouldn't be a string compare but promper semver compare
- let is_outdated = version != newest_flightcore_release.tag_name;
+ #[cfg(debug_assertions)]
+ let is_outdated = current_version < newest_version;
+ #[cfg(not(debug_assertions))]
+ let is_outdated = current_version != newest_version;
// If outdated, check how new the update is
if is_outdated {