File tree Expand file tree Collapse file tree 3 files changed +12
-5
lines changed Expand file tree Collapse file tree 3 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,14 @@ module StringMap = struct
15
15
let unwrap = to_list
16
16
end
17
17
18
+ module Re2 = struct
19
+ include Re2
20
+
21
+ let wrap s = create_exn s
22
+
23
+ let unwrap = Re2. to_string
24
+ end
25
+
18
26
let fmt_error fmt = Printf. ksprintf (fun s -> Error s) fmt
19
27
20
28
let first_line s =
Original file line number Diff line number Diff line change
1
+ type regex = string wrap <ocaml module="Common.Re2">
2
+
1
3
(* Text fields from the GitHub payload that can be used in a condition *)
2
4
type comparable_field = [
3
5
| Context <json name="context">
@@ -8,7 +10,7 @@ type comparable_field = [
8
10
(* Checks whether a payload field matches the provided regex pattern *)
9
11
type match_condition = {
10
12
field : comparable_field;
11
- re : string; (* expects a regex pattern *)
13
+ re : regex;
12
14
}
13
15
14
16
(* Specifies additional conditions the payload must meet for the status rule to match *)
Original file line number Diff line number Diff line change @@ -21,10 +21,7 @@ module Status = struct
21
21
| Target_url -> notification.target_url
22
22
in
23
23
let rec match_condition = function
24
- | Match { field; re } ->
25
- value_of_field field
26
- |> Option. map ~f: (fun f -> Re.Str. string_match (Re.Str. regexp_case_fold re) f 0 )
27
- |> Option. value ~default: false
24
+ | Match { field; re } -> value_of_field field |> Option. map ~f: (Re2. matches re) |> Option. value ~default: false
28
25
| All_of conditions -> List. for_all conditions ~f: match_condition
29
26
| One_of conditions -> List. exists conditions ~f: match_condition
30
27
| Not condition -> not @@ match_condition condition
You can’t perform that action at this time.
0 commit comments