integrations: Improve GitHub force push notifications.

Previously, we didn't explicitly display something special for force-pushes.

Fixes #21969.
This commit is contained in:
sbansal1999
2023-05-04 20:42:59 +05:30
committed by Tim Abbott
parent dba6f84b97
commit 2a3d4041e0
3 changed files with 12 additions and 6 deletions

View File

@@ -38,11 +38,11 @@ class GitHubWebhookTest(WebhookTestCase):
self.check_webhook("push__delete_branch", "public-repo / feature", expected_message)
def test_push_force_1_commit(self) -> None:
expected_message = "sbansal1999 [pushed](https://github.com/sbansal1999/zulip/compare/b6de8891fc10...971d76ca3094) 1 commit to branch temp.\n\n* log: Add important.txt which is useful for logging errors. ([971d76ca309](https://github.com/sbansal1999/zulip/commit/971d76ca309446a9c20381f6271cea8a59b4e40a))"
expected_message = "sbansal1999 [force pushed](https://github.com/sbansal1999/zulip/compare/b6de8891fc10...971d76ca3094) 1 commit to branch temp.\n\n* log: Add important.txt which is useful for logging errors. ([971d76ca309](https://github.com/sbansal1999/zulip/commit/971d76ca309446a9c20381f6271cea8a59b4e40a))"
self.check_webhook("push__force_1_commit", "zulip / temp", expected_message)
def test_push__force_remove_commits(self) -> None:
expected_message = "sbansal1999 [pushed](https://github.com/sbansal1999/zulip/compare/2084a91af9ca...9a8749ea8fe7) the branch temp."
expected_message = "sbansal1999 [force pushed](https://github.com/sbansal1999/zulip/compare/2084a91af9ca...9a8749ea8fe7) the branch temp."
self.check_webhook("push__force_remove_commits", "zulip / temp", expected_message)
def test_push_local_branch_without_commits(self) -> None:

View File

@@ -283,6 +283,7 @@ def get_push_commits_body(helper: Helper) -> str:
get_branch_name_from_ref(payload["ref"].tame(check_string)),
commits_data,
deleted=payload["deleted"].tame(check_bool),
force_push=payload["forced"].tame(check_bool),
)