diff --git a/zerver/tests/webhooks/test_beanstalk.py b/zerver/tests/webhooks/test_beanstalk.py index 20b3b36677..132df65ac4 100644 --- a/zerver/tests/webhooks/test_beanstalk.py +++ b/zerver/tests/webhooks/test_beanstalk.py @@ -8,7 +8,7 @@ class BeanstalkHookTests(WebhookTestCase): def test_git_single(self): # type: () -> None - expected_subject = "work-test" + expected_subject = "work-test / master" expected_message = """Leo Franchi [pushed](http://lfranchi-svn.beanstalkapp.com/work-test) to branch master * [e50508d](http://lfranchi-svn.beanstalkapp.com/work-test/changesets/e50508df): add some stuff @@ -19,7 +19,7 @@ class BeanstalkHookTests(WebhookTestCase): def test_git_multiple(self): # type: () -> None - expected_subject = "work-test" + expected_subject = "work-test / master" expected_message = """Leo Franchi [pushed](http://lfranchi-svn.beanstalkapp.com/work-test) to branch master * [edf529c](http://lfranchi-svn.beanstalkapp.com/work-test/changesets/edf529c7): Added new file diff --git a/zerver/tests/webhooks/test_github.py b/zerver/tests/webhooks/test_github.py index 9922b05618..056ca95b8a 100644 --- a/zerver/tests/webhooks/test_github.py +++ b/zerver/tests/webhooks/test_github.py @@ -61,19 +61,19 @@ class GithubV1HookTests(WebhookTestCase): def test_user_specified_branches(self): # type: () -> None - self.basic_test('push', 'my_commits', 'zulip-test', self.push_content, + self.basic_test('push', 'my_commits', 'zulip-test / master', self.push_content, send_stream=True, branches="master,staging") def test_user_specified_stream(self): # type: () -> None """Around May 2013 the github webhook started to specify the stream. Before then, the stream was hard coded to "commits".""" - self.basic_test('push', 'my_commits', 'zulip-test', self.push_content, + self.basic_test('push', 'my_commits', 'zulip-test / master', self.push_content, send_stream=True) def test_legacy_hook(self): # type: () -> None - self.basic_test('push', 'commits', 'zulip-test', self.push_content) + self.basic_test('push', 'commits', 'zulip-test / master', self.push_content) def test_issues_opened(self): # type: () -> None @@ -192,19 +192,19 @@ class GithubV2HookTests(WebhookTestCase): def test_user_specified_branches(self): # type: () -> None - self.basic_test('push', 'my_commits', 'zulip-test', self.push_content, + self.basic_test('push', 'my_commits', 'zulip-test / master', self.push_content, send_stream=True, branches="master,staging") def test_user_specified_stream(self): # type: () -> None """Around May 2013 the github webhook started to specify the stream. Before then, the stream was hard coded to "commits".""" - self.basic_test('push', 'my_commits', 'zulip-test', self.push_content, + self.basic_test('push', 'my_commits', 'zulip-test / master', self.push_content, send_stream=True) def test_legacy_hook(self): # type: () -> None - self.basic_test('push', 'commits', 'zulip-test', self.push_content) + self.basic_test('push', 'commits', 'zulip-test / master', self.push_content) def test_issues_opened(self): # type: () -> None diff --git a/zerver/views/webhooks/github.py b/zerver/views/webhooks/github.py index be476a42e9..bbe43dd251 100644 --- a/zerver/views/webhooks/github.py +++ b/zerver/views/webhooks/github.py @@ -5,7 +5,7 @@ from zerver.lib.response import json_success from zerver.lib.validator import check_dict from zerver.decorator import authenticated_api_view, REQ, has_request_variables, to_non_negative_int, flexible_boolean from zerver.views.messages import send_message_backend -from zerver.lib.webhooks.git import get_push_commits_event_message +from zerver.lib.webhooks.git import get_push_commits_event_message, SUBJECT_WITH_BRANCH_TEMPLATE import logging import re import ujson @@ -225,7 +225,7 @@ def api_github_landing(request, user_profile, event=REQ(), def build_message_from_gitlog(user_profile, name, ref, commits, before, after, url, pusher, forced=None, created=None): # type: (UserProfile, text_type, text_type, List[Dict[str, str]], text_type, text_type, text_type, text_type, Optional[text_type], Optional[text_type]) -> Tuple[text_type, text_type] short_ref = re.sub(r'^refs/heads/', '', ref) - subject = name + subject = SUBJECT_WITH_BRANCH_TEMPLATE.format(repo=name, branch=short_ref) if re.match(r'^0+$', after): content = u'%s deleted branch %s' % (pusher,