webhooks/github*: Support pushing a local branch without commits.

Changes made to get_push_commits_event_message in
zerver/lib/webhooks/git.py are common to all Git integrations
that use get_push_commits_event_message. These include github,
github_webhook, gitlab, gogs, bitbucket, bitbucket2. In some
cases (for instance, gitlab), no further changes to gitlab/view.py
will be required to support pushing a local branch without commits;
adding a fixture and tests should suffice.
This commit is contained in:
Eeshan Garg
2017-05-16 21:49:33 -02:30
parent 7a545eeb13
commit 5687b2cdc5
3 changed files with 168 additions and 0 deletions

View File

@@ -28,6 +28,11 @@ class GithubWebhookTest(WebhookTestCase):
expected_message = u"eeshangarg [deleted](https://github.com/eeshangarg/public-repo/compare/2e8cf535fb38...000000000000) the branch feature."
self.send_and_test_stream_message('push_delete_branch', u"public-repo / feature", expected_message, HTTP_X_GITHUB_EVENT='push')
def test_push_local_branch_without_commits(self):
# type: () -> None
expected_message = u"eeshangarg [pushed](https://github.com/eeshangarg/public-repo/compare/feature) the branch feature."
self.send_and_test_stream_message('push_local_branch_without_commits', u"public-repo / feature", expected_message, HTTP_X_GITHUB_EVENT='push')
def test_push_1_commit(self):
# type: () -> None
expected_message = u"baxterthehacker [pushed](https://github.com/baxterthehacker/public-repo/compare/9049f1265b7d...0d1a26e67d8f) 1 commit to branch changes.\n\n* Update README.md ([0d1a26e](https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c))"