Loosen Lune version string requirements (#294)

This commit is contained in:
Micah 2025-03-24 11:24:36 -07:00 committed by GitHub
parent 5d1401cdf6
commit 19e7f57284
Signed by: DevComp
GPG key ID: B5690EEEBB952194
3 changed files with 8 additions and 7 deletions

3
Cargo.lock generated
View file

@ -1,6 +1,6 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
version = 4
[[package]]
name = "addr2line"
@ -1716,6 +1716,7 @@ dependencies = [
"once_cell",
"path-clean",
"pathdiff",
"semver 1.0.23",
"tokio",
]

View file

@ -22,3 +22,4 @@ dunce = "1.0"
once_cell = "1.17"
path-clean = "1.0"
pathdiff = "0.2"
semver = "1.0"

View file

@ -2,6 +2,7 @@ use std::sync::Arc;
use mlua::prelude::*;
use once_cell::sync::Lazy;
use semver::Version;
static LUAU_VERSION: Lazy<Arc<String>> = Lazy::new(create_luau_version_string);
@ -20,12 +21,10 @@ pub fn get_version_string(lune_version: impl AsRef<str>) -> String {
let lune_version = lune_version.as_ref();
assert!(!lune_version.is_empty(), "Lune version string is empty");
assert!(
lune_version.chars().all(is_valid_version_char),
"Lune version string contains invalid characters"
);
format!("Lune {lune_version}+{}", *LUAU_VERSION)
match Version::parse(lune_version) {
Ok(semver) => format!("Lune {semver}+{}", *LUAU_VERSION),
Err(e) => panic!("Lune version string is not valid semver: {e}"),
}
}
fn create_luau_version_string() -> Arc<String> {