webhooks/github: Fix repeating description for edits and updates.

This change updates the GitHub Integration webhook
get_opened_or_update_pull_request_body method so that
the description is only printed if it actually changes.
If the update event is a result of some other
attribute update, such as an asignee change, then the
description is not included in the message sent to
the zulip stream.

Fixes #16345
This commit is contained in:
cozyrohan
2020-11-23 00:15:42 -08:00
committed by Alex Vandiver
parent 6f31a2d49f
commit 16d1ab3d5f
4 changed files with 900 additions and 1 deletions

View File

@@ -251,6 +251,14 @@ class GitHubWebhookTest(WebhookTestCase):
expected_message = "baxterthehacker edited [PR #1](https://github.com/baxterthehacker/public-repo/pull/1) from `changes` to `master`."
self.check_webhook("pull_request__edited", TOPIC_PR, expected_message)
def test_pull_request_edited_with_body_change(self) -> None:
expected_message = "cozyrohan edited [PR #1](https://github.com/cozyrohan/public-repo/pull/1) from `issue-#1` to `main`:\n\n~~~ quote\nPR EDITED\n~~~"
self.check_webhook("pull_request__edited_with_body_change", TOPIC_PR, expected_message)
def test_pull_request_synchronized_with_body(self) -> None:
expected_message = "baxterthehacker updated [PR #1](https://github.com/baxterthehacker/public-repo/pull/1) from `changes` to `master`."
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."
self.check_webhook("pull_request__assigned", TOPIC_PR, expected_message)