Skip to content

Commit bc0ee6d

Browse files
committed
upgrade and unlock ocamlformat
1 parent 89d6f8d commit bc0ee6d

File tree

9 files changed

+54
-28
lines changed

9 files changed

+54
-28
lines changed

.ocamlformat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version=0.13.0
1+
#version=0.19.0
22
break-cases=toplevel
33
break-infix-before-func=false
44
break-infix=fit-or-vertical

lib/action.ml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ module Action (Github_api : Api.Github) (Slack_api : Api.Slack) = struct
2222
|> List.filter ~f:(fun c ->
2323
let skip = Github.is_main_merge_message ~msg:c.message ~branch cfg in
2424
if skip then log#info "main branch merge, ignoring %s: %s" c.id (first_line c.message);
25-
not skip)
25+
not skip
26+
)
2627
|> List.concat_map ~f:(fun commit ->
2728
let rules = List.filter ~f:(filter_by_branch ~distinct:commit.distinct) rules in
2829
let matched_channel_names =
@@ -33,7 +34,8 @@ module Action (Github_api : Api.Github) (Slack_api : Api.Slack) = struct
3334
let channel_names =
3435
if List.is_empty matched_channel_names && commit.distinct then default else matched_channel_names
3536
in
36-
List.map channel_names ~f:(fun n -> n, commit))
37+
List.map channel_names ~f:(fun n -> n, commit)
38+
)
3739
|> Map.of_alist_multi (module String)
3840
|> Map.map ~f:(fun commits -> { n with commits })
3941
|> Map.to_alist
@@ -248,7 +250,8 @@ module Action (Github_api : Api.Github) (Slack_api : Api.Slack) = struct
248250
| Ok () -> Lwt.return_unit
249251
| Error msg ->
250252
log#warn "failed to save state file %s : %s" path msg;
251-
Lwt.return_unit)
253+
Lwt.return_unit
254+
)
252255
in
253256
Lwt.return_some user_id
254257
| Error msg ->

lib/mrkdwn.ml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ let escape_mrkdwn =
77
| '<' -> "&lt;"
88
| '>' -> "&gt;"
99
| '&' -> "&amp;"
10-
| c -> String.make 1 c)
10+
| c -> String.make 1 c
11+
)
1112

1213
(** Translates omd AST to a Slack mrkdwn string. Code heavily adapted
1314
from omd 1.3.1 source.
@@ -111,7 +112,8 @@ let rec mrkdwn_of_md md =
111112
add_spaces list_indent;
112113
Buffer.add_string b "- ";
113114
loop ~is_in_list:true (list_indent + 4) li;
114-
nl_if_needed_above b);
115+
nl_if_needed_above b
116+
);
115117
if list_indent = 0 then nl b;
116118
loop list_indent tl
117119
| Ol l ->
@@ -120,22 +122,25 @@ let rec mrkdwn_of_md md =
120122
add_spaces list_indent;
121123
Printf.bprintf b "%d. " (i + 1);
122124
loop ~is_in_list:true (list_indent + 4) li;
123-
nl_if_needed_above b);
125+
nl_if_needed_above b
126+
);
124127
if list_indent = 0 then nl b;
125128
loop list_indent tl
126129
| Ulp l ->
127130
List.iter l ~f:(fun li ->
128131
nl_if_needed_above b;
129132
add_spaces list_indent;
130133
Buffer.add_string b "- ";
131-
loop ~is_in_list:true (list_indent + 4) li (* Paragraphs => No need of '\n' *));
134+
loop ~is_in_list:true (list_indent + 4) li (* Paragraphs => No need of '\n' *)
135+
);
132136
loop list_indent tl
133137
| Olp l ->
134138
List.iteri l ~f:(fun i li ->
135139
nl_if_needed_above b;
136140
add_spaces list_indent;
137141
Printf.bprintf b "%d. " i;
138-
loop ~is_in_list:true (list_indent + 4) li (* Paragraphs => No need of '\n' *));
142+
loop ~is_in_list:true (list_indent + 4) li (* Paragraphs => No need of '\n' *)
143+
);
139144
loop list_indent tl
140145
| Code_block (_lang, c) ->
141146
(* unlike commonmark, can't have code block inside lists, so print code block with

lib/rule.ml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ module Prefix = struct
8989
| Some l, Some [] -> Stdio.printf " %s" (show_match l)
9090
| Some l, Some i -> Stdio.printf " %s and not %s" (show_match l) (show_match i)
9191
end;
92-
Stdio.printf " -> #%s\n%!" rule.channel_name)
92+
Stdio.printf " -> #%s\n%!" rule.channel_name
93+
)
9394
end
9495

9596
module Label = struct
@@ -124,5 +125,6 @@ module Label = struct
124125
| Some l, Some [] -> Stdio.printf " %s" (show_match l)
125126
| Some l, Some i -> Stdio.printf " %s and not %s" (show_match l) (show_match i)
126127
end;
127-
Stdio.printf " -> #%s\n%!" rule.channel_name)
128+
Stdio.printf " -> #%s\n%!" rule.channel_name
129+
)
128130
end

