@@ -16,7 +16,7 @@ pub fn parse_godot_version(version_str: &str) -> Result<GodotVersion, Box<dyn Er
16
16
// https://github.com/godot-rust/gdext/issues/118#issuecomment-1465748123
17
17
// We assume that it's on a line of its own, but it may be surrounded by other lines.
18
18
let regex = Regex :: new (
19
- r# "(?xm)
19
+ r"(?xm)
20
20
# x: ignore whitespace and allow line comments (starting with `#`)
21
21
# m: multi-line mode, ^ and $ match start and end of line
22
22
^
@@ -32,15 +32,17 @@ pub fn parse_godot_version(version_str: &str) -> Result<GodotVersion, Box<dyn Er
32
32
(\.[^.]+)+?
33
33
# Git commit SHA1, currently truncated to 9 chars, but accept the full thing
34
34
(?:\.(?P<custom_rev>[a-f0-9]{9,40}))?
35
+ # Optional newline printed in some systems (e.g. Arch Linux, see #416)
36
+ (?:\\n)?
35
37
$
36
- "# ,
38
+ " ,
37
39
) ?;
38
40
39
41
let fail = || format ! ( "Version substring cannot be parsed: `{version_str}`" ) ;
40
42
let caps = regex. captures ( version_str) . ok_or_else ( fail) ?;
41
43
42
44
Ok ( GodotVersion {
43
- full_string : caps. get ( 0 ) . unwrap ( ) . as_str ( ) . to_string ( ) ,
45
+ full_string : caps. get ( 0 ) . unwrap ( ) . as_str ( ) . trim ( ) . to_string ( ) ,
44
46
major : cap ( & caps, "major" ) ?. unwrap ( ) ,
45
47
minor : cap ( & caps, "minor" ) ?. unwrap ( ) ,
46
48
patch : cap ( & caps, "patch" ) ?. unwrap_or ( 0 ) ,
@@ -86,6 +88,7 @@ fn test_godot_versions() {
86
88
( "4.0.beta8.mono.custom_build.b28ddd918" , 4 , 0 , 0 , "beta8" , s ( "b28ddd918" ) ) ,
87
89
( "4.0.rc1.official.8843d9ad3" , 4 , 0 , 0 , "rc1" , s ( "8843d9ad3" ) ) ,
88
90
( "4.0.stable.arch_linux" , 4 , 0 , 0 , "stable" , None ) ,
91
+ ( "4.1.1.stable.arch_linux\n " , 4 , 1 , 1 , "stable" , None ) ,
89
92
// Output from 4.0.stable on MacOS in debug mode:
90
93
// https://github.com/godotengine/godot/issues/74906
91
94
( "arguments
@@ -104,7 +107,7 @@ Current path: /Users/runner/work/gdext/gdext/godot-core
104
107
for ( full, major, minor, patch, status, custom_rev) in good_versions {
105
108
let expected = GodotVersion {
106
109
// Version line is last in every test at the moment.
107
- full_string : full. lines ( ) . last ( ) . unwrap ( ) . to_owned ( ) ,
110
+ full_string : full. lines ( ) . last ( ) . unwrap ( ) . trim ( ) . to_owned ( ) ,
108
111
major,
109
112
minor,
110
113
patch,
0 commit comments