Added supported for GitHub pull request comments.

This commit is contained in:
chhsia0
2019-10-26 09:59:57 -07:00
parent 2845fba51e
commit 3007a7f5c2
4 changed files with 235 additions and 11 deletions
+1 -1
View File
@@ -47,7 +47,7 @@ const (
MemberEvent Event = "member"
MembershipEvent Event = "membership"
MilestoneEvent Event = "milestone"
MetaEvent Event = "meta"
MetaEvent Event = "meta"
OrganizationEvent Event = "organization"
OrgBlockEvent Event = "org_block"
PageBuildEvent Event = "page_build"
+10
View File
@@ -273,6 +273,16 @@ func TestWebhooks(t *testing.T) {
"X-Hub-Signature": []string{"sha1=e724c9f811fcf5f511aac32e4251b08ab1a0fd87"},
},
},
{
name: "PullRequestIssueCommentEvent",
event: IssueCommentEvent,
typ: IssueCommentPayload{},
filename: "../testdata/github/pull-request-issue-comment.json",
headers: http.Header{
"X-Github-Event": []string{"issue_comment"},
"X-Hub-Signature": []string{"sha1=6c969b99ef881b5c98b2dbfc66a34465fcf0e7d4"},
},
},
{
name: "IssuesEvent",
event: IssuesEvent,
+16 -10
View File
@@ -1614,16 +1614,22 @@ type IssueCommentPayload struct {
Color string `json:"color"`
Default bool `json:"default"`
} `json:"labels"`
State string `json:"state"`
Locked bool `json:"locked"`
Assignee *Assignee `json:"assignee"`
Assignees []*Assignee `json:"assignees"`
Milestone *Milestone `json:"milestone"`
Comments int64 `json:"comments"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
ClosedAt *time.Time `json:"closed_at"`
Body string `json:"body"`
State string `json:"state"`
Locked bool `json:"locked"`
Assignee *Assignee `json:"assignee"`
Assignees []*Assignee `json:"assignees"`
Milestone *Milestone `json:"milestone"`
Comments int64 `json:"comments"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
ClosedAt *time.Time `json:"closed_at"`
PullRequest *struct {
URL string `json:"url"`
HTMLURL string `json:"html_url"`
DiffURL string `json:"diff_url"`
PatchURL string `json:"patch_url"`
} `json:"pull_request"`
Body string `json:"body"`
} `json:"issue"`
Comment struct {
URL string `json:"url"`
+208
View File
@@ -0,0 +1,208 @@
{
"action": "created",
"issue": {
"url": "https://api.github.com/repos/chhsia0/knative-route-demo/issues/3",
"repository_url": "https://api.github.com/repos/chhsia0/knative-route-demo",
"labels_url": "https://api.github.com/repos/chhsia0/knative-route-demo/issues/3/labels{/name}",
"comments_url": "https://api.github.com/repos/chhsia0/knative-route-demo/issues/3/comments",
"events_url": "https://api.github.com/repos/chhsia0/knative-route-demo/issues/3/events",
"html_url": "https://github.com/chhsia0/knative-route-demo/pull/3",
"id": 494965988,
"node_id": "MDExOlB1bGxSZXF1ZXN0MzE4NjEwOTI3",
"number": 3,
"title": "Updated to v2.",
"user": {
"login": "chhsia0",
"id": 4643017,
"node_id": "MDQ6VXNlcjQ2NDMwMTc=",
"avatar_url": "https://avatars0.githubusercontent.com/u/4643017?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/chhsia0",
"html_url": "https://github.com/chhsia0",
"followers_url": "https://api.github.com/users/chhsia0/followers",
"following_url": "https://api.github.com/users/chhsia0/following{/other_user}",
"gists_url": "https://api.github.com/users/chhsia0/gists{/gist_id}",
"starred_url": "https://api.github.com/users/chhsia0/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/chhsia0/subscriptions",
"organizations_url": "https://api.github.com/users/chhsia0/orgs",
"repos_url": "https://api.github.com/users/chhsia0/repos",
"events_url": "https://api.github.com/users/chhsia0/events{/privacy}",
"received_events_url": "https://api.github.com/users/chhsia0/received_events",
"type": "User",
"site_admin": false
},
"labels": [
],
"state": "open",
"locked": false,
"assignee": null,
"assignees": [
],
"milestone": null,
"comments": 17,
"created_at": "2019-09-18T03:28:04Z",
"updated_at": "2019-10-26T16:09:23Z",
"closed_at": null,
"author_association": "OWNER",
"pull_request": {
"url": "https://api.github.com/repos/chhsia0/knative-route-demo/pulls/3",
"html_url": "https://github.com/chhsia0/knative-route-demo/pull/3",
"diff_url": "https://github.com/chhsia0/knative-route-demo/pull/3.diff",
"patch_url": "https://github.com/chhsia0/knative-route-demo/pull/3.patch"
},
"body": ""
},
"comment": {
"url": "https://api.github.com/repos/chhsia0/knative-route-demo/issues/comments/546616131",
"html_url": "https://github.com/chhsia0/knative-route-demo/pull/3#issuecomment-546616131",
"issue_url": "https://api.github.com/repos/chhsia0/knative-route-demo/issues/3",
"id": 546616131,
"node_id": "MDEyOklzc3VlQ29tbWVudDU0NjYxNjEzMQ==",
"user": {
"login": "chhsia0",
"id": 4643017,
"node_id": "MDQ6VXNlcjQ2NDMwMTc=",
"avatar_url": "https://avatars0.githubusercontent.com/u/4643017?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/chhsia0",
"html_url": "https://github.com/chhsia0",
"followers_url": "https://api.github.com/users/chhsia0/followers",
"following_url": "https://api.github.com/users/chhsia0/following{/other_user}",
"gists_url": "https://api.github.com/users/chhsia0/gists{/gist_id}",
"starred_url": "https://api.github.com/users/chhsia0/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/chhsia0/subscriptions",
"organizations_url": "https://api.github.com/users/chhsia0/orgs",
"repos_url": "https://api.github.com/users/chhsia0/repos",
"events_url": "https://api.github.com/users/chhsia0/events{/privacy}",
"received_events_url": "https://api.github.com/users/chhsia0/received_events",
"type": "User",
"site_admin": false
},
"created_at": "2019-10-26T16:09:23Z",
"updated_at": "2019-10-26T16:09:23Z",
"author_association": "OWNER",
"body": "/build"
},
"repository": {
"id": 199540710,
"node_id": "MDEwOlJlcG9zaXRvcnkxOTk1NDA3MTA=",
"name": "knative-route-demo",
"full_name": "chhsia0/knative-route-demo",
"private": false,
"owner": {
"login": "chhsia0",
"id": 4643017,
"node_id": "MDQ6VXNlcjQ2NDMwMTc=",
"avatar_url": "https://avatars0.githubusercontent.com/u/4643017?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/chhsia0",
"html_url": "https://github.com/chhsia0",
"followers_url": "https://api.github.com/users/chhsia0/followers",
"following_url": "https://api.github.com/users/chhsia0/following{/other_user}",
"gists_url": "https://api.github.com/users/chhsia0/gists{/gist_id}",
"starred_url": "https://api.github.com/users/chhsia0/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/chhsia0/subscriptions",
"organizations_url": "https://api.github.com/users/chhsia0/orgs",
"repos_url": "https://api.github.com/users/chhsia0/repos",
"events_url": "https://api.github.com/users/chhsia0/events{/privacy}",
"received_events_url": "https://api.github.com/users/chhsia0/received_events",
"type": "User",
"site_admin": false
},
"html_url": "https://github.com/chhsia0/knative-route-demo",
"description": "Simple knative route demo",
"fork": true,
"url": "https://api.github.com/repos/chhsia0/knative-route-demo",
"forks_url": "https://api.github.com/repos/chhsia0/knative-route-demo/forks",
"keys_url": "https://api.github.com/repos/chhsia0/knative-route-demo/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/chhsia0/knative-route-demo/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/chhsia0/knative-route-demo/teams",
"hooks_url": "https://api.github.com/repos/chhsia0/knative-route-demo/hooks",
"issue_events_url": "https://api.github.com/repos/chhsia0/knative-route-demo/issues/events{/number}",
"events_url": "https://api.github.com/repos/chhsia0/knative-route-demo/events",
"assignees_url": "https://api.github.com/repos/chhsia0/knative-route-demo/assignees{/user}",
"branches_url": "https://api.github.com/repos/chhsia0/knative-route-demo/branches{/branch}",
"tags_url": "https://api.github.com/repos/chhsia0/knative-route-demo/tags",
"blobs_url": "https://api.github.com/repos/chhsia0/knative-route-demo/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/chhsia0/knative-route-demo/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/chhsia0/knative-route-demo/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/chhsia0/knative-route-demo/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/chhsia0/knative-route-demo/statuses/{sha}",
"languages_url": "https://api.github.com/repos/chhsia0/knative-route-demo/languages",
"stargazers_url": "https://api.github.com/repos/chhsia0/knative-route-demo/stargazers",
"contributors_url": "https://api.github.com/repos/chhsia0/knative-route-demo/contributors",
"subscribers_url": "https://api.github.com/repos/chhsia0/knative-route-demo/subscribers",
"subscription_url": "https://api.github.com/repos/chhsia0/knative-route-demo/subscription",
"commits_url": "https://api.github.com/repos/chhsia0/knative-route-demo/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/chhsia0/knative-route-demo/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/chhsia0/knative-route-demo/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/chhsia0/knative-route-demo/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/chhsia0/knative-route-demo/contents/{+path}",
"compare_url": "https://api.github.com/repos/chhsia0/knative-route-demo/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/chhsia0/knative-route-demo/merges",
"archive_url": "https://api.github.com/repos/chhsia0/knative-route-demo/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/chhsia0/knative-route-demo/downloads",
"issues_url": "https://api.github.com/repos/chhsia0/knative-route-demo/issues{/number}",
"pulls_url": "https://api.github.com/repos/chhsia0/knative-route-demo/pulls{/number}",
"milestones_url": "https://api.github.com/repos/chhsia0/knative-route-demo/milestones{/number}",
"notifications_url": "https://api.github.com/repos/chhsia0/knative-route-demo/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/chhsia0/knative-route-demo/labels{/name}",
"releases_url": "https://api.github.com/repos/chhsia0/knative-route-demo/releases{/id}",
"deployments_url": "https://api.github.com/repos/chhsia0/knative-route-demo/deployments",
"created_at": "2019-07-29T23:38:07Z",
"updated_at": "2019-10-01T18:07:59Z",
"pushed_at": "2019-10-23T23:49:38Z",
"git_url": "git://github.com/chhsia0/knative-route-demo.git",
"ssh_url": "git@github.com:chhsia0/knative-route-demo.git",
"clone_url": "https://github.com/chhsia0/knative-route-demo.git",
"svn_url": "https://github.com/chhsia0/knative-route-demo",
"homepage": "",
"size": 59,
"stargazers_count": 0,
"watchers_count": 0,
"language": "Go",
"has_issues": true,
"has_projects": true,
"has_downloads": true,
"has_wiki": false,
"has_pages": true,
"forks_count": 0,
"mirror_url": null,
"archived": false,
"disabled": false,
"open_issues_count": 3,
"license": {
"key": "apache-2.0",
"name": "Apache License 2.0",
"spdx_id": "Apache-2.0",
"url": "https://api.github.com/licenses/apache-2.0",
"node_id": "MDc6TGljZW5zZTI="
},
"forks": 0,
"open_issues": 3,
"watchers": 0,
"default_branch": "master"
},
"sender": {
"login": "chhsia0",
"id": 4643017,
"node_id": "MDQ6VXNlcjQ2NDMwMTc=",
"avatar_url": "https://avatars0.githubusercontent.com/u/4643017?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/chhsia0",
"html_url": "https://github.com/chhsia0",
"followers_url": "https://api.github.com/users/chhsia0/followers",
"following_url": "https://api.github.com/users/chhsia0/following{/other_user}",
"gists_url": "https://api.github.com/users/chhsia0/gists{/gist_id}",
"starred_url": "https://api.github.com/users/chhsia0/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/chhsia0/subscriptions",
"organizations_url": "https://api.github.com/users/chhsia0/orgs",
"repos_url": "https://api.github.com/users/chhsia0/repos",
"events_url": "https://api.github.com/users/chhsia0/events{/privacy}",
"received_events_url": "https://api.github.com/users/chhsia0/received_events",
"type": "User",
"site_admin": false
}
}