diff --git a/fixtures/pull-request-baxterthehacker.json b/fixtures/pull-request-baxterthehacker.json new file mode 100644 index 00000000..8bbe8ee5 --- /dev/null +++ b/fixtures/pull-request-baxterthehacker.json @@ -0,0 +1,314 @@ +{ + "url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls/1", + "id": 34778301, + "html_url": "https://github.com/baxterthehacker/public-repo/pull/1", + "diff_url": "https://github.com/baxterthehacker/public-repo/pull/1.diff", + "patch_url": "https://github.com/baxterthehacker/public-repo/pull/1.patch", + "issue_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/1", + "number": 1, + "state": "closed", + "locked": false, + "title": "Update the README with new information", + "user": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars3.githubusercontent.com/u/6752317?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + }, + "body": "This is a pretty simple change that we need to pull into master.\n", + "created_at": "2015-05-05T23:40:27Z", + "updated_at": "2017-03-08T18:21:05Z", + "closed_at": "2015-05-05T23:41:12Z", + "merged_at": null, + "merge_commit_sha": "18721552ba489fb84e12958c1b5694b5475f7991", + "assignee": null, + "assignees": [ + + ], + "requested_reviewers": [ + + ], + "milestone": null, + "commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls/1/commits", + "review_comments_url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls/1/comments", + "review_comment_url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls/comments{/number}", + "comments_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/1/comments", + "statuses_url": "https://api.github.com/repos/baxterthehacker/public-repo/statuses/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c", + "head": { + "label": "baxterthehacker:changes", + "ref": "changes", + "sha": "0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c", + "user": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars3.githubusercontent.com/u/6752317?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + }, + "repo": { + "id": 35129377, + "name": "public-repo", + "full_name": "baxterthehacker/public-repo", + "owner": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars3.githubusercontent.com/u/6752317?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/baxterthehacker/public-repo", + "description": null, + "fork": false, + "url": "https://api.github.com/repos/baxterthehacker/public-repo", + "forks_url": "https://api.github.com/repos/baxterthehacker/public-repo/forks", + "keys_url": "https://api.github.com/repos/baxterthehacker/public-repo/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/baxterthehacker/public-repo/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/baxterthehacker/public-repo/teams", + "hooks_url": "https://api.github.com/repos/baxterthehacker/public-repo/hooks", + "issue_events_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/events{/number}", + "events_url": "https://api.github.com/repos/baxterthehacker/public-repo/events", + "assignees_url": "https://api.github.com/repos/baxterthehacker/public-repo/assignees{/user}", + "branches_url": "https://api.github.com/repos/baxterthehacker/public-repo/branches{/branch}", + "tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/tags", + "blobs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/baxterthehacker/public-repo/statuses/{sha}", + "languages_url": "https://api.github.com/repos/baxterthehacker/public-repo/languages", + "stargazers_url": "https://api.github.com/repos/baxterthehacker/public-repo/stargazers", + "contributors_url": "https://api.github.com/repos/baxterthehacker/public-repo/contributors", + "subscribers_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscribers", + "subscription_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscription", + "commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/baxterthehacker/public-repo/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/baxterthehacker/public-repo/contents/{+path}", + "compare_url": "https://api.github.com/repos/baxterthehacker/public-repo/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/baxterthehacker/public-repo/merges", + "archive_url": "https://api.github.com/repos/baxterthehacker/public-repo/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/baxterthehacker/public-repo/downloads", + "issues_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues{/number}", + "pulls_url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls{/number}", + "milestones_url": "https://api.github.com/repos/baxterthehacker/public-repo/milestones{/number}", + "notifications_url": "https://api.github.com/repos/baxterthehacker/public-repo/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/baxterthehacker/public-repo/labels{/name}", + "releases_url": "https://api.github.com/repos/baxterthehacker/public-repo/releases{/id}", + "deployments_url": "https://api.github.com/repos/baxterthehacker/public-repo/deployments", + "created_at": "2015-05-05T23:40:12Z", + "updated_at": "2017-01-17T21:35:29Z", + "pushed_at": "2016-10-03T23:37:43Z", + "git_url": "git://github.com/baxterthehacker/public-repo.git", + "ssh_url": "git@github.com:baxterthehacker/public-repo.git", + "clone_url": "https://github.com/baxterthehacker/public-repo.git", + "svn_url": "https://github.com/baxterthehacker/public-repo", + "homepage": null, + "size": 3, + "stargazers_count": 3, + "watchers_count": 3, + "language": null, + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 3, + "mirror_url": null, + "open_issues_count": 5, + "forks": 3, + "open_issues": 5, + "watchers": 3, + "default_branch": "master" + } + }, + "base": { + "label": "baxterthehacker:master", + "ref": "master", + "sha": "9049f1265b7d61be4a8904a9a27120d2064dab3b", + "user": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars3.githubusercontent.com/u/6752317?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + }, + "repo": { + "id": 35129377, + "name": "public-repo", + "full_name": "baxterthehacker/public-repo", + "owner": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars3.githubusercontent.com/u/6752317?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/baxterthehacker/public-repo", + "description": null, + "fork": false, + "url": "https://api.github.com/repos/baxterthehacker/public-repo", + "forks_url": "https://api.github.com/repos/baxterthehacker/public-repo/forks", + "keys_url": "https://api.github.com/repos/baxterthehacker/public-repo/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/baxterthehacker/public-repo/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/baxterthehacker/public-repo/teams", + "hooks_url": "https://api.github.com/repos/baxterthehacker/public-repo/hooks", + "issue_events_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/events{/number}", + "events_url": "https://api.github.com/repos/baxterthehacker/public-repo/events", + "assignees_url": "https://api.github.com/repos/baxterthehacker/public-repo/assignees{/user}", + "branches_url": "https://api.github.com/repos/baxterthehacker/public-repo/branches{/branch}", + "tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/tags", + "blobs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/baxterthehacker/public-repo/statuses/{sha}", + "languages_url": "https://api.github.com/repos/baxterthehacker/public-repo/languages", + "stargazers_url": "https://api.github.com/repos/baxterthehacker/public-repo/stargazers", + "contributors_url": "https://api.github.com/repos/baxterthehacker/public-repo/contributors", + "subscribers_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscribers", + "subscription_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscription", + "commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/baxterthehacker/public-repo/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/baxterthehacker/public-repo/contents/{+path}", + "compare_url": "https://api.github.com/repos/baxterthehacker/public-repo/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/baxterthehacker/public-repo/merges", + "archive_url": "https://api.github.com/repos/baxterthehacker/public-repo/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/baxterthehacker/public-repo/downloads", + "issues_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues{/number}", + "pulls_url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls{/number}", + "milestones_url": "https://api.github.com/repos/baxterthehacker/public-repo/milestones{/number}", + "notifications_url": "https://api.github.com/repos/baxterthehacker/public-repo/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/baxterthehacker/public-repo/labels{/name}", + "releases_url": "https://api.github.com/repos/baxterthehacker/public-repo/releases{/id}", + "deployments_url": "https://api.github.com/repos/baxterthehacker/public-repo/deployments", + "created_at": "2015-05-05T23:40:12Z", + "updated_at": "2017-01-17T21:35:29Z", + "pushed_at": "2016-10-03T23:37:43Z", + "git_url": "git://github.com/baxterthehacker/public-repo.git", + "ssh_url": "git@github.com:baxterthehacker/public-repo.git", + "clone_url": "https://github.com/baxterthehacker/public-repo.git", + "svn_url": "https://github.com/baxterthehacker/public-repo", + "homepage": null, + "size": 3, + "stargazers_count": 3, + "watchers_count": 3, + "language": null, + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 3, + "mirror_url": null, + "open_issues_count": 5, + "forks": 3, + "open_issues": 5, + "watchers": 3, + "default_branch": "master" + } + }, + "_links": { + "self": { + "href": "https://api.github.com/repos/baxterthehacker/public-repo/pulls/1" + }, + "html": { + "href": "https://github.com/baxterthehacker/public-repo/pull/1" + }, + "issue": { + "href": "https://api.github.com/repos/baxterthehacker/public-repo/issues/1" + }, + "comments": { + "href": "https://api.github.com/repos/baxterthehacker/public-repo/issues/1/comments" + }, + "review_comments": { + "href": "https://api.github.com/repos/baxterthehacker/public-repo/pulls/1/comments" + }, + "review_comment": { + "href": "https://api.github.com/repos/baxterthehacker/public-repo/pulls/comments{/number}" + }, + "commits": { + "href": "https://api.github.com/repos/baxterthehacker/public-repo/pulls/1/commits" + }, + "statuses": { + "href": "https://api.github.com/repos/baxterthehacker/public-repo/statuses/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c" + } + }, + "merged": false, + "mergeable": true, + "rebaseable": false, + "mergeable_state": "clean", + "merged_by": null, + "comments": 6, + "review_comments": 2, + "maintainer_can_modify": false, + "commits": 1, + "additions": 1, + "deletions": 1, + "changed_files": 1 +} diff --git a/fixtures/pull-request-event-github-example.json b/fixtures/pull-request-event-github-example.json new file mode 100644 index 00000000..0c37e40a --- /dev/null +++ b/fixtures/pull-request-event-github-example.json @@ -0,0 +1,415 @@ +{ + "action": "opened", + "number": 1, + "pull_request": { + "url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls/1", + "id": 34778301, + "html_url": "https://github.com/baxterthehacker/public-repo/pull/1", + "diff_url": "https://github.com/baxterthehacker/public-repo/pull/1.diff", + "patch_url": "https://github.com/baxterthehacker/public-repo/pull/1.patch", + "issue_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/1", + "number": 1, + "state": "open", + "locked": false, + "title": "Update the README with new information", + "user": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + }, + "body": "This is a pretty simple change that we need to pull into master.", + "created_at": "2015-05-05T23:40:27Z", + "updated_at": "2015-05-05T23:40:27Z", + "closed_at": null, + "merged_at": null, + "merge_commit_sha": null, + "assignee": null, + "milestone": null, + "commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls/1/commits", + "review_comments_url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls/1/comments", + "review_comment_url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls/comments{/number}", + "comments_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/1/comments", + "statuses_url": "https://api.github.com/repos/baxterthehacker/public-repo/statuses/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c", + "head": { + "label": "baxterthehacker:changes", + "ref": "changes", + "sha": "0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c", + "user": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + }, + "repo": { + "id": 35129377, + "name": "public-repo", + "full_name": "baxterthehacker/public-repo", + "owner": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/baxterthehacker/public-repo", + "description": "", + "fork": false, + "url": "https://api.github.com/repos/baxterthehacker/public-repo", + "forks_url": "https://api.github.com/repos/baxterthehacker/public-repo/forks", + "keys_url": "https://api.github.com/repos/baxterthehacker/public-repo/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/baxterthehacker/public-repo/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/baxterthehacker/public-repo/teams", + "hooks_url": "https://api.github.com/repos/baxterthehacker/public-repo/hooks", + "issue_events_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/events{/number}", + "events_url": "https://api.github.com/repos/baxterthehacker/public-repo/events", + "assignees_url": "https://api.github.com/repos/baxterthehacker/public-repo/assignees{/user}", + "branches_url": "https://api.github.com/repos/baxterthehacker/public-repo/branches{/branch}", + "tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/tags", + "blobs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/baxterthehacker/public-repo/statuses/{sha}", + "languages_url": "https://api.github.com/repos/baxterthehacker/public-repo/languages", + "stargazers_url": "https://api.github.com/repos/baxterthehacker/public-repo/stargazers", + "contributors_url": "https://api.github.com/repos/baxterthehacker/public-repo/contributors", + "subscribers_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscribers", + "subscription_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscription", + "commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/baxterthehacker/public-repo/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/baxterthehacker/public-repo/contents/{+path}", + "compare_url": "https://api.github.com/repos/baxterthehacker/public-repo/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/baxterthehacker/public-repo/merges", + "archive_url": "https://api.github.com/repos/baxterthehacker/public-repo/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/baxterthehacker/public-repo/downloads", + "issues_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues{/number}", + "pulls_url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls{/number}", + "milestones_url": "https://api.github.com/repos/baxterthehacker/public-repo/milestones{/number}", + "notifications_url": "https://api.github.com/repos/baxterthehacker/public-repo/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/baxterthehacker/public-repo/labels{/name}", + "releases_url": "https://api.github.com/repos/baxterthehacker/public-repo/releases{/id}", + "created_at": "2015-05-05T23:40:12Z", + "updated_at": "2015-05-05T23:40:12Z", + "pushed_at": "2015-05-05T23:40:26Z", + "git_url": "git://github.com/baxterthehacker/public-repo.git", + "ssh_url": "git@github.com:baxterthehacker/public-repo.git", + "clone_url": "https://github.com/baxterthehacker/public-repo.git", + "svn_url": "https://github.com/baxterthehacker/public-repo", + "homepage": null, + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 0, + "mirror_url": null, + "open_issues_count": 1, + "forks": 0, + "open_issues": 1, + "watchers": 0, + "default_branch": "master" + } + }, + "base": { + "label": "baxterthehacker:master", + "ref": "master", + "sha": "9049f1265b7d61be4a8904a9a27120d2064dab3b", + "user": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + }, + "repo": { + "id": 35129377, + "name": "public-repo", + "full_name": "baxterthehacker/public-repo", + "owner": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/baxterthehacker/public-repo", + "description": "", + "fork": false, + "url": "https://api.github.com/repos/baxterthehacker/public-repo", + "forks_url": "https://api.github.com/repos/baxterthehacker/public-repo/forks", + "keys_url": "https://api.github.com/repos/baxterthehacker/public-repo/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/baxterthehacker/public-repo/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/baxterthehacker/public-repo/teams", + "hooks_url": "https://api.github.com/repos/baxterthehacker/public-repo/hooks", + "issue_events_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/events{/number}", + "events_url": "https://api.github.com/repos/baxterthehacker/public-repo/events", + "assignees_url": "https://api.github.com/repos/baxterthehacker/public-repo/assignees{/user}", + "branches_url": "https://api.github.com/repos/baxterthehacker/public-repo/branches{/branch}", + "tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/tags", + "blobs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/baxterthehacker/public-repo/statuses/{sha}", + "languages_url": "https://api.github.com/repos/baxterthehacker/public-repo/languages", + "stargazers_url": "https://api.github.com/repos/baxterthehacker/public-repo/stargazers", + "contributors_url": "https://api.github.com/repos/baxterthehacker/public-repo/contributors", + "subscribers_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscribers", + "subscription_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscription", + "commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/baxterthehacker/public-repo/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/baxterthehacker/public-repo/contents/{+path}", + "compare_url": "https://api.github.com/repos/baxterthehacker/public-repo/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/baxterthehacker/public-repo/merges", + "archive_url": "https://api.github.com/repos/baxterthehacker/public-repo/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/baxterthehacker/public-repo/downloads", + "issues_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues{/number}", + "pulls_url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls{/number}", + "milestones_url": "https://api.github.com/repos/baxterthehacker/public-repo/milestones{/number}", + "notifications_url": "https://api.github.com/repos/baxterthehacker/public-repo/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/baxterthehacker/public-repo/labels{/name}", + "releases_url": "https://api.github.com/repos/baxterthehacker/public-repo/releases{/id}", + "created_at": "2015-05-05T23:40:12Z", + "updated_at": "2015-05-05T23:40:12Z", + "pushed_at": "2015-05-05T23:40:26Z", + "git_url": "git://github.com/baxterthehacker/public-repo.git", + "ssh_url": "git@github.com:baxterthehacker/public-repo.git", + "clone_url": "https://github.com/baxterthehacker/public-repo.git", + "svn_url": "https://github.com/baxterthehacker/public-repo", + "homepage": null, + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 0, + "mirror_url": null, + "open_issues_count": 1, + "forks": 0, + "open_issues": 1, + "watchers": 0, + "default_branch": "master" + } + }, + "_links": { + "self": { + "href": "https://api.github.com/repos/baxterthehacker/public-repo/pulls/1" + }, + "html": { + "href": "https://github.com/baxterthehacker/public-repo/pull/1" + }, + "issue": { + "href": "https://api.github.com/repos/baxterthehacker/public-repo/issues/1" + }, + "comments": { + "href": "https://api.github.com/repos/baxterthehacker/public-repo/issues/1/comments" + }, + "review_comments": { + "href": "https://api.github.com/repos/baxterthehacker/public-repo/pulls/1/comments" + }, + "review_comment": { + "href": "https://api.github.com/repos/baxterthehacker/public-repo/pulls/comments{/number}" + }, + "commits": { + "href": "https://api.github.com/repos/baxterthehacker/public-repo/pulls/1/commits" + }, + "statuses": { + "href": "https://api.github.com/repos/baxterthehacker/public-repo/statuses/0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c" + } + }, + "merged": false, + "mergeable": null, + "mergeable_state": "unknown", + "merged_by": null, + "comments": 0, + "review_comments": 0, + "commits": 1, + "additions": 1, + "deletions": 1, + "changed_files": 1 + }, + "repository": { + "id": 35129377, + "name": "public-repo", + "full_name": "baxterthehacker/public-repo", + "owner": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/baxterthehacker/public-repo", + "description": "", + "fork": false, + "url": "https://api.github.com/repos/baxterthehacker/public-repo", + "forks_url": "https://api.github.com/repos/baxterthehacker/public-repo/forks", + "keys_url": "https://api.github.com/repos/baxterthehacker/public-repo/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/baxterthehacker/public-repo/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/baxterthehacker/public-repo/teams", + "hooks_url": "https://api.github.com/repos/baxterthehacker/public-repo/hooks", + "issue_events_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/events{/number}", + "events_url": "https://api.github.com/repos/baxterthehacker/public-repo/events", + "assignees_url": "https://api.github.com/repos/baxterthehacker/public-repo/assignees{/user}", + "branches_url": "https://api.github.com/repos/baxterthehacker/public-repo/branches{/branch}", + "tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/tags", + "blobs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/baxterthehacker/public-repo/statuses/{sha}", + "languages_url": "https://api.github.com/repos/baxterthehacker/public-repo/languages", + "stargazers_url": "https://api.github.com/repos/baxterthehacker/public-repo/stargazers", + "contributors_url": "https://api.github.com/repos/baxterthehacker/public-repo/contributors", + "subscribers_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscribers", + "subscription_url": "https://api.github.com/repos/baxterthehacker/public-repo/subscription", + "commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/baxterthehacker/public-repo/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/baxterthehacker/public-repo/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/baxterthehacker/public-repo/contents/{+path}", + "compare_url": "https://api.github.com/repos/baxterthehacker/public-repo/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/baxterthehacker/public-repo/merges", + "archive_url": "https://api.github.com/repos/baxterthehacker/public-repo/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/baxterthehacker/public-repo/downloads", + "issues_url": "https://api.github.com/repos/baxterthehacker/public-repo/issues{/number}", + "pulls_url": "https://api.github.com/repos/baxterthehacker/public-repo/pulls{/number}", + "milestones_url": "https://api.github.com/repos/baxterthehacker/public-repo/milestones{/number}", + "notifications_url": "https://api.github.com/repos/baxterthehacker/public-repo/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/baxterthehacker/public-repo/labels{/name}", + "releases_url": "https://api.github.com/repos/baxterthehacker/public-repo/releases{/id}", + "created_at": "2015-05-05T23:40:12Z", + "updated_at": "2015-05-05T23:40:12Z", + "pushed_at": "2015-05-05T23:40:26Z", + "git_url": "git://github.com/baxterthehacker/public-repo.git", + "ssh_url": "git@github.com:baxterthehacker/public-repo.git", + "clone_url": "https://github.com/baxterthehacker/public-repo.git", + "svn_url": "https://github.com/baxterthehacker/public-repo", + "homepage": null, + "size": 0, + "stargazers_count": 0, + "watchers_count": 0, + "language": null, + "has_issues": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": true, + "forks_count": 0, + "mirror_url": null, + "open_issues_count": 1, + "forks": 0, + "open_issues": 1, + "watchers": 0, + "default_branch": "master" + }, + "sender": { + "login": "baxterthehacker", + "id": 6752317, + "avatar_url": "https://avatars.githubusercontent.com/u/6752317?v=3", + "gravatar_id": "", + "url": "https://api.github.com/users/baxterthehacker", + "html_url": "https://github.com/baxterthehacker", + "followers_url": "https://api.github.com/users/baxterthehacker/followers", + "following_url": "https://api.github.com/users/baxterthehacker/following{/other_user}", + "gists_url": "https://api.github.com/users/baxterthehacker/gists{/gist_id}", + "starred_url": "https://api.github.com/users/baxterthehacker/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/baxterthehacker/subscriptions", + "organizations_url": "https://api.github.com/users/baxterthehacker/orgs", + "repos_url": "https://api.github.com/users/baxterthehacker/repos", + "events_url": "https://api.github.com/users/baxterthehacker/events{/privacy}", + "received_events_url": "https://api.github.com/users/baxterthehacker/received_events", + "type": "User", + "site_admin": false + }, + "installation": { + "id": 234 + } +} diff --git a/fixtures/pull-request-event-realworld.json b/fixtures/pull-request-event-realworld.json new file mode 100644 index 00000000..4c0ff208 --- /dev/null +++ b/fixtures/pull-request-event-realworld.json @@ -0,0 +1,422 @@ +{ + "repository": { + "git_commits_url": "https://api.github.com/repos/adnelson/taskserver/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/adnelson/taskserver/comments{/number}", + "assignees_url": "https://api.github.com/repos/adnelson/taskserver/assignees{/user}", + "milestones_url": "https://api.github.com/repos/adnelson/taskserver/milestones{/number}", + "has_issues": true, + "ssh_url": "git@github.com:adnelson/taskserver.git", + "has_projects": true, + "fork": false, + "watchers_count": 0, + "labels_url": "https://api.github.com/repos/adnelson/taskserver/labels{/name}", + "owner": { + "organizations_url": "https://api.github.com/users/adnelson/orgs", + "login": "adnelson", + "events_url": "https://api.github.com/users/adnelson/events{/privacy}", + "following_url": "https://api.github.com/users/adnelson/following{/other_user}", + "subscriptions_url": "https://api.github.com/users/adnelson/subscriptions", + "id": 5091511, + "site_admin": false, + "starred_url": "https://api.github.com/users/adnelson/starred{/owner}{/repo}", + "avatar_url": "https://avatars2.githubusercontent.com/u/5091511?v=4", + "type": "User", + "received_events_url": "https://api.github.com/users/adnelson/received_events", + "html_url": "https://github.com/adnelson", + "gravatar_id": "", + "gists_url": "https://api.github.com/users/adnelson/gists{/gist_id}", + "url": "https://api.github.com/users/adnelson", + "followers_url": "https://api.github.com/users/adnelson/followers", + "repos_url": "https://api.github.com/users/adnelson/repos" + }, + "html_url": "https://github.com/adnelson/taskserver", + "default_branch": "master", + "homepage": null, + "archive_url": "https://api.github.com/repos/adnelson/taskserver/{archive_format}{/ref}", + "subscribers_url": "https://api.github.com/repos/adnelson/taskserver/subscribers", + "git_url": "git://github.com/adnelson/taskserver.git", + "open_issues": 1, + "notifications_url": "https://api.github.com/repos/adnelson/taskserver/notifications{?since,all,participating}", + "forks": 0, + "branches_url": "https://api.github.com/repos/adnelson/taskserver/branches{/branch}", + "downloads_url": "https://api.github.com/repos/adnelson/taskserver/downloads", + "forks_count": 0, + "has_wiki": true, + "pulls_url": "https://api.github.com/repos/adnelson/taskserver/pulls{/number}", + "keys_url": "https://api.github.com/repos/adnelson/taskserver/keys{/key_id}", + "clone_url": "https://github.com/adnelson/taskserver.git", + "stargazers_url": "https://api.github.com/repos/adnelson/taskserver/stargazers", + "merges_url": "https://api.github.com/repos/adnelson/taskserver/merges", + "private": true, + "url": "https://api.github.com/repos/adnelson/taskserver", + "size": 148, + "contributors_url": "https://api.github.com/repos/adnelson/taskserver/contributors", + "issue_comment_url": "https://api.github.com/repos/adnelson/taskserver/issues/comments{/number}", + "blobs_url": "https://api.github.com/repos/adnelson/taskserver/git/blobs{/sha}", + "full_name": "adnelson/taskserver", + "commits_url": "https://api.github.com/repos/adnelson/taskserver/commits{/sha}", + "teams_url": "https://api.github.com/repos/adnelson/taskserver/teams", + "name": "taskserver", + "collaborators_url": "https://api.github.com/repos/adnelson/taskserver/collaborators{/collaborator}", + "pushed_at": "2017-07-31T18:08:56Z", + "forks_url": "https://api.github.com/repos/adnelson/taskserver/forks", + "trees_url": "https://api.github.com/repos/adnelson/taskserver/git/trees{/sha}", + "tags_url": "https://api.github.com/repos/adnelson/taskserver/tags", + "issue_events_url": "https://api.github.com/repos/adnelson/taskserver/issues/events{/number}", + "mirror_url": null, + "has_downloads": true, + "svn_url": "https://github.com/adnelson/taskserver", + "subscription_url": "https://api.github.com/repos/adnelson/taskserver/subscription", + "git_refs_url": "https://api.github.com/repos/adnelson/taskserver/git/refs{/sha}", + "created_at": "2017-07-07T22:39:54Z", + "description": "Server that does tasks", + "events_url": "https://api.github.com/repos/adnelson/taskserver/events", + "has_pages": false, + "language": "JavaScript", + "stargazers_count": 0, + "compare_url": "https://api.github.com/repos/adnelson/taskserver/compare/{base}...{head}", + "issues_url": "https://api.github.com/repos/adnelson/taskserver/issues{/number}", + "contents_url": "https://api.github.com/repos/adnelson/taskserver/contents/{+path}", + "updated_at": "2017-07-31T14:44:25Z", + "hooks_url": "https://api.github.com/repos/adnelson/taskserver/hooks", + "deployments_url": "https://api.github.com/repos/adnelson/taskserver/deployments", + "id": 96581526, + "statuses_url": "https://api.github.com/repos/adnelson/taskserver/statuses/{sha}", + "open_issues_count": 1, + "languages_url": "https://api.github.com/repos/adnelson/taskserver/languages", + "watchers": 0, + "git_tags_url": "https://api.github.com/repos/adnelson/taskserver/git/tags{/sha}", + "releases_url": "https://api.github.com/repos/adnelson/taskserver/releases{/id}" + }, + "action": "opened", + "pull_request": { + "user": { + "organizations_url": "https://api.github.com/users/adnelson/orgs", + "login": "adnelson", + "events_url": "https://api.github.com/users/adnelson/events{/privacy}", + "following_url": "https://api.github.com/users/adnelson/following{/other_user}", + "subscriptions_url": "https://api.github.com/users/adnelson/subscriptions", + "id": 5091511, + "site_admin": false, + "starred_url": "https://api.github.com/users/adnelson/starred{/owner}{/repo}", + "avatar_url": "https://avatars2.githubusercontent.com/u/5091511?v=4", + "type": "User", + "received_events_url": "https://api.github.com/users/adnelson/received_events", + "html_url": "https://github.com/adnelson", + "gravatar_id": "", + "gists_url": "https://api.github.com/users/adnelson/gists{/gist_id}", + "url": "https://api.github.com/users/adnelson", + "followers_url": "https://api.github.com/users/adnelson/followers", + "repos_url": "https://api.github.com/users/adnelson/repos" + }, + "comments_url": "https://api.github.com/repos/adnelson/taskserver/issues/1/comments", + "review_comments_url": "https://api.github.com/repos/adnelson/taskserver/pulls/1/comments", + "review_comment_url": "https://api.github.com/repos/adnelson/taskserver/pulls/comments{/number}", + "assignee": null, + "title": "hey hey", + "issue_url": "https://api.github.com/repos/adnelson/taskserver/issues/1", + "base": { + "ref": "master", + "user": { + "organizations_url": "https://api.github.com/users/adnelson/orgs", + "login": "adnelson", + "events_url": "https://api.github.com/users/adnelson/events{/privacy}", + "following_url": "https://api.github.com/users/adnelson/following{/other_user}", + "subscriptions_url": "https://api.github.com/users/adnelson/subscriptions", + "id": 5091511, + "site_admin": false, + "starred_url": "https://api.github.com/users/adnelson/starred{/owner}{/repo}", + "avatar_url": "https://avatars2.githubusercontent.com/u/5091511?v=4", + "type": "User", + "received_events_url": "https://api.github.com/users/adnelson/received_events", + "html_url": "https://github.com/adnelson", + "gravatar_id": "", + "gists_url": "https://api.github.com/users/adnelson/gists{/gist_id}", + "url": "https://api.github.com/users/adnelson", + "followers_url": "https://api.github.com/users/adnelson/followers", + "repos_url": "https://api.github.com/users/adnelson/repos" + }, + "repo": { + "git_commits_url": "https://api.github.com/repos/adnelson/taskserver/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/adnelson/taskserver/comments{/number}", + "assignees_url": "https://api.github.com/repos/adnelson/taskserver/assignees{/user}", + "milestones_url": "https://api.github.com/repos/adnelson/taskserver/milestones{/number}", + "has_issues": true, + "ssh_url": "git@github.com:adnelson/taskserver.git", + "has_projects": true, + "fork": false, + "watchers_count": 0, + "labels_url": "https://api.github.com/repos/adnelson/taskserver/labels{/name}", + "owner": { + "organizations_url": "https://api.github.com/users/adnelson/orgs", + "login": "adnelson", + "events_url": "https://api.github.com/users/adnelson/events{/privacy}", + "following_url": "https://api.github.com/users/adnelson/following{/other_user}", + "subscriptions_url": "https://api.github.com/users/adnelson/subscriptions", + "id": 5091511, + "site_admin": false, + "starred_url": "https://api.github.com/users/adnelson/starred{/owner}{/repo}", + "avatar_url": "https://avatars2.githubusercontent.com/u/5091511?v=4", + "type": "User", + "received_events_url": "https://api.github.com/users/adnelson/received_events", + "html_url": "https://github.com/adnelson", + "gravatar_id": "", + "gists_url": "https://api.github.com/users/adnelson/gists{/gist_id}", + "url": "https://api.github.com/users/adnelson", + "followers_url": "https://api.github.com/users/adnelson/followers", + "repos_url": "https://api.github.com/users/adnelson/repos" + }, + "html_url": "https://github.com/adnelson/taskserver", + "default_branch": "master", + "homepage": null, + "archive_url": "https://api.github.com/repos/adnelson/taskserver/{archive_format}{/ref}", + "subscribers_url": "https://api.github.com/repos/adnelson/taskserver/subscribers", + "git_url": "git://github.com/adnelson/taskserver.git", + "open_issues": 1, + "notifications_url": "https://api.github.com/repos/adnelson/taskserver/notifications{?since,all,participating}", + "forks": 0, + "branches_url": "https://api.github.com/repos/adnelson/taskserver/branches{/branch}", + "downloads_url": "https://api.github.com/repos/adnelson/taskserver/downloads", + "forks_count": 0, + "has_wiki": true, + "pulls_url": "https://api.github.com/repos/adnelson/taskserver/pulls{/number}", + "keys_url": "https://api.github.com/repos/adnelson/taskserver/keys{/key_id}", + "clone_url": "https://github.com/adnelson/taskserver.git", + "stargazers_url": "https://api.github.com/repos/adnelson/taskserver/stargazers", + "merges_url": "https://api.github.com/repos/adnelson/taskserver/merges", + "private": true, + "url": "https://api.github.com/repos/adnelson/taskserver", + "size": 148, + "contributors_url": "https://api.github.com/repos/adnelson/taskserver/contributors", + "issue_comment_url": "https://api.github.com/repos/adnelson/taskserver/issues/comments{/number}", + "blobs_url": "https://api.github.com/repos/adnelson/taskserver/git/blobs{/sha}", + "full_name": "adnelson/taskserver", + "commits_url": "https://api.github.com/repos/adnelson/taskserver/commits{/sha}", + "teams_url": "https://api.github.com/repos/adnelson/taskserver/teams", + "name": "taskserver", + "collaborators_url": "https://api.github.com/repos/adnelson/taskserver/collaborators{/collaborator}", + "pushed_at": "2017-07-31T18:08:56Z", + "forks_url": "https://api.github.com/repos/adnelson/taskserver/forks", + "trees_url": "https://api.github.com/repos/adnelson/taskserver/git/trees{/sha}", + "tags_url": "https://api.github.com/repos/adnelson/taskserver/tags", + "issue_events_url": "https://api.github.com/repos/adnelson/taskserver/issues/events{/number}", + "mirror_url": null, + "has_downloads": true, + "svn_url": "https://github.com/adnelson/taskserver", + "subscription_url": "https://api.github.com/repos/adnelson/taskserver/subscription", + "git_refs_url": "https://api.github.com/repos/adnelson/taskserver/git/refs{/sha}", + "created_at": "2017-07-07T22:39:54Z", + "description": "Server that does tasks", + "events_url": "https://api.github.com/repos/adnelson/taskserver/events", + "has_pages": false, + "language": "JavaScript", + "stargazers_count": 0, + "compare_url": "https://api.github.com/repos/adnelson/taskserver/compare/{base}...{head}", + "issues_url": "https://api.github.com/repos/adnelson/taskserver/issues{/number}", + "contents_url": "https://api.github.com/repos/adnelson/taskserver/contents/{+path}", + "updated_at": "2017-07-31T14:44:25Z", + "hooks_url": "https://api.github.com/repos/adnelson/taskserver/hooks", + "deployments_url": "https://api.github.com/repos/adnelson/taskserver/deployments", + "id": 96581526, + "statuses_url": "https://api.github.com/repos/adnelson/taskserver/statuses/{sha}", + "open_issues_count": 1, + "languages_url": "https://api.github.com/repos/adnelson/taskserver/languages", + "watchers": 0, + "git_tags_url": "https://api.github.com/repos/adnelson/taskserver/git/tags{/sha}", + "releases_url": "https://api.github.com/repos/adnelson/taskserver/releases{/id}" + }, + "label": "adnelson:master", + "sha": "a0a6ca750da52b5337527004ae039d7816868ad1" + }, + "changed_files": 1, + "deletions": 0, + "commits_url": "https://api.github.com/repos/adnelson/taskserver/pulls/1/commits", + "locked": false, + "mergeable_state": "unknown", + "assignees": [], + "html_url": "https://github.com/adnelson/taskserver/pull/1", + "rebaseable": null, + "merged": false, + "merged_by": null, + "closed_at": null, + "created_at": "2017-07-31T18:14:37Z", + "patch_url": "https://github.com/adnelson/taskserver/pull/1.patch", + "_links": { + "html": { + "href": "https://github.com/adnelson/taskserver/pull/1" + }, + "review_comment": { + "href": "https://api.github.com/repos/adnelson/taskserver/pulls/comments{/number}" + }, + "commits": { + "href": "https://api.github.com/repos/adnelson/taskserver/pulls/1/commits" + }, + "review_comments": { + "href": "https://api.github.com/repos/adnelson/taskserver/pulls/1/comments" + }, + "comments": { + "href": "https://api.github.com/repos/adnelson/taskserver/issues/1/comments" + }, + "statuses": { + "href": "https://api.github.com/repos/adnelson/taskserver/statuses/6e4e1a77e6cc98c0cac43f545187fba86b866082" + }, + "self": { + "href": "https://api.github.com/repos/adnelson/taskserver/pulls/1" + }, + "issue": { + "href": "https://api.github.com/repos/adnelson/taskserver/issues/1" + } + }, + "review_comments": 0, + "body": "blah blah", + "requested_reviewers": [], + "id": 133303711, + "merged_at": null, + "updated_at": "2017-07-31T18:14:37Z", + "mergeable": null, + "head": { + "ref": "adnelson-patch-1", + "user": { + "organizations_url": "https://api.github.com/users/adnelson/orgs", + "login": "adnelson", + "events_url": "https://api.github.com/users/adnelson/events{/privacy}", + "following_url": "https://api.github.com/users/adnelson/following{/other_user}", + "subscriptions_url": "https://api.github.com/users/adnelson/subscriptions", + "id": 5091511, + "site_admin": false, + "starred_url": "https://api.github.com/users/adnelson/starred{/owner}{/repo}", + "avatar_url": "https://avatars2.githubusercontent.com/u/5091511?v=4", + "type": "User", + "received_events_url": "https://api.github.com/users/adnelson/received_events", + "html_url": "https://github.com/adnelson", + "gravatar_id": "", + "gists_url": "https://api.github.com/users/adnelson/gists{/gist_id}", + "url": "https://api.github.com/users/adnelson", + "followers_url": "https://api.github.com/users/adnelson/followers", + "repos_url": "https://api.github.com/users/adnelson/repos" + }, + "repo": { + "git_commits_url": "https://api.github.com/repos/adnelson/taskserver/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/adnelson/taskserver/comments{/number}", + "assignees_url": "https://api.github.com/repos/adnelson/taskserver/assignees{/user}", + "milestones_url": "https://api.github.com/repos/adnelson/taskserver/milestones{/number}", + "has_issues": true, + "ssh_url": "git@github.com:adnelson/taskserver.git", + "has_projects": true, + "fork": false, + "watchers_count": 0, + "labels_url": "https://api.github.com/repos/adnelson/taskserver/labels{/name}", + "owner": { + "organizations_url": "https://api.github.com/users/adnelson/orgs", + "login": "adnelson", + "events_url": "https://api.github.com/users/adnelson/events{/privacy}", + "following_url": "https://api.github.com/users/adnelson/following{/other_user}", + "subscriptions_url": "https://api.github.com/users/adnelson/subscriptions", + "id": 5091511, + "site_admin": false, + "starred_url": "https://api.github.com/users/adnelson/starred{/owner}{/repo}", + "avatar_url": "https://avatars2.githubusercontent.com/u/5091511?v=4", + "type": "User", + "received_events_url": "https://api.github.com/users/adnelson/received_events", + "html_url": "https://github.com/adnelson", + "gravatar_id": "", + "gists_url": "https://api.github.com/users/adnelson/gists{/gist_id}", + "url": "https://api.github.com/users/adnelson", + "followers_url": "https://api.github.com/users/adnelson/followers", + "repos_url": "https://api.github.com/users/adnelson/repos" + }, + "html_url": "https://github.com/adnelson/taskserver", + "default_branch": "master", + "homepage": null, + "archive_url": "https://api.github.com/repos/adnelson/taskserver/{archive_format}{/ref}", + "subscribers_url": "https://api.github.com/repos/adnelson/taskserver/subscribers", + "git_url": "git://github.com/adnelson/taskserver.git", + "open_issues": 1, + "notifications_url": "https://api.github.com/repos/adnelson/taskserver/notifications{?since,all,participating}", + "forks": 0, + "branches_url": "https://api.github.com/repos/adnelson/taskserver/branches{/branch}", + "downloads_url": "https://api.github.com/repos/adnelson/taskserver/downloads", + "forks_count": 0, + "has_wiki": true, + "pulls_url": "https://api.github.com/repos/adnelson/taskserver/pulls{/number}", + "keys_url": "https://api.github.com/repos/adnelson/taskserver/keys{/key_id}", + "clone_url": "https://github.com/adnelson/taskserver.git", + "stargazers_url": "https://api.github.com/repos/adnelson/taskserver/stargazers", + "merges_url": "https://api.github.com/repos/adnelson/taskserver/merges", + "private": true, + "url": "https://api.github.com/repos/adnelson/taskserver", + "size": 148, + "contributors_url": "https://api.github.com/repos/adnelson/taskserver/contributors", + "issue_comment_url": "https://api.github.com/repos/adnelson/taskserver/issues/comments{/number}", + "blobs_url": "https://api.github.com/repos/adnelson/taskserver/git/blobs{/sha}", + "full_name": "adnelson/taskserver", + "commits_url": "https://api.github.com/repos/adnelson/taskserver/commits{/sha}", + "teams_url": "https://api.github.com/repos/adnelson/taskserver/teams", + "name": "taskserver", + "collaborators_url": "https://api.github.com/repos/adnelson/taskserver/collaborators{/collaborator}", + "pushed_at": "2017-07-31T18:08:56Z", + "forks_url": "https://api.github.com/repos/adnelson/taskserver/forks", + "trees_url": "https://api.github.com/repos/adnelson/taskserver/git/trees{/sha}", + "tags_url": "https://api.github.com/repos/adnelson/taskserver/tags", + "issue_events_url": "https://api.github.com/repos/adnelson/taskserver/issues/events{/number}", + "mirror_url": null, + "has_downloads": true, + "svn_url": "https://github.com/adnelson/taskserver", + "subscription_url": "https://api.github.com/repos/adnelson/taskserver/subscription", + "git_refs_url": "https://api.github.com/repos/adnelson/taskserver/git/refs{/sha}", + "created_at": "2017-07-07T22:39:54Z", + "description": "Server that does tasks", + "events_url": "https://api.github.com/repos/adnelson/taskserver/events", + "has_pages": false, + "language": "JavaScript", + "stargazers_count": 0, + "compare_url": "https://api.github.com/repos/adnelson/taskserver/compare/{base}...{head}", + "issues_url": "https://api.github.com/repos/adnelson/taskserver/issues{/number}", + "contents_url": "https://api.github.com/repos/adnelson/taskserver/contents/{+path}", + "updated_at": "2017-07-31T14:44:25Z", + "hooks_url": "https://api.github.com/repos/adnelson/taskserver/hooks", + "deployments_url": "https://api.github.com/repos/adnelson/taskserver/deployments", + "id": 96581526, + "statuses_url": "https://api.github.com/repos/adnelson/taskserver/statuses/{sha}", + "open_issues_count": 1, + "languages_url": "https://api.github.com/repos/adnelson/taskserver/languages", + "watchers": 0, + "git_tags_url": "https://api.github.com/repos/adnelson/taskserver/git/tags{/sha}", + "releases_url": "https://api.github.com/repos/adnelson/taskserver/releases{/id}" + }, + "label": "adnelson:adnelson-patch-1", + "sha": "6e4e1a77e6cc98c0cac43f545187fba86b866082" + }, + "maintainer_can_modify": false, + "statuses_url": "https://api.github.com/repos/adnelson/taskserver/statuses/6e4e1a77e6cc98c0cac43f545187fba86b866082", + "number": 1, + "commits": 1, + "diff_url": "https://github.com/adnelson/taskserver/pull/1.diff", + "milestone": null, + "comments": 0, + "merge_commit_sha": null, + "url": "https://api.github.com/repos/adnelson/taskserver/pulls/1", + "additions": 1, + "state": "open" + }, + "number": 1, + "sender": { + "organizations_url": "https://api.github.com/users/adnelson/orgs", + "login": "adnelson", + "events_url": "https://api.github.com/users/adnelson/events{/privacy}", + "following_url": "https://api.github.com/users/adnelson/following{/other_user}", + "subscriptions_url": "https://api.github.com/users/adnelson/subscriptions", + "id": 5091511, + "site_admin": false, + "starred_url": "https://api.github.com/users/adnelson/starred{/owner}{/repo}", + "avatar_url": "https://avatars2.githubusercontent.com/u/5091511?v=4", + "type": "User", + "received_events_url": "https://api.github.com/users/adnelson/received_events", + "html_url": "https://github.com/adnelson", + "gravatar_id": "", + "gists_url": "https://api.github.com/users/adnelson/gists{/gist_id}", + "url": "https://api.github.com/users/adnelson", + "followers_url": "https://api.github.com/users/adnelson/followers", + "repos_url": "https://api.github.com/users/adnelson/repos" + } +} diff --git a/fixtures/pull-request-realworld.json b/fixtures/pull-request-realworld.json new file mode 100644 index 00000000..de8ac8ba --- /dev/null +++ b/fixtures/pull-request-realworld.json @@ -0,0 +1,350 @@ +{ + "url": "https://api.github.com/repos/phadej/github/pulls/285", + "id": 133345191, + "html_url": "https://github.com/phadej/github/pull/285", + "diff_url": "https://github.com/phadej/github/pull/285.diff", + "patch_url": "https://github.com/phadej/github/pull/285.patch", + "issue_url": "https://api.github.com/repos/phadej/github/issues/285", + "number": 285, + "state": "open", + "locked": false, + "title": "fix the PullRequest object so it can parse", + "user": { + "login": "adnelson", + "id": 5091511, + "avatar_url": "https://avatars2.githubusercontent.com/u/5091511?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/adnelson", + "html_url": "https://github.com/adnelson", + "followers_url": "https://api.github.com/users/adnelson/followers", + "following_url": "https://api.github.com/users/adnelson/following{/other_user}", + "gists_url": "https://api.github.com/users/adnelson/gists{/gist_id}", + "starred_url": "https://api.github.com/users/adnelson/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/adnelson/subscriptions", + "organizations_url": "https://api.github.com/users/adnelson/orgs", + "repos_url": "https://api.github.com/users/adnelson/repos", + "events_url": "https://api.github.com/users/adnelson/events{/privacy}", + "received_events_url": "https://api.github.com/users/adnelson/received_events", + "type": "User", + "site_admin": false + }, + "body": "I'm not positive this covers every variant of a pull request event, but prior to this change the `FromJSON` instance failed to decode the [example json](https://developer.github.com/v3/activity/events/types/#pullrequestevent) (which is where the JSON I included here comes from) in the API docs, and now it does.", + "created_at": "2017-07-31T21:50:19Z", + "updated_at": "2017-08-02T08:26:08Z", + "closed_at": null, + "merged_at": null, + "merge_commit_sha": "36d6962cdeae16d49138054da9ed547b151268f5", + "assignee": { + "login": "phadej", + "id": 51087, + "avatar_url": "https://avatars2.githubusercontent.com/u/51087?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/phadej", + "html_url": "https://github.com/phadej", + "followers_url": "https://api.github.com/users/phadej/followers", + "following_url": "https://api.github.com/users/phadej/following{/other_user}", + "gists_url": "https://api.github.com/users/phadej/gists{/gist_id}", + "starred_url": "https://api.github.com/users/phadej/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/phadej/subscriptions", + "organizations_url": "https://api.github.com/users/phadej/orgs", + "repos_url": "https://api.github.com/users/phadej/repos", + "events_url": "https://api.github.com/users/phadej/events{/privacy}", + "received_events_url": "https://api.github.com/users/phadej/received_events", + "type": "User", + "site_admin": false + }, + "assignees": [ + { + "login": "phadej", + "id": 51087, + "avatar_url": "https://avatars2.githubusercontent.com/u/51087?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/phadej", + "html_url": "https://github.com/phadej", + "followers_url": "https://api.github.com/users/phadej/followers", + "following_url": "https://api.github.com/users/phadej/following{/other_user}", + "gists_url": "https://api.github.com/users/phadej/gists{/gist_id}", + "starred_url": "https://api.github.com/users/phadej/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/phadej/subscriptions", + "organizations_url": "https://api.github.com/users/phadej/orgs", + "repos_url": "https://api.github.com/users/phadej/repos", + "events_url": "https://api.github.com/users/phadej/events{/privacy}", + "received_events_url": "https://api.github.com/users/phadej/received_events", + "type": "User", + "site_admin": false + } + ], + "requested_reviewers": [ + + ], + "milestone": null, + "commits_url": "https://api.github.com/repos/phadej/github/pulls/285/commits", + "review_comments_url": "https://api.github.com/repos/phadej/github/pulls/285/comments", + "review_comment_url": "https://api.github.com/repos/phadej/github/pulls/comments{/number}", + "comments_url": "https://api.github.com/repos/phadej/github/issues/285/comments", + "statuses_url": "https://api.github.com/repos/phadej/github/statuses/6e92ab740cc3bb5b569aff9f9377bb4924351ea9", + "head": { + "label": "adnelson:fix_pull_request", + "ref": "fix_pull_request", + "sha": "6e92ab740cc3bb5b569aff9f9377bb4924351ea9", + "user": { + "login": "adnelson", + "id": 5091511, + "avatar_url": "https://avatars2.githubusercontent.com/u/5091511?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/adnelson", + "html_url": "https://github.com/adnelson", + "followers_url": "https://api.github.com/users/adnelson/followers", + "following_url": "https://api.github.com/users/adnelson/following{/other_user}", + "gists_url": "https://api.github.com/users/adnelson/gists{/gist_id}", + "starred_url": "https://api.github.com/users/adnelson/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/adnelson/subscriptions", + "organizations_url": "https://api.github.com/users/adnelson/orgs", + "repos_url": "https://api.github.com/users/adnelson/repos", + "events_url": "https://api.github.com/users/adnelson/events{/privacy}", + "received_events_url": "https://api.github.com/users/adnelson/received_events", + "type": "User", + "site_admin": false + }, + "repo": { + "id": 98932125, + "name": "github", + "full_name": "adnelson/github", + "owner": { + "login": "adnelson", + "id": 5091511, + "avatar_url": "https://avatars2.githubusercontent.com/u/5091511?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/adnelson", + "html_url": "https://github.com/adnelson", + "followers_url": "https://api.github.com/users/adnelson/followers", + "following_url": "https://api.github.com/users/adnelson/following{/other_user}", + "gists_url": "https://api.github.com/users/adnelson/gists{/gist_id}", + "starred_url": "https://api.github.com/users/adnelson/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/adnelson/subscriptions", + "organizations_url": "https://api.github.com/users/adnelson/orgs", + "repos_url": "https://api.github.com/users/adnelson/repos", + "events_url": "https://api.github.com/users/adnelson/events{/privacy}", + "received_events_url": "https://api.github.com/users/adnelson/received_events", + "type": "User", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/adnelson/github", + "description": "The github API for Haskell", + "fork": true, + "url": "https://api.github.com/repos/adnelson/github", + "forks_url": "https://api.github.com/repos/adnelson/github/forks", + "keys_url": "https://api.github.com/repos/adnelson/github/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/adnelson/github/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/adnelson/github/teams", + "hooks_url": "https://api.github.com/repos/adnelson/github/hooks", + "issue_events_url": "https://api.github.com/repos/adnelson/github/issues/events{/number}", + "events_url": "https://api.github.com/repos/adnelson/github/events", + "assignees_url": "https://api.github.com/repos/adnelson/github/assignees{/user}", + "branches_url": "https://api.github.com/repos/adnelson/github/branches{/branch}", + "tags_url": "https://api.github.com/repos/adnelson/github/tags", + "blobs_url": "https://api.github.com/repos/adnelson/github/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/adnelson/github/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/adnelson/github/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/adnelson/github/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/adnelson/github/statuses/{sha}", + "languages_url": "https://api.github.com/repos/adnelson/github/languages", + "stargazers_url": "https://api.github.com/repos/adnelson/github/stargazers", + "contributors_url": "https://api.github.com/repos/adnelson/github/contributors", + "subscribers_url": "https://api.github.com/repos/adnelson/github/subscribers", + "subscription_url": "https://api.github.com/repos/adnelson/github/subscription", + "commits_url": "https://api.github.com/repos/adnelson/github/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/adnelson/github/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/adnelson/github/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/adnelson/github/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/adnelson/github/contents/{+path}", + "compare_url": "https://api.github.com/repos/adnelson/github/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/adnelson/github/merges", + "archive_url": "https://api.github.com/repos/adnelson/github/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/adnelson/github/downloads", + "issues_url": "https://api.github.com/repos/adnelson/github/issues{/number}", + "pulls_url": "https://api.github.com/repos/adnelson/github/pulls{/number}", + "milestones_url": "https://api.github.com/repos/adnelson/github/milestones{/number}", + "notifications_url": "https://api.github.com/repos/adnelson/github/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/adnelson/github/labels{/name}", + "releases_url": "https://api.github.com/repos/adnelson/github/releases{/id}", + "deployments_url": "https://api.github.com/repos/adnelson/github/deployments", + "created_at": "2017-07-31T21:38:16Z", + "updated_at": "2017-07-31T21:38:17Z", + "pushed_at": "2017-08-01T18:04:46Z", + "git_url": "git://github.com/adnelson/github.git", + "ssh_url": "git@github.com:adnelson/github.git", + "clone_url": "https://github.com/adnelson/github.git", + "svn_url": "https://github.com/adnelson/github", + "homepage": "", + "size": 942, + "stargazers_count": 0, + "watchers_count": 0, + "language": "Haskell", + "has_issues": false, + "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": "master" + } + }, + "base": { + "label": "phadej:master", + "ref": "master", + "sha": "05eef68bc8fb625df6aaf7cc7b66aef3ad154e26", + "user": { + "login": "phadej", + "id": 51087, + "avatar_url": "https://avatars2.githubusercontent.com/u/51087?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/phadej", + "html_url": "https://github.com/phadej", + "followers_url": "https://api.github.com/users/phadej/followers", + "following_url": "https://api.github.com/users/phadej/following{/other_user}", + "gists_url": "https://api.github.com/users/phadej/gists{/gist_id}", + "starred_url": "https://api.github.com/users/phadej/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/phadej/subscriptions", + "organizations_url": "https://api.github.com/users/phadej/orgs", + "repos_url": "https://api.github.com/users/phadej/repos", + "events_url": "https://api.github.com/users/phadej/events{/privacy}", + "received_events_url": "https://api.github.com/users/phadej/received_events", + "type": "User", + "site_admin": false + }, + "repo": { + "id": 2677437, + "name": "github", + "full_name": "phadej/github", + "owner": { + "login": "phadej", + "id": 51087, + "avatar_url": "https://avatars2.githubusercontent.com/u/51087?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/phadej", + "html_url": "https://github.com/phadej", + "followers_url": "https://api.github.com/users/phadej/followers", + "following_url": "https://api.github.com/users/phadej/following{/other_user}", + "gists_url": "https://api.github.com/users/phadej/gists{/gist_id}", + "starred_url": "https://api.github.com/users/phadej/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/phadej/subscriptions", + "organizations_url": "https://api.github.com/users/phadej/orgs", + "repos_url": "https://api.github.com/users/phadej/repos", + "events_url": "https://api.github.com/users/phadej/events{/privacy}", + "received_events_url": "https://api.github.com/users/phadej/received_events", + "type": "User", + "site_admin": false + }, + "private": false, + "html_url": "https://github.com/phadej/github", + "description": "The github API for Haskell", + "fork": false, + "url": "https://api.github.com/repos/phadej/github", + "forks_url": "https://api.github.com/repos/phadej/github/forks", + "keys_url": "https://api.github.com/repos/phadej/github/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/phadej/github/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/phadej/github/teams", + "hooks_url": "https://api.github.com/repos/phadej/github/hooks", + "issue_events_url": "https://api.github.com/repos/phadej/github/issues/events{/number}", + "events_url": "https://api.github.com/repos/phadej/github/events", + "assignees_url": "https://api.github.com/repos/phadej/github/assignees{/user}", + "branches_url": "https://api.github.com/repos/phadej/github/branches{/branch}", + "tags_url": "https://api.github.com/repos/phadej/github/tags", + "blobs_url": "https://api.github.com/repos/phadej/github/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/phadej/github/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/phadej/github/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/phadej/github/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/phadej/github/statuses/{sha}", + "languages_url": "https://api.github.com/repos/phadej/github/languages", + "stargazers_url": "https://api.github.com/repos/phadej/github/stargazers", + "contributors_url": "https://api.github.com/repos/phadej/github/contributors", + "subscribers_url": "https://api.github.com/repos/phadej/github/subscribers", + "subscription_url": "https://api.github.com/repos/phadej/github/subscription", + "commits_url": "https://api.github.com/repos/phadej/github/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/phadej/github/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/phadej/github/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/phadej/github/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/phadej/github/contents/{+path}", + "compare_url": "https://api.github.com/repos/phadej/github/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/phadej/github/merges", + "archive_url": "https://api.github.com/repos/phadej/github/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/phadej/github/downloads", + "issues_url": "https://api.github.com/repos/phadej/github/issues{/number}", + "pulls_url": "https://api.github.com/repos/phadej/github/pulls{/number}", + "milestones_url": "https://api.github.com/repos/phadej/github/milestones{/number}", + "notifications_url": "https://api.github.com/repos/phadej/github/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/phadej/github/labels{/name}", + "releases_url": "https://api.github.com/repos/phadej/github/releases{/id}", + "deployments_url": "https://api.github.com/repos/phadej/github/deployments", + "created_at": "2011-10-30T22:38:34Z", + "updated_at": "2017-07-25T01:39:27Z", + "pushed_at": "2017-08-01T18:04:48Z", + "git_url": "git://github.com/phadej/github.git", + "ssh_url": "git@github.com:phadej/github.git", + "clone_url": "https://github.com/phadej/github.git", + "svn_url": "https://github.com/phadej/github", + "homepage": "", + "size": 937, + "stargazers_count": 223, + "watchers_count": 223, + "language": "Haskell", + "has_issues": true, + "has_projects": true, + "has_downloads": true, + "has_wiki": true, + "has_pages": false, + "forks_count": 111, + "mirror_url": null, + "open_issues_count": 22, + "forks": 111, + "open_issues": 22, + "watchers": 223, + "default_branch": "master" + } + }, + "_links": { + "self": { + "href": "https://api.github.com/repos/phadej/github/pulls/285" + }, + "html": { + "href": "https://github.com/phadej/github/pull/285" + }, + "issue": { + "href": "https://api.github.com/repos/phadej/github/issues/285" + }, + "comments": { + "href": "https://api.github.com/repos/phadej/github/issues/285/comments" + }, + "review_comments": { + "href": "https://api.github.com/repos/phadej/github/pulls/285/comments" + }, + "review_comment": { + "href": "https://api.github.com/repos/phadej/github/pulls/comments{/number}" + }, + "commits": { + "href": "https://api.github.com/repos/phadej/github/pulls/285/commits" + }, + "statuses": { + "href": "https://api.github.com/repos/phadej/github/statuses/6e92ab740cc3bb5b569aff9f9377bb4924351ea9" + } + }, + "merged": false, + "mergeable": true, + "rebaseable": true, + "mergeable_state": "clean", + "merged_by": null, + "comments": 3, + "review_comments": 3, + "maintainer_can_modify": true, + "commits": 2, + "additions": 446, + "deletions": 13, + "changed_files": 4 +} diff --git a/github.cabal b/github.cabal index 06d8b7da..1a9fa0d1 100644 --- a/github.cabal +++ b/github.cabal @@ -34,7 +34,11 @@ extra-source-files: fixtures/list-teams.json, fixtures/members-list.json, fixtures/user-organizations.json, - fixtures/user.json + fixtures/user.json, + fixtures/pull-request-realworld.json, + fixtures/pull-request-baxterthehacker.json, + fixtures/pull-request-event-github-example.json, + fixtures/pull-request-event-realworld.json flag aeson-compat description: Whether to use aeson-compat or aeson-extra @@ -188,9 +192,11 @@ test-suite github-test vector, unordered-containers, file-embed, + aeson, + text, + bytestring, hspec if flag(aeson-compat) build-depends: aeson-compat else build-depends: aeson-extra - diff --git a/spec/GitHub/PullRequestsSpec.hs b/spec/GitHub/PullRequestsSpec.hs index 78d1ab1c..dfaeaf92 100644 --- a/spec/GitHub/PullRequestsSpec.hs +++ b/spec/GitHub/PullRequestsSpec.hs @@ -1,4 +1,6 @@ {-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE TemplateHaskell #-} module GitHub.PullRequestsSpec where import qualified GitHub @@ -6,11 +8,17 @@ import qualified GitHub import Prelude () import Prelude.Compat +import Data.Aeson.Compat (eitherDecodeStrict) import Data.Either.Compat (isRight) import Data.Foldable (for_) import Data.String (fromString) +import qualified Data.Vector as V import System.Environment (lookupEnv) -import Test.Hspec (Spec, describe, it, pendingWith, shouldSatisfy) +import Data.FileEmbed (embedFile) +import Test.Hspec (Spec, describe, it, pendingWith, shouldSatisfy, shouldBe) +import GitHub.Data.Definitions (simpleUserLogin) +import GitHub.Data.Options (IssueState(..)) +import GitHub.Data.PullRequests fromRightS :: Show a => Either a b -> b fromRightS (Right b) = b @@ -28,8 +36,34 @@ spec = do describe "pullRequestsForR" $ do it "works" $ withAuth $ \auth -> for_ repos $ \(owner, repo) -> do cs <- GitHub.executeRequest auth $ - GitHub.pullRequestsForR owner repo opts GitHub.FetchAll + GitHub.pullRequestsForR owner repo opts GitHub.FetchAll cs `shouldSatisfy` isRight + describe "PullRequest" $ do + it "can parse PR json, from a PR to the github repo" $ do + let pr = fromRightS $ + eitherDecodeStrict $(embedFile "fixtures/pull-request-realworld.json") + + pullRequestState pr `shouldBe` StateOpen + simpleUserLogin (pullRequestUser pr) `shouldBe` "adnelson" + let [user] = V.toList (pullRequestAssignees pr) + simpleUserLogin user `shouldBe` "phadej" + it "can parse PR json, from the 'baxterthehacker' account" $ do + let pr = fromRightS $ + eitherDecodeStrict $(embedFile "fixtures/pull-request-baxterthehacker.json") + pullRequestState pr `shouldBe` StateClosed + simpleUserLogin (pullRequestUser pr) `shouldBe` "baxterthehacker" + describe "PullRequestEvent" $ do + it "can parse PR event json, example from github docs" $ do + let pre = fromRightS $ + eitherDecodeStrict $(embedFile "fixtures/pull-request-event-github-example.json") + pullRequestEventAction pre `shouldBe` PullRequestOpened + simpleUserLogin (pullRequestSender pre) `shouldBe` "baxterthehacker" + it "can parse PR event json, example from a real-world github repo" $ do + let pre = fromRightS $ + eitherDecodeStrict $(embedFile "fixtures/pull-request-event-realworld.json") + pullRequestEventAction pre `shouldBe` PullRequestOpened + simpleUserLogin (pullRequestSender pre) `shouldBe` "adnelson" + where repos = [ ("thoughtbot", "paperclip") diff --git a/src/GitHub/Data/PullRequests.hs b/src/GitHub/Data/PullRequests.hs index ab0d1976..5e60f206 100644 --- a/src/GitHub/Data/PullRequests.hs +++ b/src/GitHub/Data/PullRequests.hs @@ -24,6 +24,9 @@ import GitHub.Data.Repos (Repo) import GitHub.Data.Request (StatusMap) import GitHub.Data.URL (URL) import GitHub.Internal.Prelude +import Data.Vector as V (elem, snoc) +import Data.Aeson.Types (Parser) +import qualified Data.Text as T import Prelude () import qualified Data.Text as T @@ -38,7 +41,7 @@ data SimplePullRequest = SimplePullRequest , simplePullRequestHtmlUrl :: !URL , simplePullRequestUpdatedAt :: !UTCTime , simplePullRequestBody :: !(Maybe Text) - , simplePullRequestAssignees :: (Vector SimpleUser) + , simplePullRequestAssignees :: !(Vector SimpleUser) , simplePullRequestIssueUrl :: !URL , simplePullRequestDiffUrl :: !URL , simplePullRequestUrl :: !URL @@ -62,7 +65,7 @@ data PullRequest = PullRequest , pullRequestHtmlUrl :: !URL , pullRequestUpdatedAt :: !UTCTime , pullRequestBody :: !(Maybe Text) - , pullRequestAssignees :: (Vector SimpleUser) + , pullRequestAssignees :: !(Vector SimpleUser) , pullRequestIssueUrl :: !URL , pullRequestDiffUrl :: !URL , pullRequestUrl :: !URL @@ -76,7 +79,6 @@ data PullRequest = PullRequest , pullRequestComments :: !Count , pullRequestDeletions :: !Count , pullRequestAdditions :: !Count - , pullRequestReviewComments :: !Count , pullRequestBase :: !PullRequestCommit , pullRequestCommits :: !Count , pullRequestMerged :: !Bool @@ -185,8 +187,22 @@ instance Binary PullRequestReference -- JSON instances ------------------------------------------------------------------------------- +-- | Helper function, reads either the "assignee" OR "assignees" OR +-- both from a JSON object. +getAssignees :: Object -> Parser (Vector SimpleUser) +getAssignees o = do + assignees <- o .:? "assignees" .!= mempty + maybeAssignee <- o .:? "assignee" + pure $ case maybeAssignee of + Nothing -> assignees + Just assignee | assignee `V.elem` assignees -> assignees + | otherwise -> assignees `V.snoc` assignee + instance FromJSON SimplePullRequest where - parseJSON = withObject "SimplePullRequest" $ \o -> SimplePullRequest + parseJSON = withObject "SimplePullRequest" $ \o -> do + -- | Either key, or both, might be present, and might contain + -- redundant information. Take both keys and uniquify the list. + SimplePullRequest <$> o .:? "closed_at" <*> o .: "created_at" <*> o .: "user" @@ -196,7 +212,7 @@ instance FromJSON SimplePullRequest where <*> o .: "html_url" <*> o .: "updated_at" <*> o .:? "body" - <*> o .: "assignees" + <*> getAssignees o <*> o .: "issue_url" <*> o .: "diff_url" <*> o .: "url" @@ -236,7 +252,7 @@ instance FromJSON PullRequest where <*> o .: "html_url" <*> o .: "updated_at" <*> o .:? "body" - <*> o .: "assignees" + <*> getAssignees o <*> o .: "issue_url" <*> o .: "diff_url" <*> o .: "url" @@ -250,7 +266,6 @@ instance FromJSON PullRequest where <*> o .: "comments" <*> o .: "deletions" <*> o .: "additions" - <*> o .: "review_comments" <*> o .: "base" <*> o .: "commits" <*> o .: "merged"