Skip to content

Commit 7488b2e

Browse files
committed
Fix Godot version regex parsing
1 parent 36bbd66 commit 7488b2e

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

godot-codegen/src/godot_version.rs

+3-9
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,11 @@ pub struct GodotVersion {
2828

2929
pub fn parse_godot_version(version_str: &str) -> Result<GodotVersion, Box<dyn Error>> {
3030
let regex = Regex::new(
31-
r#"(\d+)\.(\d+)(?:\.(\d+))?\.(alpha|beta|dev|stable)[0-9]*\.(?:mono)\.(?:(?:official|custom_build)\.([a-f0-9]+)|official)"#,
31+
r#"(\d+)\.(\d+)(?:\.(\d+))?\.(alpha|beta|dev|stable)[0-9]*\.(?:mono\.)?(?:(?:official|custom_build)\.([a-f0-9]+)|official)"#,
3232
)?;
3333

34-
let caps = regex.captures(version_str).ok_or("Regex capture failed")?;
35-
36-
let fail = || {
37-
format!(
38-
"Version substring could not be matched in '{}'",
39-
version_str
40-
)
41-
};
34+
let fail = || format!("Version substring cannot be parsed: `{}`", version_str);
35+
let caps = regex.captures(version_str).ok_or_else(fail)?;
4236

4337
Ok(GodotVersion {
4438
full_string: caps.get(0).unwrap().as_str().to_string(),

0 commit comments

Comments
 (0)