lib/slack.ml

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,14 @@ let generate_pull_request_notification notification channel =
4646
| _ ->
4747
invalid_arg
4848
(sprintf "Monorobot doesn't know how to generate notification for the unexpected event %s"
49-
(string_of_pr_action action))
49+
(string_of_pr_action action)
50+
)
5051
in
5152
let summary =
5253
Some
5354
(sprintf "<%s|[%s]> Pull request #%d <%s|%s> %s by *%s*" repository.url repository.full_name number html_url title
54-
action sender.login)
55+
action sender.login
56+
)
5557
in
5658
{
5759
channel;
@@ -86,12 +88,14 @@ let generate_pr_review_notification notification channel =
8688
| _ ->
8789
invalid_arg
8890
(sprintf "Monorobot doesn't know how to generate notification for the unexpected event %s"
89-
(string_of_pr_review_action action))
91+
(string_of_pr_review_action action)
92+
)
9093
in
9194
let summary =
9295
Some
9396
(sprintf "<%s|[%s]> *%s* <%s|%s> #%d <%s|%s>" repository.url repository.full_name sender.login review.html_url
94-
action_str number html_url title)
97+
action_str number html_url title
98+
)
9599
in
96100
{
97101
channel;
@@ -120,12 +124,14 @@ let generate_pr_review_comment_notification notification channel =
120124
| _ ->
121125
invalid_arg
122126
(sprintf "Monorobot doesn't know how to generate notification for the unexpected event %s"
123-
(string_of_comment_action action))
127+
(string_of_comment_action action)
128+
)
124129
in
125130
let summary =
126131
Some
127132
(sprintf "<%s|[%s]> *%s* %s on #%d <%s|%s>" repository.url repository.full_name sender.login action_str number
128-
html_url title)
133+
html_url title
134+
)
129135
in
130136
let file =
131137
match comment.path with
@@ -163,12 +169,14 @@ let generate_issue_notification notification channel =
163169
| _ ->
164170
invalid_arg
165171
(sprintf "Monorobot doesn't know how to generate notification for the unexpected event %s"
166-
(string_of_issue_action action))
172+
(string_of_issue_action action)
173+
)
167174
in
168175
let summary =
169176
Some
170177
(sprintf "<%s|[%s]> Issue #%d <%s|%s> %s by *%s*" repository.url repository.full_name number html_url title action
171-
sender.login)
178+
sender.login
179+
)
172180
in
173181
{
174182
channel;
@@ -198,12 +206,14 @@ let generate_issue_comment_notification notification channel =
198206
invalid_arg
199207
(sprintf
200208
"Monorobot doesn't know how to generate pull request review comment notification for the unexpected event %s"
201-
(string_of_comment_action action))
209+
(string_of_comment_action action)
210+
)
202211
in
203212
let summary =
204213
Some
205214
(sprintf "<%s|[%s]> *%s* <%s|%s> on #%d <%s|%s>" repository.url repository.full_name sender.login comment.html_url
206-
action_str number issue.html_url title)
215+
action_str number issue.html_url title
216+
)
207217
in
208218
{
209219
channel;
@@ -291,7 +301,8 @@ let generate_status_notification (cfg : Config_t.config) (notification : status_
291301
| _ ->
292302
invalid_arg
293303
(sprintf "Monorobot doesn't know how to generate notification for the unexpected event %s of %s"
294-
(string_of_status_state state) sha)
304+
(string_of_status_state state) sha
305+
)
295306
in
296307
let color_info =
297308
match state with
@@ -327,7 +338,8 @@ let generate_status_notification (cfg : Config_t.config) (notification : status_
327338
| Some t ->
328339
Some
329340
(sprintf "<%s|[%s]> CI Build Status notification for <%s|%s>: %s" repository.url repository.full_name t context
330-
state_info)
341+
state_info
342+
)
331343
in
332344
let msg = String.concat ~sep:"\n" @@ List.concat [ commit_info; branches_info ] in
333345
let attachment =
@@ -354,7 +366,8 @@ let generate_commit_comment_notification api_commit notification channel =
354366
let summary =
355367
Some
356368
(sprintf "<%s|[%s]> *%s* commented on `<%s|%s>` %s" repository.url repository.full_name sender.login
357-
comment.html_url (git_short_sha_hash commit_id) (first_line commit.message))
369+
comment.html_url (git_short_sha_hash commit_id) (first_line commit.message)
370+
)
358371
in
359372
let path =
360373
match comment.path with

lib/slack_message.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ let populate_pull_request repository (pull_request : pull_request) =
6262
merged;
6363
_;
6464
}
65-
: pull_request)
65+
: pull_request
66+
)
6667
=
6768
pull_request
6869
in

monorobot.opam

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ depends: [
2525
"re"
2626
"stdio"
2727
"uri"
28-
"ocamlformat" {dev & = "0.13.0"}
28+
"ocamlformat" {dev}
2929
"omd" {<= "1.3.1"}
3030
"yojson"
3131
]

src/request_handler.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ let setup_http ~ctx ~signature ~port ~ip =
5555
| Failure s -> s
5656
| Invalid_argument s -> s
5757
| exn -> Exn.str exn
58-
))
58+
)
59+
)
5960
in
6061
Lwt.return_unit
6162

test/test.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ let get_mock_payloads () =
1717
|> List.map ~f:(fun (kind, fn) ->
1818
let payload_path = Caml.Filename.concat mock_payload_dir fn in
1919
let state_path = Caml.Filename.concat mock_state_dir fn in
20-
if Caml.Sys.file_exists state_path then kind, payload_path, Some state_path else kind, payload_path, None)
20+
if Caml.Sys.file_exists state_path then kind, payload_path, Some state_path else kind, payload_path, None
21+
)
2122

2223
let process ~(ctx : Context.t) (kind, path, state_path) =
2324
let%lwt ctx =

0 commit comments

Comments
 (0)