File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -239,6 +239,16 @@ module Action (Github_api : Api.Github) (Slack_api : Api.Slack) = struct
239
239
| None -> Lwt. return_none
240
240
| Some gh_link ->
241
241
match gh_link with
242
+ | Pull_request (repo , number ) ->
243
+ ( match % lwt Github_api. get_pull_request ~ctx ~repo ~number with
244
+ | Error _ -> Lwt. return_none
245
+ | Ok pr -> Lwt. return_some @@ (link, Slack_message. populate_pull_request repo pr)
246
+ )
247
+ | Issue (repo , number ) ->
248
+ ( match % lwt Github_api. get_issue ~ctx ~repo ~number with
249
+ | Error _ -> Lwt. return_none
250
+ | Ok issue -> Lwt. return_some @@ (link, Slack_message. populate_issue repo issue)
251
+ )
242
252
| Commit (repo , sha ) ->
243
253
( match % lwt Github_api. get_api_commit ~ctx ~repo ~sha with
244
254
| Error _ -> Lwt. return_none
Original file line number Diff line number Diff line change @@ -87,7 +87,10 @@ let parse_exn ~secret headers body =
87
87
| "member" | "create" | "delete" | "release" -> Event (event_notification_of_string body)
88
88
| event -> failwith @@ sprintf " unsupported event : %s" event
89
89
90
- type gh_link = Commit of repository * commit_hash
90
+ type gh_link =
91
+ | Pull_request of repository * int
92
+ | Issue of repository * int
93
+ | Commit of repository * commit_hash
91
94
92
95
(* * `gh_link_of_string s` parses a URL string `s` to try to match a supported
93
96
GitHub link type, generating repository endpoints if necessary *)
@@ -100,7 +103,7 @@ let gh_link_of_string url_str =
100
103
let custom_api_base ?(scheme = " https" ) base owner name =
101
104
sprintf " %s://%s/api/v3/repos/%s/%s" scheme base owner name
102
105
in
103
- let re = Re.Str. regexp {|^ \(.* \)/ \(.+ \)/ \(.+ \)/ \(commit\)/ \([a- z0-9 ]+ \)/?$| } in
106
+ let re = Re.Str. regexp {|^ \(.* \)/ \(.+ \)/ \(.+ \)/ \(commit\| pull\ | issues\ )/ \([a- z0-9 ]+ \)/?$| } in
104
107
match Uri. host url with
105
108
| None -> None
106
109
| Some host ->
@@ -131,6 +134,8 @@ let gh_link_of_string url_str =
131
134
begin
132
135
try
133
136
match link_type with
137
+ | "pull" -> Some (Pull_request (repo, Int. of_string item))
138
+ | "issues" -> Some (Issue (repo, Int. of_string item))
134
139
| "commit" -> Some (Commit (repo, item))
135
140
| _ -> None
136
141
with _ -> None
You can’t perform that action at this time.
0 commit comments