mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 06:53:25 +00:00
webhooks: Add support for a GitHub push event deleting a branch.
Fixes: #4742.
This commit is contained in:
130
zerver/webhooks/github_webhook/fixtures/push_delete_branch.json
Normal file
130
zerver/webhooks/github_webhook/fixtures/push_delete_branch.json
Normal file
@@ -0,0 +1,130 @@
|
||||
{
|
||||
"ref":"refs/heads/feature",
|
||||
"before":"2e8cf535fb38a3dab2476cdf856efda904ad4c94",
|
||||
"after":"0000000000000000000000000000000000000000",
|
||||
"created":false,
|
||||
"deleted":true,
|
||||
"forced":false,
|
||||
"base_ref":null,
|
||||
"compare":"https://github.com/eeshangarg/public-repo/compare/2e8cf535fb38...000000000000",
|
||||
"commits":[
|
||||
|
||||
],
|
||||
"head_commit":null,
|
||||
"repository":{
|
||||
"id":89799239,
|
||||
"name":"public-repo",
|
||||
"full_name":"eeshangarg/public-repo",
|
||||
"owner":{
|
||||
"name":"eeshangarg",
|
||||
"email":"jerryguitarist@gmail.com",
|
||||
"login":"eeshangarg",
|
||||
"id":7251823,
|
||||
"avatar_url":"https://avatars3.githubusercontent.com/u/7251823?v=3",
|
||||
"gravatar_id":"",
|
||||
"url":"https://api.github.com/users/eeshangarg",
|
||||
"html_url":"https://github.com/eeshangarg",
|
||||
"followers_url":"https://api.github.com/users/eeshangarg/followers",
|
||||
"following_url":"https://api.github.com/users/eeshangarg/following{/other_user}",
|
||||
"gists_url":"https://api.github.com/users/eeshangarg/gists{/gist_id}",
|
||||
"starred_url":"https://api.github.com/users/eeshangarg/starred{/owner}{/repo}",
|
||||
"subscriptions_url":"https://api.github.com/users/eeshangarg/subscriptions",
|
||||
"organizations_url":"https://api.github.com/users/eeshangarg/orgs",
|
||||
"repos_url":"https://api.github.com/users/eeshangarg/repos",
|
||||
"events_url":"https://api.github.com/users/eeshangarg/events{/privacy}",
|
||||
"received_events_url":"https://api.github.com/users/eeshangarg/received_events",
|
||||
"type":"User",
|
||||
"site_admin":false
|
||||
},
|
||||
"private":false,
|
||||
"html_url":"https://github.com/eeshangarg/public-repo",
|
||||
"description":null,
|
||||
"fork":false,
|
||||
"url":"https://github.com/eeshangarg/public-repo",
|
||||
"forks_url":"https://api.github.com/repos/eeshangarg/public-repo/forks",
|
||||
"keys_url":"https://api.github.com/repos/eeshangarg/public-repo/keys{/key_id}",
|
||||
"collaborators_url":"https://api.github.com/repos/eeshangarg/public-repo/collaborators{/collaborator}",
|
||||
"teams_url":"https://api.github.com/repos/eeshangarg/public-repo/teams",
|
||||
"hooks_url":"https://api.github.com/repos/eeshangarg/public-repo/hooks",
|
||||
"issue_events_url":"https://api.github.com/repos/eeshangarg/public-repo/issues/events{/number}",
|
||||
"events_url":"https://api.github.com/repos/eeshangarg/public-repo/events",
|
||||
"assignees_url":"https://api.github.com/repos/eeshangarg/public-repo/assignees{/user}",
|
||||
"branches_url":"https://api.github.com/repos/eeshangarg/public-repo/branches{/branch}",
|
||||
"tags_url":"https://api.github.com/repos/eeshangarg/public-repo/tags",
|
||||
"blobs_url":"https://api.github.com/repos/eeshangarg/public-repo/git/blobs{/sha}",
|
||||
"git_tags_url":"https://api.github.com/repos/eeshangarg/public-repo/git/tags{/sha}",
|
||||
"git_refs_url":"https://api.github.com/repos/eeshangarg/public-repo/git/refs{/sha}",
|
||||
"trees_url":"https://api.github.com/repos/eeshangarg/public-repo/git/trees{/sha}",
|
||||
"statuses_url":"https://api.github.com/repos/eeshangarg/public-repo/statuses/{sha}",
|
||||
"languages_url":"https://api.github.com/repos/eeshangarg/public-repo/languages",
|
||||
"stargazers_url":"https://api.github.com/repos/eeshangarg/public-repo/stargazers",
|
||||
"contributors_url":"https://api.github.com/repos/eeshangarg/public-repo/contributors",
|
||||
"subscribers_url":"https://api.github.com/repos/eeshangarg/public-repo/subscribers",
|
||||
"subscription_url":"https://api.github.com/repos/eeshangarg/public-repo/subscription",
|
||||
"commits_url":"https://api.github.com/repos/eeshangarg/public-repo/commits{/sha}",
|
||||
"git_commits_url":"https://api.github.com/repos/eeshangarg/public-repo/git/commits{/sha}",
|
||||
"comments_url":"https://api.github.com/repos/eeshangarg/public-repo/comments{/number}",
|
||||
"issue_comment_url":"https://api.github.com/repos/eeshangarg/public-repo/issues/comments{/number}",
|
||||
"contents_url":"https://api.github.com/repos/eeshangarg/public-repo/contents/{+path}",
|
||||
"compare_url":"https://api.github.com/repos/eeshangarg/public-repo/compare/{base}...{head}",
|
||||
"merges_url":"https://api.github.com/repos/eeshangarg/public-repo/merges",
|
||||
"archive_url":"https://api.github.com/repos/eeshangarg/public-repo/{archive_format}{/ref}",
|
||||
"downloads_url":"https://api.github.com/repos/eeshangarg/public-repo/downloads",
|
||||
"issues_url":"https://api.github.com/repos/eeshangarg/public-repo/issues{/number}",
|
||||
"pulls_url":"https://api.github.com/repos/eeshangarg/public-repo/pulls{/number}",
|
||||
"milestones_url":"https://api.github.com/repos/eeshangarg/public-repo/milestones{/number}",
|
||||
"notifications_url":"https://api.github.com/repos/eeshangarg/public-repo/notifications{?since,all,participating}",
|
||||
"labels_url":"https://api.github.com/repos/eeshangarg/public-repo/labels{/name}",
|
||||
"releases_url":"https://api.github.com/repos/eeshangarg/public-repo/releases{/id}",
|
||||
"deployments_url":"https://api.github.com/repos/eeshangarg/public-repo/deployments",
|
||||
"created_at":1493484776,
|
||||
"updated_at":"2017-04-29T16:52:56Z",
|
||||
"pushed_at":1494897868,
|
||||
"git_url":"git://github.com/eeshangarg/public-repo.git",
|
||||
"ssh_url":"git@github.com:eeshangarg/public-repo.git",
|
||||
"clone_url":"https://github.com/eeshangarg/public-repo.git",
|
||||
"svn_url":"https://github.com/eeshangarg/public-repo",
|
||||
"homepage":null,
|
||||
"size":0,
|
||||
"stargazers_count":0,
|
||||
"watchers_count":0,
|
||||
"language":null,
|
||||
"has_issues":true,
|
||||
"has_projects":true,
|
||||
"has_downloads":true,
|
||||
"has_wiki":true,
|
||||
"has_pages":false,
|
||||
"forks_count":0,
|
||||
"mirror_url":null,
|
||||
"open_issues_count":0,
|
||||
"forks":0,
|
||||
"open_issues":0,
|
||||
"watchers":0,
|
||||
"default_branch":"changes",
|
||||
"stargazers":0,
|
||||
"master_branch":"changes"
|
||||
},
|
||||
"pusher":{
|
||||
"name":"eeshangarg",
|
||||
"email":"jerryguitarist@gmail.com"
|
||||
},
|
||||
"sender":{
|
||||
"login":"eeshangarg",
|
||||
"id":7251823,
|
||||
"avatar_url":"https://avatars3.githubusercontent.com/u/7251823?v=3",
|
||||
"gravatar_id":"",
|
||||
"url":"https://api.github.com/users/eeshangarg",
|
||||
"html_url":"https://github.com/eeshangarg",
|
||||
"followers_url":"https://api.github.com/users/eeshangarg/followers",
|
||||
"following_url":"https://api.github.com/users/eeshangarg/following{/other_user}",
|
||||
"gists_url":"https://api.github.com/users/eeshangarg/gists{/gist_id}",
|
||||
"starred_url":"https://api.github.com/users/eeshangarg/starred{/owner}{/repo}",
|
||||
"subscriptions_url":"https://api.github.com/users/eeshangarg/subscriptions",
|
||||
"organizations_url":"https://api.github.com/users/eeshangarg/orgs",
|
||||
"repos_url":"https://api.github.com/users/eeshangarg/repos",
|
||||
"events_url":"https://api.github.com/users/eeshangarg/events{/privacy}",
|
||||
"received_events_url":"https://api.github.com/users/eeshangarg/received_events",
|
||||
"type":"User",
|
||||
"site_admin":false
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,11 @@ class GithubWebhookTest(WebhookTestCase):
|
||||
expected_message = u"GitHub webhook has been successfully configured by TomaszKolek"
|
||||
self.send_and_test_stream_message('ping', self.EXPECTED_SUBJECT_REPO_EVENTS, expected_message, HTTP_X_GITHUB_EVENT='ping')
|
||||
|
||||
def test_push_delete_branch(self):
|
||||
# type: () -> None
|
||||
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_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))"
|
||||
|
||||
@@ -190,7 +190,8 @@ def get_push_commits_body(payload):
|
||||
get_sender_name(payload),
|
||||
payload['compare'],
|
||||
get_branch_name_from_ref(payload['ref']),
|
||||
commits_data
|
||||
commits_data,
|
||||
deleted=payload['deleted']
|
||||
)
|
||||
|
||||
def get_public_body(payload):
|
||||
|
||||
Reference in New Issue
Block a user