Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
webhooks/github: Include full repository name in notification messages.
Till Schneidereit6d6d43188da7
diff --git a/zerver/webhooks/github/tests.py b/zerver/webhooks/github/tests.pyindex 2ee58248613..cc80b8bfe0a 100644--- a/zerver/webhooks/github/tests.py+++ b/zerver/webhooks/github/tests.py@@ -21,7 +21,7 @@ class GithubWebhookTest(WebhookTestCase):self.send_and_test_stream_message('ping', self.EXPECTED_TOPIC_REPO_EVENTS, expected_message)def test_star_event(self) -> None:- expected_message = "Codertocat starred the repository."+ expected_message = "Codertocat starred the repository [Codertocat/Hello-World](https://github.com/Codertocat/Hello-World)."expected_topic = "Hello-World"self.send_and_test_stream_message('star', expected_topic, expected_message)@@ -182,7 +182,7 @@ class GithubWebhookTest(WebhookTestCase):self.send_and_test_stream_message('pull_request__merged', self.EXPECTED_TOPIC_PR_EVENTS, expected_message)def test_public_msg(self) -> None:- expected_message = "baxterthehacker made [the repository](https://github.com/baxterthehacker/public-repo) public."+ expected_message = "baxterthehacker made the repository [baxterthehacker/public-repo](https://github.com/baxterthehacker/public-repo) public."self.send_and_test_stream_message('public', self.EXPECTED_TOPIC_REPO_EVENTS, expected_message)def test_wiki_pages_msg(self) -> None:@@ -190,15 +190,15 @@ class GithubWebhookTest(WebhookTestCase):self.send_and_test_stream_message('gollum__wiki_pages', self.EXPECTED_TOPIC_WIKI_EVENTS, expected_message)def test_watch_msg(self) -> None:- expected_message = "baxterthehacker starred [the repository](https://github.com/baxterthehacker/public-repo)."+ expected_message = "baxterthehacker starred the repository [baxterthehacker/public-repo](https://github.com/baxterthehacker/public-repo)."self.send_and_test_stream_message('watch__repository', self.EXPECTED_TOPIC_REPO_EVENTS, expected_message)def test_repository_msg(self) -> None:- expected_message = "baxterthehacker created [the repository](https://github.com/baxterandthehackers/public-repo)."+ expected_message = "baxterthehacker created the repository [baxterandthehackers/public-repo](https://github.com/baxterandthehackers/public-repo)."self.send_and_test_stream_message('repository', self.EXPECTED_TOPIC_REPO_EVENTS, expected_message)def test_team_add_msg(self) -> None:- expected_message = "[The repository](https://github.com/baxterandthehackers/public-repo) was added to team github."+ expected_message = "The repository [baxterandthehackers/public-repo](https://github.com/baxterandthehackers/public-repo) was added to team github."self.send_and_test_stream_message('team_add', self.EXPECTED_TOPIC_REPO_EVENTS, expected_message)def test_release_msg(self) -> None:diff --git a/zerver/webhooks/github/view.py b/zerver/webhooks/github/view.pyindex 2c80fe859d6..29d95f20d8a 100644--- a/zerver/webhooks/github/view.py+++ b/zerver/webhooks/github/view.py@@ -207,8 +207,9 @@ def get_push_commits_body(payload: Dict[str, Any]) -> str:)def get_public_body(payload: Dict[str, Any]) -> str:- return "{} made [the repository]({}) public.".format(+ return "{} made the repository [{}]({}) public.".format(get_sender_name(payload),+ get_repository_full_name(payload),payload['repository']['html_url'],)@@ -224,20 +225,23 @@ def get_wiki_pages_body(payload: Dict[str, Any]) -> str:return f"{get_sender_name(payload)}:\n{wiki_info.rstrip()}"def get_watch_body(payload: Dict[str, Any]) -> str:- return "{} starred [the repository]({}).".format(+ return "{} starred the repository [{}]({}).".format(get_sender_name(payload),+ get_repository_full_name(payload),payload['repository']['html_url'],)def get_repository_body(payload: Dict[str, Any]) -> str:- return "{} {} [the repository]({}).".format(+ return "{} {} the repository [{}]({}).".format(get_sender_name(payload),payload.get('action'),+ get_repository_full_name(payload),payload['repository']['html_url'],)def get_add_team_body(payload: Dict[str, Any]) -> str:- return "[The repository]({}) was added to team {}.".format(+ return "The repository [{}]({}) was added to team {}.".format(+ get_repository_full_name(payload),payload['repository']['html_url'],payload['team']['name'],)@@ -407,10 +411,12 @@ Check [{name}]({html_url}) {status} ({conclusion}). ([{short_hash}]({commit_url}return template.format(**kwargs)def get_star_body(payload: Dict[str, Any]) -> str:- template = "{user} {action} the repository."+ template = "{user} {action} the repository [{repo}]({url})."return template.format(user=payload['sender']['login'],action='starred' if payload['action'] == 'created' else 'unstarred',+ repo=get_repository_full_name(payload),+ url=payload['repository']['html_url'],)def get_ping_body(payload: Dict[str, Any]) -> str:@@ -419,6 +425,9 @@ def get_ping_body(payload: Dict[str, Any]) -> str:def get_repository_name(payload: Dict[str, Any]) -> str:return payload['repository']['name']+def get_repository_full_name(payload: Dict[str, Any]) -> str:+ return payload['repository']['full_name']+def get_organization_name(payload: Dict[str, Any]) -> str:return payload['organization']['login']