Skip to content

Commit 89d6f8d

Browse files
committed
slack: distinguish PR merge vs close
"If the action is closed and the merged key is false, the pull request was closed with unmerged commits. If the action is closed and the merged key is true, the pull request was merged." https://docs.github.com/en/[email protected]/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#pull_request
1 parent 2bcad1d commit 89d6f8d

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lib/slack.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ let pluralize name num suffix = if num = 1 then sprintf "%s" name else String.co
3636

3737
let generate_pull_request_notification notification channel =
3838
let { action; number; sender; pull_request; repository } = notification in
39-
let ({ body; title; html_url; labels; _ } : pull_request) = pull_request in
39+
let ({ body; title; html_url; labels; merged; _ } : pull_request) = pull_request in
4040
let action, body =
4141
match action with
4242
| Opened -> "opened", Some body
43-
| Closed -> "closed", None
43+
| Closed -> (if merged then "merged" else "closed"), None
4444
| Reopened -> "reopened", None
4545
| Labeled -> "labeled", show_labels labels
4646
| _ ->

test/slack_payloads.expected

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,11 +286,11 @@ will notify #default
286286
"attachments": [
287287
{
288288
"fallback":
289-
"<https://github.com/xinyuluo/monorepo|[xinyuluo/monorepo]> Pull request #2 <https://github.com/xinyuluo/monorepo/pull/2|Update README.md> closed by *xinyuluo*",
289+
"<https://github.com/xinyuluo/monorepo|[xinyuluo/monorepo]> Pull request #2 <https://github.com/xinyuluo/monorepo/pull/2|Update README.md> merged by *xinyuluo*",
290290
"mrkdwn_in": [ "text" ],
291291
"color": "#ccc",
292292
"pretext":
293-
"<https://github.com/xinyuluo/monorepo|[xinyuluo/monorepo]> Pull request #2 <https://github.com/xinyuluo/monorepo/pull/2|Update README.md> closed by *xinyuluo*"
293+
"<https://github.com/xinyuluo/monorepo|[xinyuluo/monorepo]> Pull request #2 <https://github.com/xinyuluo/monorepo/pull/2|Update README.md> merged by *xinyuluo*"
294294
}
295295
]
296296
}

0 commit comments

Comments
 (0)