github webhook: For release events show actions and tag name.

This commit is contained in:
Brutus5000
2019-08-17 16:34:42 +02:00
committed by Tim Abbott
parent dac068df31
commit a386e3aebb
2 changed files with 5 additions and 3 deletions

View File

@@ -205,7 +205,7 @@ class GithubWebhookTest(WebhookTestCase):
self.send_and_test_stream_message('team_add', self.EXPECTED_TOPIC_REPO_EVENTS, expected_message) self.send_and_test_stream_message('team_add', self.EXPECTED_TOPIC_REPO_EVENTS, expected_message)
def test_release_msg(self) -> None: def test_release_msg(self) -> None:
expected_message = u"baxterthehacker published [the release](https://github.com/baxterthehacker/public-repo/releases/tag/0.0.1)." expected_message = u"baxterthehacker published [release for tag 0.0.1](https://github.com/baxterthehacker/public-repo/releases/tag/0.0.1)."
self.send_and_test_stream_message('release', self.EXPECTED_TOPIC_REPO_EVENTS, expected_message) self.send_and_test_stream_message('release', self.EXPECTED_TOPIC_REPO_EVENTS, expected_message)
def test_page_build_msg(self) -> None: def test_page_build_msg(self) -> None:

View File

@@ -236,8 +236,10 @@ def get_add_team_body(payload: Dict[str, Any]) -> str:
) )
def get_release_body(payload: Dict[str, Any]) -> str: def get_release_body(payload: Dict[str, Any]) -> str:
return u"{} published [the release]({}).".format( return u"{} {} [release for tag {}]({}).".format(
get_sender_name(payload), get_sender_name(payload),
payload['action'],
payload['release']['tag_name'],
payload['release']['html_url'], payload['release']['html_url'],
) )
@@ -502,7 +504,7 @@ def get_event(request: HttpRequest, payload: Dict[str, Any], branches: str) -> O
# Unsupported pull_request events # Unsupported pull_request events
if action in ('labeled', 'unlabeled', 'review_request_removed'): if action in ('labeled', 'unlabeled', 'review_request_removed'):
return None return None
if event == 'push': elif event == 'push':
if is_commit_push_event(payload): if is_commit_push_event(payload):
if branches is not None: if branches is not None:
branch = get_branch_name_from_ref(payload['ref']) branch = get_branch_name_from_ref(payload['ref'])