Skip to content

Commit 0035246

Browse files
author
Dean Karn
authored
Merge pull request #36 from binkkatal/feature/owner_fields_in_github_push_event_payload
Add fields in PushPayload for repository owner
2 parents b9b0e19 + 443e255 commit 0035246

File tree

2 files changed

+155
-117
lines changed

2 files changed

+155
-117
lines changed

github/github_test.go

+126-103
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,6 @@ func TestBadSignatureMatch(t *testing.T) {
181181
}
182182

183183
func TestCommitCommentEvent(t *testing.T) {
184-
185184
payload := `{
186185
"action": "created",
187186
"comment": {
@@ -4763,137 +4762,160 @@ func TestPullRequestReviewCommentEvent(t *testing.T) {
47634762
func TestPushEvent(t *testing.T) {
47644763

47654764
payload := `{
4766-
"ref": "refs/heads/changes",
4767-
"before": "9049f1265b7d61be4a8904a9a27120d2064dab3b",
4768-
"after": "0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c",
4765+
"ref": "refs/heads/master",
4766+
"before": "737d38c599c1b2991664dfc6155d6bf516fcce36",
4767+
"after": "fd489864e7642b48eaad6e3f155c10e46810ec72",
47694768
"created": false,
47704769
"deleted": false,
47714770
"forced": false,
47724771
"base_ref": null,
4773-
"compare": "https://github.com/baxterthehacker/public-repo/compare/9049f1265b7d...0d1a26e67d8f",
4772+
"compare": "https://github.com/binkkatal/sample_app/compare/737d38c599c1...fd489864e764",
47744773
"commits": [
47754774
{
4776-
"id": "0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c",
4777-
"tree_id": "f9d2a07e9488b91af2641b26b9407fe22a451433",
4775+
"id": "fd489864e7642b48eaad6e3f155c10e46810ec72",
4776+
"tree_id": "55e08136e14d5168b699038f88c73e175ddffd3b",
47784777
"distinct": true,
4779-
"message": "Update README.md",
4780-
"timestamp": "2015-05-05T19:40:15-04:00",
4781-
"url": "https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c",
4778+
"message": "test a push event",
4779+
"timestamp": "2018-06-29T19:34:13+05:30",
4780+
"url": "https://github.com/binkkatal/sample_app/commit/fd489864e7642b48eaad6e3f155c10e46810ec72",
47824781
"author": {
4783-
"name": "baxterthehacker",
4784-
"email": "[email protected].com",
4785-
"username": "baxterthehacker"
4782+
"name": "binkkatal",
4783+
"email": "binkkatal.r@gmail.com",
4784+
"username": "binkkatal"
47864785
},
47874786
"committer": {
4788-
"name": "baxterthehacker",
4789-
"email": "[email protected].com",
4790-
"username": "baxterthehacker"
4787+
"name": "binkkatal",
4788+
"email": "binkkatal.r@gmail.com",
4789+
"username": "binkkatal"
47914790
},
47924791
"added": [
4793-
4792+
".razorops.yaml"
47944793
],
47954794
"removed": [
47964795
47974796
],
47984797
"modified": [
4799-
"README.md"
4798+
"app/controllers/application_controller.rb"
48004799
]
48014800
}
48024801
],
48034802
"head_commit": {
4804-
"id": "0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c",
4805-
"tree_id": "f9d2a07e9488b91af2641b26b9407fe22a451433",
4803+
"id": "fd489864e7642b48eaad6e3f155c10e46810ec72",
4804+
"tree_id": "55e08136e14d5168b699038f88c73e175ddffd3b",
48064805
"distinct": true,
4807-
"message": "Update README.md",
4808-
"timestamp": "2015-05-05T19:40:15-04:00",
4809-
"url": "https://github.com/baxterthehacker/public-repo/commit/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c",
4806+
"message": "test a push event",
4807+
"timestamp": "2018-06-29T19:34:13+05:30",
4808+
"url": "https://github.com/binkkatal/sample_app/commit/fd489864e7642b48eaad6e3f155c10e46810ec72",
48104809
"author": {
4811-
"name": "baxterthehacker",
4812-
"email": "[email protected].com",
4813-
"username": "baxterthehacker"
4810+
"name": "binkkatal",
4811+
"email": "binkkatal.r@gmail.com",
4812+
"username": "binkkatal"
48144813
},
48154814
"committer": {
4816-
"name": "baxterthehacker",
4817-
"email": "[email protected].com",
4818-
"username": "baxterthehacker"
4815+
"name": "binkkatal",
4816+
"email": "binkkatal.r@gmail.com",
4817+
"username": "binkkatal"
48194818
},
48204819
"added": [
4821-
4820+
".razorops.yaml"
48224821
],
48234822
"removed": [
48244823
48254824
],
48264825
"modified": [
4827-
"README.md"
4826+
"app/controllers/application_controller.rb"
48284827
]
48294828
},
48304829
"repository": {
4831-
"id": 35129377,
4832-
"name": "public-repo",
4833-
"full_name": "baxterthehacker/public-repo",
4830+
"id": 63933911,
4831+
"node_id": "MDEwOlJlcG9zaXRvcnk2MzkzMzkxMQ==",
4832+
"name": "sample_app",
4833+
"full_name": "binkkatal/sample_app",
48344834
"owner": {
4835-
"name": "baxterthehacker",
4836-
"email": "[email protected]"
4835+
"name": "binkkatal",
4836+
"email": "[email protected]",
4837+
"login": "binkkatal",
4838+
"id": 13351472,
4839+
"node_id": "MDQ6VXNlcjEzMzUxNDcy",
4840+
"avatar_url": "https://avatars3.githubusercontent.com/u/13351472?v=4",
4841+
"gravatar_id": "",
4842+
"url": "https://api.github.com/users/binkkatal",
4843+
"html_url": "https://github.com/binkkatal",
4844+
"followers_url": "https://api.github.com/users/binkkatal/followers",
4845+
"following_url": "https://api.github.com/users/binkkatal/following{/other_user}",
4846+
"gists_url": "https://api.github.com/users/binkkatal/gists{/gist_id}",
4847+
"starred_url": "https://api.github.com/users/binkkatal/starred{/owner}{/repo}",
4848+
"subscriptions_url": "https://api.github.com/users/binkkatal/subscriptions",
4849+
"organizations_url": "https://api.github.com/users/binkkatal/orgs",
4850+
"repos_url": "https://api.github.com/users/binkkatal/repos",
4851+
"events_url": "https://api.github.com/users/binkkatal/events{/privacy}",
4852+
"received_events_url": "https://api.github.com/users/binkkatal/received_events",
4853+
"type": "User",
4854+
"site_admin": false
48374855
},
48384856
"private": false,
4839-
"html_url": "https://github.com/baxterthehacker/public-repo",
4840-
"description": "",
4857+
"html_url": "https://github.com/binkkatal/sample_app",
4858+
"description": null,
48414859
"fork": false,
4842-
"url": "https://github.com/baxterthehacker/public-repo",
4843-
"forks_url": "https://api.github.com/repos/baxterthehacker/public-repo/forks",
4844-
"keys_url": "https://api.github.com/repos/baxterthehacker/public-repo/keys{/key_id}",
4845-
"collaborators_url": "https://api.github.com/repos/baxterthehacker/public-repo/collaborators{/collaborator}",
4846-
"teams_url": "https://api.github.com/repos/baxterthehacker/public-repo/teams",
4847-
"hooks_url": "https://api.github.com/repos/baxterthehacker/public-repo/hooks",
4848-
"issue_events_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/events{/number}",
4849-
"events_url": "https://api.github.com/repos/baxterthehacker/public-repo/events",
4850-
"assignees_url": "https://api.github.com/repos/baxterthehacker/public-repo/assignees{/user}",
4851-
"branches_url": "https://api.github.com/repos/baxterthehacker/public-repo/branches{/branch}",
4852-
"tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/tags",
4853-
"blobs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/blobs{/sha}",
4854-
"git_tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/tags{/sha}",
4855-
"git_refs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/refs{/sha}",
4856-
"trees_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/trees{/sha}",
4857-
"statuses_url": "https://api.github.com/repos/baxterthehacker/public-repo/statuses/{sha}",
4858-
"languages_url": "https://api.github.com/repos/baxterthehacker/public-repo/languages",
4859-
"stargazers_url": "https://api.github.com/repos/baxterthehacker/public-repo/stargazers",
4860-
"contributors_url": "https://api.github.com/repos/baxterthehacker/public-repo/contributors",
4861-
"subscribers_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscribers",
4862-
"subscription_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscription",
4863-
"commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/commits{/sha}",
4864-
"git_commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/commits{/sha}",
4865-
"comments_url": "https://api.github.com/repos/baxterthehacker/public-repo/comments{/number}",
4866-
"issue_comment_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/comments{/number}",
4867-
"contents_url": "https://api.github.com/repos/baxterthehacker/public-repo/contents/{+path}",
4868-
"compare_url": "https://api.github.com/repos/baxterthehacker/public-repo/compare/{base}...{head}",
4869-
"merges_url": "https://api.github.com/repos/baxterthehacker/public-repo/merges",
4870-
"archive_url": "https://api.github.com/repos/baxterthehacker/public-repo/{archive_format}{/ref}",
4871-
"downloads_url": "https://api.github.com/repos/baxterthehacker/public-repo/downloads",
4872-
"issues_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues{/number}",
4873-
"pulls_url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls{/number}",
4874-
"milestones_url": "https://api.github.com/repos/baxterthehacker/public-repo/milestones{/number}",
4875-
"notifications_url": "https://api.github.com/repos/baxterthehacker/public-repo/notifications{?since,all,participating}",
4876-
"labels_url": "https://api.github.com/repos/baxterthehacker/public-repo/labels{/name}",
4877-
"releases_url": "https://api.github.com/repos/baxterthehacker/public-repo/releases{/id}",
4878-
"created_at": 1430869212,
4879-
"updated_at": "2015-05-05T23:40:12Z",
4880-
"pushed_at": 1430869217,
4881-
"git_url": "git://github.com/baxterthehacker/public-repo.git",
4882-
"ssh_url": "[email protected]:baxterthehacker/public-repo.git",
4883-
"clone_url": "https://github.com/baxterthehacker/public-repo.git",
4884-
"svn_url": "https://github.com/baxterthehacker/public-repo",
4860+
"url": "https://github.com/binkkatal/sample_app",
4861+
"forks_url": "https://api.github.com/repos/binkkatal/sample_app/forks",
4862+
"keys_url": "https://api.github.com/repos/binkkatal/sample_app/keys{/key_id}",
4863+
"collaborators_url": "https://api.github.com/repos/binkkatal/sample_app/collaborators{/collaborator}",
4864+
"teams_url": "https://api.github.com/repos/binkkatal/sample_app/teams",
4865+
"hooks_url": "https://api.github.com/repos/binkkatal/sample_app/hooks",
4866+
"issue_events_url": "https://api.github.com/repos/binkkatal/sample_app/issues/events{/number}",
4867+
"events_url": "https://api.github.com/repos/binkkatal/sample_app/events",
4868+
"assignees_url": "https://api.github.com/repos/binkkatal/sample_app/assignees{/user}",
4869+
"branches_url": "https://api.github.com/repos/binkkatal/sample_app/branches{/branch}",
4870+
"tags_url": "https://api.github.com/repos/binkkatal/sample_app/tags",
4871+
"blobs_url": "https://api.github.com/repos/binkkatal/sample_app/git/blobs{/sha}",
4872+
"git_tags_url": "https://api.github.com/repos/binkkatal/sample_app/git/tags{/sha}",
4873+
"git_refs_url": "https://api.github.com/repos/binkkatal/sample_app/git/refs{/sha}",
4874+
"trees_url": "https://api.github.com/repos/binkkatal/sample_app/git/trees{/sha}",
4875+
"statuses_url": "https://api.github.com/repos/binkkatal/sample_app/statuses/{sha}",
4876+
"languages_url": "https://api.github.com/repos/binkkatal/sample_app/languages",
4877+
"stargazers_url": "https://api.github.com/repos/binkkatal/sample_app/stargazers",
4878+
"contributors_url": "https://api.github.com/repos/binkkatal/sample_app/contributors",
4879+
"subscribers_url": "https://api.github.com/repos/binkkatal/sample_app/subscribers",
4880+
"subscription_url": "https://api.github.com/repos/binkkatal/sample_app/subscription",
4881+
"commits_url": "https://api.github.com/repos/binkkatal/sample_app/commits{/sha}",
4882+
"git_commits_url": "https://api.github.com/repos/binkkatal/sample_app/git/commits{/sha}",
4883+
"comments_url": "https://api.github.com/repos/binkkatal/sample_app/comments{/number}",
4884+
"issue_comment_url": "https://api.github.com/repos/binkkatal/sample_app/issues/comments{/number}",
4885+
"contents_url": "https://api.github.com/repos/binkkatal/sample_app/contents/{+path}",
4886+
"compare_url": "https://api.github.com/repos/binkkatal/sample_app/compare/{base}...{head}",
4887+
"merges_url": "https://api.github.com/repos/binkkatal/sample_app/merges",
4888+
"archive_url": "https://api.github.com/repos/binkkatal/sample_app/{archive_format}{/ref}",
4889+
"downloads_url": "https://api.github.com/repos/binkkatal/sample_app/downloads",
4890+
"issues_url": "https://api.github.com/repos/binkkatal/sample_app/issues{/number}",
4891+
"pulls_url": "https://api.github.com/repos/binkkatal/sample_app/pulls{/number}",
4892+
"milestones_url": "https://api.github.com/repos/binkkatal/sample_app/milestones{/number}",
4893+
"notifications_url": "https://api.github.com/repos/binkkatal/sample_app/notifications{?since,all,participating}",
4894+
"labels_url": "https://api.github.com/repos/binkkatal/sample_app/labels{/name}",
4895+
"releases_url": "https://api.github.com/repos/binkkatal/sample_app/releases{/id}",
4896+
"deployments_url": "https://api.github.com/repos/binkkatal/sample_app/deployments",
4897+
"created_at": 1469173225,
4898+
"updated_at": "2016-07-22T07:48:39Z",
4899+
"pushed_at": 1530281075,
4900+
"git_url": "git://github.com/binkkatal/sample_app.git",
4901+
"ssh_url": "[email protected]:binkkatal/sample_app.git",
4902+
"clone_url": "https://github.com/binkkatal/sample_app.git",
4903+
"svn_url": "https://github.com/binkkatal/sample_app",
48854904
"homepage": null,
4886-
"size": 0,
4905+
"size": 23,
48874906
"stargazers_count": 0,
48884907
"watchers_count": 0,
4889-
"language": null,
4908+
"language": "Ruby",
48904909
"has_issues": true,
4910+
"has_projects": true,
48914911
"has_downloads": true,
48924912
"has_wiki": true,
4893-
"has_pages": true,
4913+
"has_pages": false,
48944914
"forks_count": 0,
48954915
"mirror_url": null,
4916+
"archived": false,
48964917
"open_issues_count": 0,
4918+
"license": null,
48974919
"forks": 0,
48984920
"open_issues": 0,
48994921
"watchers": 0,
@@ -4902,35 +4924,35 @@ func TestPushEvent(t *testing.T) {
49024924
"master_branch": "master"
49034925
},
49044926
"pusher": {
4905-
"name": "baxterthehacker",
4906-
"email": "[email protected].com"
4927+
"name": "binkkatal",
4928+
"email": "binkkatal.r@gmail.com"
49074929
},
49084930
"sender": {
4909-
"login": "baxterthehacker",
4910-
"id": 6752317,
4911-
"avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3",
4931+
"login": "binkkatal",
4932+
"id": 13351472,
4933+
"node_id": "MDQ6VXNlcjEzMzUxNDcy",
4934+
"avatar_url": "https://avatars3.githubusercontent.com/u/13351472?v=4",
49124935
"gravatar_id": "",
4913-
"url": "https://api.github.com/users/baxterthehacker",
4914-
"html_url": "https://github.com/baxterthehacker",
4915-
"followers_url": "https://api.github.com/users/baxterthehacker/followers",
4916-
"following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}",
4917-
"gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}",
4918-
"starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}",
4919-
"subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions",
4920-
"organizations_url": "https://api.github.com/users/baxterthehacker/orgs",
4921-
"repos_url": "https://api.github.com/users/baxterthehacker/repos",
4922-
"events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}",
4923-
"received_events_url": "https://api.github.com/users/baxterthehacker/received_events",
4936+
"url": "https://api.github.com/users/binkkatal",
4937+
"html_url": "https://github.com/binkkatal",
4938+
"followers_url": "https://api.github.com/users/binkkatal/followers",
4939+
"following_url": "https://api.github.com/users/binkkatal/following{/other_user}",
4940+
"gists_url": "https://api.github.com/users/binkkatal/gists{/gist_id}",
4941+
"starred_url": "https://api.github.com/users/binkkatal/starred{/owner}{/repo}",
4942+
"subscriptions_url": "https://api.github.com/users/binkkatal/subscriptions",
4943+
"organizations_url": "https://api.github.com/users/binkkatal/orgs",
4944+
"repos_url": "https://api.github.com/users/binkkatal/repos",
4945+
"events_url": "https://api.github.com/users/binkkatal/events{/privacy}",
4946+
"received_events_url": "https://api.github.com/users/binkkatal/received_events",
49244947
"type": "User",
49254948
"site_admin": false
49264949
}
4927-
}
4928-
`
4950+
}`
49294951

49304952
req, err := http.NewRequest("POST", "http://127.0.0.1:3010/webhooks", bytes.NewBuffer([]byte(payload)))
49314953
req.Header.Set("Content-Type", "application/json")
49324954
req.Header.Set("X-Github-Event", "push")
4933-
req.Header.Set("X-Hub-Signature", "sha1=c7097badc10db8a2ec615e340534956e75a483c6")
4955+
req.Header.Set("X-Hub-Signature", "sha1=0534736f52c2fc5896ef1bd5a043127b20d233ba")
49344956

49354957
Equal(t, err, nil)
49364958

@@ -4941,6 +4963,7 @@ func TestPushEvent(t *testing.T) {
49414963
defer resp.Body.Close()
49424964

49434965
Equal(t, resp.StatusCode, http.StatusOK)
4966+
49444967
}
49454968

49464969
func TestReleaseEvent(t *testing.T) {

github/payload.go

+29-14
Original file line numberDiff line numberDiff line change
@@ -376,12 +376,12 @@ type DeletePayload struct {
376376
// DeploymentPayload contains the information for GitHub's deployment hook
377377
type DeploymentPayload struct {
378378
Deployment struct {
379-
URL string `json:"url"`
380-
ID int64 `json:"id"`
381-
Sha string `json:"sha"`
382-
Ref string `json:"ref"`
383-
Task string `json:"task"`
384-
Payload string `json:"payload"`
379+
URL string `json:"url"`
380+
ID int64 `json:"id"`
381+
Sha string `json:"sha"`
382+
Ref string `json:"ref"`
383+
Task string `json:"task"`
384+
Payload string `json:"payload"`
385385
Environment string `json:"environment"`
386386
Description *string `json:"description"`
387387
Creator struct {
@@ -549,12 +549,12 @@ type DeploymentStatusPayload struct {
549549
RepositoryURL string `json:"repository_url"`
550550
} `json:"deployment_status"`
551551
Deployment struct {
552-
URL string `json:"url"`
553-
ID int64 `json:"id"`
554-
Sha string `json:"sha"`
555-
Ref string `json:"ref"`
556-
Task string `json:"task"`
557-
Payload string `json:"payload"`
552+
URL string `json:"url"`
553+
ID int64 `json:"id"`
554+
Sha string `json:"sha"`
555+
Ref string `json:"ref"`
556+
Task string `json:"task"`
557+
Payload string `json:"payload"`
558558
Environment string `json:"environment"`
559559
Description *string `json:"description"`
560560
Creator struct {
@@ -4122,8 +4122,23 @@ type PushPayload struct {
41224122
Name string `json:"name"`
41234123
FullName string `json:"full_name"`
41244124
Owner struct {
4125-
Name string `json:"name"`
4126-
Email string `json:"email"`
4125+
Login string `json:"login"`
4126+
ID int64 `json:"id"`
4127+
AvatarURL string `json:"avatar_url"`
4128+
GravatarID string `json:"gravatar_id"`
4129+
URL string `json:"url"`
4130+
HTMLURL string `json:"html_url"`
4131+
FollowersURL string `json:"followers_url"`
4132+
FollowingURL string `json:"following_url"`
4133+
GistsURL string `json:"gists_url"`
4134+
StarredURL string `json:"starred_url"`
4135+
SubscriptionsURL string `json:"subscriptions_url"`
4136+
OrganizationsURL string `json:"organizations_url"`
4137+
ReposURL string `json:"repos_url"`
4138+
EventsURL string `json:"events_url"`
4139+
ReceivedEventsURL string `json:"received_events_url"`
4140+
Type string `json:"type"`
4141+
SiteAdmin bool `json:"site_admin"`
41274142
} `json:"owner"`
41284143
Private bool `json:"private"`
41294144
HTMLURL string `json:"html_url"`

0 commit comments

Comments
 (0)