Skip to content

Commit cb4aa3d

Browse files
author
Dean Karn
authored
Merge pull request #96 from chhsia0/github-pr-comment
Added supported for GitHub pull request comments.
2 parents 334436b + 3007a7f commit cb4aa3d

File tree

4 files changed

+235
-11
lines changed

4 files changed

+235
-11
lines changed

github/github.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const (
4747
MemberEvent Event = "member"
4848
MembershipEvent Event = "membership"
4949
MilestoneEvent Event = "milestone"
50-
MetaEvent Event = "meta"
50+
MetaEvent Event = "meta"
5151
OrganizationEvent Event = "organization"
5252
OrgBlockEvent Event = "org_block"
5353
PageBuildEvent Event = "page_build"

github/github_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,16 @@ func TestWebhooks(t *testing.T) {
273273
"X-Hub-Signature": []string{"sha1=e724c9f811fcf5f511aac32e4251b08ab1a0fd87"},
274274
},
275275
},
276+
{
277+
name: "PullRequestIssueCommentEvent",
278+
event: IssueCommentEvent,
279+
typ: IssueCommentPayload{},
280+
filename: "../testdata/github/pull-request-issue-comment.json",
281+
headers: http.Header{
282+
"X-Github-Event": []string{"issue_comment"},
283+
"X-Hub-Signature": []string{"sha1=6c969b99ef881b5c98b2dbfc66a34465fcf0e7d4"},
284+
},
285+
},
276286
{
277287
name: "IssuesEvent",
278288
event: IssuesEvent,

github/payload.go

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,16 +1614,22 @@ type IssueCommentPayload struct {
16141614
Color string `json:"color"`
16151615
Default bool `json:"default"`
16161616
} `json:"labels"`
1617-
State string `json:"state"`
1618-
Locked bool `json:"locked"`
1619-
Assignee *Assignee `json:"assignee"`
1620-
Assignees []*Assignee `json:"assignees"`
1621-
Milestone *Milestone `json:"milestone"`
1622-
Comments int64 `json:"comments"`
1623-
CreatedAt time.Time `json:"created_at"`
1624-
UpdatedAt time.Time `json:"updated_at"`
1625-
ClosedAt *time.Time `json:"closed_at"`
1626-
Body string `json:"body"`
1617+
State string `json:"state"`
1618+
Locked bool `json:"locked"`
1619+
Assignee *Assignee `json:"assignee"`
1620+
Assignees []*Assignee `json:"assignees"`
1621+
Milestone *Milestone `json:"milestone"`
1622+
Comments int64 `json:"comments"`
1623+
CreatedAt time.Time `json:"created_at"`
1624+
UpdatedAt time.Time `json:"updated_at"`
1625+
ClosedAt *time.Time `json:"closed_at"`
1626+
PullRequest *struct {
1627+
URL string `json:"url"`
1628+
HTMLURL string `json:"html_url"`
1629+
DiffURL string `json:"diff_url"`
1630+
PatchURL string `json:"patch_url"`
1631+
} `json:"pull_request"`
1632+
Body string `json:"body"`
16271633
} `json:"issue"`
16281634
Comment struct {
16291635
URL string `json:"url"`
Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
{
2+
"action": "created",
3+
"issue": {
4+
"url": "https://api.github.com/repos/chhsia0/knative-route-demo/issues/3",
5+
"repository_url": "https://api.github.com/repos/chhsia0/knative-route-demo",
6+
"labels_url": "https://api.github.com/repos/chhsia0/knative-route-demo/issues/3/labels{/name}",
7+
"comments_url": "https://api.github.com/repos/chhsia0/knative-route-demo/issues/3/comments",
8+
"events_url": "https://api.github.com/repos/chhsia0/knative-route-demo/issues/3/events",
9+
"html_url": "https://github.com/chhsia0/knative-route-demo/pull/3",
10+
"id": 494965988,
11+
"node_id": "MDExOlB1bGxSZXF1ZXN0MzE4NjEwOTI3",
12+
"number": 3,
13+
"title": "Updated to v2.",
14+
"user": {
15+
"login": "chhsia0",
16+
"id": 4643017,
17+
"node_id": "MDQ6VXNlcjQ2NDMwMTc=",
18+
"avatar_url": "https://avatars0.githubusercontent.com/u/4643017?v=4",
19+
"gravatar_id": "",
20+
"url": "https://api.github.com/users/chhsia0",
21+
"html_url": "https://github.com/chhsia0",
22+
"followers_url": "https://api.github.com/users/chhsia0/followers",
23+
"following_url": "https://api.github.com/users/chhsia0/following{/other_user}",
24+
"gists_url": "https://api.github.com/users/chhsia0/gists{/gist_id}",
25+
"starred_url": "https://api.github.com/users/chhsia0/starred{/owner}{/repo}",
26+
"subscriptions_url": "https://api.github.com/users/chhsia0/subscriptions",
27+
"organizations_url": "https://api.github.com/users/chhsia0/orgs",
28+
"repos_url": "https://api.github.com/users/chhsia0/repos",
29+
"events_url": "https://api.github.com/users/chhsia0/events{/privacy}",
30+
"received_events_url": "https://api.github.com/users/chhsia0/received_events",
31+
"type": "User",
32+
"site_admin": false
33+
},
34+
"labels": [
35+
36+
],
37+
"state": "open",
38+
"locked": false,
39+
"assignee": null,
40+
"assignees": [
41+
42+
],
43+
"milestone": null,
44+
"comments": 17,
45+
"created_at": "2019-09-18T03:28:04Z",
46+
"updated_at": "2019-10-26T16:09:23Z",
47+
"closed_at": null,
48+
"author_association": "OWNER",
49+
"pull_request": {
50+
"url": "https://api.github.com/repos/chhsia0/knative-route-demo/pulls/3",
51+
"html_url": "https://github.com/chhsia0/knative-route-demo/pull/3",
52+
"diff_url": "https://github.com/chhsia0/knative-route-demo/pull/3.diff",
53+
"patch_url": "https://github.com/chhsia0/knative-route-demo/pull/3.patch"
54+
},
55+
"body": ""
56+
},
57+
"comment": {
58+
"url": "https://api.github.com/repos/chhsia0/knative-route-demo/issues/comments/546616131",
59+
"html_url": "https://github.com/chhsia0/knative-route-demo/pull/3#issuecomment-546616131",
60+
"issue_url": "https://api.github.com/repos/chhsia0/knative-route-demo/issues/3",
61+
"id": 546616131,
62+
"node_id": "MDEyOklzc3VlQ29tbWVudDU0NjYxNjEzMQ==",
63+
"user": {
64+
"login": "chhsia0",
65+
"id": 4643017,
66+
"node_id": "MDQ6VXNlcjQ2NDMwMTc=",
67+
"avatar_url": "https://avatars0.githubusercontent.com/u/4643017?v=4",
68+
"gravatar_id": "",
69+
"url": "https://api.github.com/users/chhsia0",
70+
"html_url": "https://github.com/chhsia0",
71+
"followers_url": "https://api.github.com/users/chhsia0/followers",
72+
"following_url": "https://api.github.com/users/chhsia0/following{/other_user}",
73+
"gists_url": "https://api.github.com/users/chhsia0/gists{/gist_id}",
74+
"starred_url": "https://api.github.com/users/chhsia0/starred{/owner}{/repo}",
75+
"subscriptions_url": "https://api.github.com/users/chhsia0/subscriptions",
76+
"organizations_url": "https://api.github.com/users/chhsia0/orgs",
77+
"repos_url": "https://api.github.com/users/chhsia0/repos",
78+
"events_url": "https://api.github.com/users/chhsia0/events{/privacy}",
79+
"received_events_url": "https://api.github.com/users/chhsia0/received_events",
80+
"type": "User",
81+
"site_admin": false
82+
},
83+
"created_at": "2019-10-26T16:09:23Z",
84+
"updated_at": "2019-10-26T16:09:23Z",
85+
"author_association": "OWNER",
86+
"body": "/build"
87+
},
88+
"repository": {
89+
"id": 199540710,
90+
"node_id": "MDEwOlJlcG9zaXRvcnkxOTk1NDA3MTA=",
91+
"name": "knative-route-demo",
92+
"full_name": "chhsia0/knative-route-demo",
93+
"private": false,
94+
"owner": {
95+
"login": "chhsia0",
96+
"id": 4643017,
97+
"node_id": "MDQ6VXNlcjQ2NDMwMTc=",
98+
"avatar_url": "https://avatars0.githubusercontent.com/u/4643017?v=4",
99+
"gravatar_id": "",
100+
"url": "https://api.github.com/users/chhsia0",
101+
"html_url": "https://github.com/chhsia0",
102+
"followers_url": "https://api.github.com/users/chhsia0/followers",
103+
"following_url": "https://api.github.com/users/chhsia0/following{/other_user}",
104+
"gists_url": "https://api.github.com/users/chhsia0/gists{/gist_id}",
105+
"starred_url": "https://api.github.com/users/chhsia0/starred{/owner}{/repo}",
106+
"subscriptions_url": "https://api.github.com/users/chhsia0/subscriptions",
107+
"organizations_url": "https://api.github.com/users/chhsia0/orgs",
108+
"repos_url": "https://api.github.com/users/chhsia0/repos",
109+
"events_url": "https://api.github.com/users/chhsia0/events{/privacy}",
110+
"received_events_url": "https://api.github.com/users/chhsia0/received_events",
111+
"type": "User",
112+
"site_admin": false
113+
},
114+
"html_url": "https://github.com/chhsia0/knative-route-demo",
115+
"description": "Simple knative route demo",
116+
"fork": true,
117+
"url": "https://api.github.com/repos/chhsia0/knative-route-demo",
118+
"forks_url": "https://api.github.com/repos/chhsia0/knative-route-demo/forks",
119+
"keys_url": "https://api.github.com/repos/chhsia0/knative-route-demo/keys{/key_id}",
120+
"collaborators_url": "https://api.github.com/repos/chhsia0/knative-route-demo/collaborators{/collaborator}",
121+
"teams_url": "https://api.github.com/repos/chhsia0/knative-route-demo/teams",
122+
"hooks_url": "https://api.github.com/repos/chhsia0/knative-route-demo/hooks",
123+
"issue_events_url": "https://api.github.com/repos/chhsia0/knative-route-demo/issues/events{/number}",
124+
"events_url": "https://api.github.com/repos/chhsia0/knative-route-demo/events",
125+
"assignees_url": "https://api.github.com/repos/chhsia0/knative-route-demo/assignees{/user}",
126+
"branches_url": "https://api.github.com/repos/chhsia0/knative-route-demo/branches{/branch}",
127+
"tags_url": "https://api.github.com/repos/chhsia0/knative-route-demo/tags",
128+
"blobs_url": "https://api.github.com/repos/chhsia0/knative-route-demo/git/blobs{/sha}",
129+
"git_tags_url": "https://api.github.com/repos/chhsia0/knative-route-demo/git/tags{/sha}",
130+
"git_refs_url": "https://api.github.com/repos/chhsia0/knative-route-demo/git/refs{/sha}",
131+
"trees_url": "https://api.github.com/repos/chhsia0/knative-route-demo/git/trees{/sha}",
132+
"statuses_url": "https://api.github.com/repos/chhsia0/knative-route-demo/statuses/{sha}",
133+
"languages_url": "https://api.github.com/repos/chhsia0/knative-route-demo/languages",
134+
"stargazers_url": "https://api.github.com/repos/chhsia0/knative-route-demo/stargazers",
135+
"contributors_url": "https://api.github.com/repos/chhsia0/knative-route-demo/contributors",
136+
"subscribers_url": "https://api.github.com/repos/chhsia0/knative-route-demo/subscribers",
137+
"subscription_url": "https://api.github.com/repos/chhsia0/knative-route-demo/subscription",
138+
"commits_url": "https://api.github.com/repos/chhsia0/knative-route-demo/commits{/sha}",
139+
"git_commits_url": "https://api.github.com/repos/chhsia0/knative-route-demo/git/commits{/sha}",
140+
"comments_url": "https://api.github.com/repos/chhsia0/knative-route-demo/comments{/number}",
141+
"issue_comment_url": "https://api.github.com/repos/chhsia0/knative-route-demo/issues/comments{/number}",
142+
"contents_url": "https://api.github.com/repos/chhsia0/knative-route-demo/contents/{+path}",
143+
"compare_url": "https://api.github.com/repos/chhsia0/knative-route-demo/compare/{base}...{head}",
144+
"merges_url": "https://api.github.com/repos/chhsia0/knative-route-demo/merges",
145+
"archive_url": "https://api.github.com/repos/chhsia0/knative-route-demo/{archive_format}{/ref}",
146+
"downloads_url": "https://api.github.com/repos/chhsia0/knative-route-demo/downloads",
147+
"issues_url": "https://api.github.com/repos/chhsia0/knative-route-demo/issues{/number}",
148+
"pulls_url": "https://api.github.com/repos/chhsia0/knative-route-demo/pulls{/number}",
149+
"milestones_url": "https://api.github.com/repos/chhsia0/knative-route-demo/milestones{/number}",
150+
"notifications_url": "https://api.github.com/repos/chhsia0/knative-route-demo/notifications{?since,all,participating}",
151+
"labels_url": "https://api.github.com/repos/chhsia0/knative-route-demo/labels{/name}",
152+
"releases_url": "https://api.github.com/repos/chhsia0/knative-route-demo/releases{/id}",
153+
"deployments_url": "https://api.github.com/repos/chhsia0/knative-route-demo/deployments",
154+
"created_at": "2019-07-29T23:38:07Z",
155+
"updated_at": "2019-10-01T18:07:59Z",
156+
"pushed_at": "2019-10-23T23:49:38Z",
157+
"git_url": "git://github.com/chhsia0/knative-route-demo.git",
158+
"ssh_url": "[email protected]:chhsia0/knative-route-demo.git",
159+
"clone_url": "https://github.com/chhsia0/knative-route-demo.git",
160+
"svn_url": "https://github.com/chhsia0/knative-route-demo",
161+
"homepage": "",
162+
"size": 59,
163+
"stargazers_count": 0,
164+
"watchers_count": 0,
165+
"language": "Go",
166+
"has_issues": true,
167+
"has_projects": true,
168+
"has_downloads": true,
169+
"has_wiki": false,
170+
"has_pages": true,
171+
"forks_count": 0,
172+
"mirror_url": null,
173+
"archived": false,
174+
"disabled": false,
175+
"open_issues_count": 3,
176+
"license": {
177+
"key": "apache-2.0",
178+
"name": "Apache License 2.0",
179+
"spdx_id": "Apache-2.0",
180+
"url": "https://api.github.com/licenses/apache-2.0",
181+
"node_id": "MDc6TGljZW5zZTI="
182+
},
183+
"forks": 0,
184+
"open_issues": 3,
185+
"watchers": 0,
186+
"default_branch": "master"
187+
},
188+
"sender": {
189+
"login": "chhsia0",
190+
"id": 4643017,
191+
"node_id": "MDQ6VXNlcjQ2NDMwMTc=",
192+
"avatar_url": "https://avatars0.githubusercontent.com/u/4643017?v=4",
193+
"gravatar_id": "",
194+
"url": "https://api.github.com/users/chhsia0",
195+
"html_url": "https://github.com/chhsia0",
196+
"followers_url": "https://api.github.com/users/chhsia0/followers",
197+
"following_url": "https://api.github.com/users/chhsia0/following{/other_user}",
198+
"gists_url": "https://api.github.com/users/chhsia0/gists{/gist_id}",
199+
"starred_url": "https://api.github.com/users/chhsia0/starred{/owner}{/repo}",
200+
"subscriptions_url": "https://api.github.com/users/chhsia0/subscriptions",
201+
"organizations_url": "https://api.github.com/users/chhsia0/orgs",
202+
"repos_url": "https://api.github.com/users/chhsia0/repos",
203+
"events_url": "https://api.github.com/users/chhsia0/events{/privacy}",
204+
"received_events_url": "https://api.github.com/users/chhsia0/received_events",
205+
"type": "User",
206+
"site_admin": false
207+
}
208+
}

0 commit comments

Comments
 (0)