Skip to content

Commit 3d4d997

Browse files
smimramtoots
andauthored
Fix parsing of rolling-release version. (#4294)
Co-authored-by: Romain Beauxis <toots@rastageeks.org>
1 parent 472f871 commit 3d4d997

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/lang/lang_string.ml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,11 +352,14 @@ module Version = struct
352352

353353
(* We assume something like, 2.0.0+git@7e211ffd *)
354354
let of_string s : t =
355-
let rex = Re.Pcre.regexp "([\\.\\d]+)([^\\.]+)?" in
355+
let rex = Re.Pcre.regexp "(?:rolling-release-v)?([\\.\\dx]+)([^\\.]+)?" in
356356
let sub = Re.Pcre.exec ~rex s in
357357
let num = Re.Pcre.get_substring sub 1 in
358358
let str = try Re.Pcre.get_substring sub 2 with _ -> "" in
359-
let num = String.split_on_char '.' num |> List.map int_of_string in
359+
let num =
360+
let int_of_string s = if s = "x" then max_int else int_of_string s in
361+
String.split_on_char '.' num |> List.map int_of_string
362+
in
360363
(num, str)
361364

362365
(** Number part. *)

tests/core/string_test.ml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
11
let () = assert ("aa\\\"bb" = Lang_string.escape_utf8_string "aa\"bb")
2+
3+
(* Bug #4287 *)
4+
let () =
5+
ignore (Lang_string.Version.of_string "rolling-release-v2.3.x+git@2addd93da")

0 commit comments

Comments
 (0)