From a4d1211ec6928b0a126e905e218c2c56f336df7b Mon Sep 17 00:00:00 2001 From: Lauryn Menard Date: Wed, 22 Nov 2023 16:33:57 +0100 Subject: [PATCH] integrations: Reformat Github pull request assigned message body. Instead of adding the assignee to the end of the message body, we update the message body where the verb is so that the link formatting at the end of the message is not broken, for example: "user_a assigned user_b to [issue #XXX title text is here](link)." This matches the formatting for the issue assigned message body. --- zerver/webhooks/github/tests.py | 4 ++-- zerver/webhooks/github/view.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/zerver/webhooks/github/tests.py b/zerver/webhooks/github/tests.py index 83df42c6c3..4547ac23aa 100644 --- a/zerver/webhooks/github/tests.py +++ b/zerver/webhooks/github/tests.py @@ -375,13 +375,13 @@ class GitHubWebhookTest(WebhookTestCase): self.check_webhook("pull_request__synchronized_with_body", TOPIC_PR, expected_message) def test_pull_request_assigned_msg(self) -> None: - expected_message = "baxterthehacker assigned [PR #1](https://github.com/baxterthehacker/public-repo/pull/1) to baxterthehacker." + expected_message = "baxterthehacker assigned baxterthehacker to [PR #1](https://github.com/baxterthehacker/public-repo/pull/1)." self.check_webhook("pull_request__assigned", TOPIC_PR, expected_message) def test_pull_request_assigned_msg_with_custom_topic_in_url(self) -> None: self.url = self.build_webhook_url(topic="notifications") expected_topic = "notifications" - expected_message = "baxterthehacker assigned [PR #1 Update the README with new information](https://github.com/baxterthehacker/public-repo/pull/1) to baxterthehacker." + expected_message = "baxterthehacker assigned baxterthehacker to [PR #1 Update the README with new information](https://github.com/baxterthehacker/public-repo/pull/1)." self.check_webhook("pull_request__assigned", expected_topic, expected_message) def test_pull_request_unassigned_msg(self) -> None: diff --git a/zerver/webhooks/github/view.py b/zerver/webhooks/github/view.py index b144f840af..fdd1d3e063 100644 --- a/zerver/webhooks/github/view.py +++ b/zerver/webhooks/github/view.py @@ -104,7 +104,7 @@ def get_assigned_or_unassigned_pull_request_body(helper: Helper) -> str: title=pull_request["title"].tame(check_string) if include_title else None, ) if assignee: - return f"{base_message[:-1]} to {stringified_assignee}." + return base_message.replace("assigned", f"assigned {stringified_assignee} to", 1) return base_message