Skip to content

Commit

Permalink
Fix parsing of rolling-release version. (#4294)
Browse files Browse the repository at this point in the history
Co-authored-by: Romain Beauxis <toots@rastageeks.org>
  • Loading branch information
smimram and toots authored Jan 1, 2025
1 parent 472f871 commit 3d4d997
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/lang/lang_string.ml
Original file line number Diff line number Diff line change
Expand Up @@ -352,11 +352,14 @@ module Version = struct

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

(** Number part. *)
Expand Down
4 changes: 4 additions & 0 deletions tests/core/string_test.ml
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
let () = assert ("aa\\\"bb" = Lang_string.escape_utf8_string "aa\"bb")

(* Bug #4287 *)
let () =
ignore (Lang_string.Version.of_string "rolling-release-v2.3.x+git@2addd93da")

0 comments on commit 3d4d997

Please sign in to comment.