From 7b61960bfd1d1ad1f81ed9dc646c54bae72d0e00 Mon Sep 17 00:00:00 2001 From: Allen Nelson Date: Mon, 31 Jul 2017 16:39:27 -0500 Subject: [PATCH 1/4] fix the PullRequest object so it can parse --- fixtures/pull-request.json | 415 ++++++++++++++++++++++++++++++++ github.cabal | 4 +- spec/GitHub/PullRequestsSpec.hs | 15 +- src/GitHub/Data/PullRequests.hs | 22 +- 4 files changed, 444 insertions(+), 12 deletions(-) create mode 100644 fixtures/pull-request.json diff --git a/fixtures/pull-request.json b/fixtures/pull-request.json new file mode 100644 index 00000000..0c37e40a --- /dev/null +++ b/fixtures/pull-request.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/github.cabal b/github.cabal index 304cf918..631aae97 100644 --- a/github.cabal +++ b/github.cabal @@ -185,9 +185,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..02bed7d7 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,14 @@ 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 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.PullRequests fromRightS :: Show a => Either a b -> b fromRightS (Right b) = b @@ -28,8 +33,14 @@ 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" $ do + let pr :: Either String PullRequestEvent = + eitherDecodeStrict $(embedFile "fixtures/pull-request.json") + pullRequestEventAction (fromRightS pr) `shouldBe` PullRequestOpened + where repos = [ ("thoughtbot", "paperclip") diff --git a/src/GitHub/Data/PullRequests.hs b/src/GitHub/Data/PullRequests.hs index d5148d87..0003eb2f 100644 --- a/src/GitHub/Data/PullRequests.hs +++ b/src/GitHub/Data/PullRequests.hs @@ -19,11 +19,12 @@ module GitHub.Data.PullRequests ( import GitHub.Data.Definitions import GitHub.Data.Id (Id) -import GitHub.Data.Options (IssueState (..), MergeableState (..)) +import GitHub.Data.Options (IssueState (..)) import GitHub.Data.Repos (Repo) import GitHub.Data.Request (StatusMap) import GitHub.Data.URL (URL) import GitHub.Internal.Prelude +import qualified Data.Text as T import Prelude () data SimplePullRequest = SimplePullRequest @@ -36,7 +37,7 @@ data SimplePullRequest = SimplePullRequest , simplePullRequestHtmlUrl :: !URL , simplePullRequestUpdatedAt :: !UTCTime , simplePullRequestBody :: !(Maybe Text) - , simplePullRequestAssignees :: (Vector SimpleUser) + , simplePullRequestAssignee :: !(Maybe SimpleUser) , simplePullRequestIssueUrl :: !URL , simplePullRequestDiffUrl :: !URL , simplePullRequestUrl :: !URL @@ -60,7 +61,7 @@ data PullRequest = PullRequest , pullRequestHtmlUrl :: !URL , pullRequestUpdatedAt :: !UTCTime , pullRequestBody :: !(Maybe Text) - , pullRequestAssignees :: (Vector SimpleUser) + , pullRequestAssignee :: !(Maybe SimpleUser) , pullRequestIssueUrl :: !URL , pullRequestDiffUrl :: !URL , pullRequestUrl :: !URL @@ -74,12 +75,10 @@ data PullRequest = PullRequest , pullRequestComments :: !Count , pullRequestDeletions :: !Count , pullRequestAdditions :: !Count - , pullRequestReviewComments :: !Count , pullRequestBase :: !PullRequestCommit , pullRequestCommits :: !Count , pullRequestMerged :: !Bool , pullRequestMergeable :: !(Maybe Bool) - , pullRequestMergeableState :: !MergeableState } deriving (Show, Data, Typeable, Eq, Ord, Generic) @@ -160,6 +159,9 @@ data PullRequestEventType | PullRequestUnassigned | PullRequestLabeled | PullRequestUnlabeled + | PullRequestReviewRequested + | PullRequestReviewRequestRemoved + | PullRequestEdited deriving (Show, Data, Typeable, Eq, Ord, Generic) instance NFData PullRequestEventType where rnf = genericRnf @@ -191,7 +193,7 @@ instance FromJSON SimplePullRequest where <*> o .: "html_url" <*> o .: "updated_at" <*> o .:? "body" - <*> o .: "assignees" + <*> o .: "assignee" <*> o .: "issue_url" <*> o .: "diff_url" <*> o .: "url" @@ -231,7 +233,7 @@ instance FromJSON PullRequest where <*> o .: "html_url" <*> o .: "updated_at" <*> o .:? "body" - <*> o .: "assignees" + <*> o .: "assignee" <*> o .: "issue_url" <*> o .: "diff_url" <*> o .: "url" @@ -245,12 +247,10 @@ instance FromJSON PullRequest where <*> o .: "comments" <*> o .: "deletions" <*> o .: "additions" - <*> o .: "review_comments" <*> o .: "base" <*> o .: "commits" <*> o .: "merged" <*> o .:? "mergeable" - <*> o .: "mergeable_state" instance FromJSON PullRequestLinks where parseJSON = withObject "PullRequestLinks" $ \o -> PullRequestLinks @@ -284,6 +284,10 @@ instance FromJSON PullRequestEventType where parseJSON (String "unassigned") = pure PullRequestUnassigned parseJSON (String "labeled") = pure PullRequestLabeled parseJSON (String "unlabeled") = pure PullRequestUnlabeled + parseJSON (String "review_requested") = pure PullRequestReviewRequested + parseJSON (String "review_request_removed") = pure PullRequestReviewRequestRemoved + parseJSON (String "edited") = pure PullRequestEdited + parseJSON (String s) = fail $ "Unknown action type " <> T.unpack s parseJSON v = typeMismatch "Could not build a PullRequestEventType" v instance FromJSON PullRequestReference where From 6e92ab740cc3bb5b569aff9f9377bb4924351ea9 Mon Sep 17 00:00:00 2001 From: Allen Nelson Date: Tue, 1 Aug 2017 13:04:43 -0500 Subject: [PATCH 2/4] add pull-request fixture to cabal file --- github.cabal | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/github.cabal b/github.cabal index 631aae97..67bea94d 100644 --- a/github.cabal +++ b/github.cabal @@ -34,7 +34,8 @@ extra-source-files: fixtures/list-teams.json, fixtures/members-list.json, fixtures/user-organizations.json, - fixtures/user.json + fixtures/user.json, + fixtures/pull-request.json flag aeson-compat description: Whether to use aeson-compat or aeson-extra From e76f68e97459dee8433315fd31f4c7ee1123109c Mon Sep 17 00:00:00 2001 From: Allen Nelson Date: Wed, 2 Aug 2017 11:01:06 -0500 Subject: [PATCH 3/4] include several more examples, support multiple assignees --- fixtures/pull-request-baxterthehacker.json | 314 +++++++++++++ ...=> pull-request-event-github-example.json} | 0 fixtures/pull-request-event-realworld.json | 422 ++++++++++++++++++ fixtures/pull-request-realworld.json | 350 +++++++++++++++ github.cabal | 5 +- spec/GitHub/PullRequestsSpec.hs | 31 +- src/GitHub/Data/PullRequests.hs | 26 +- 7 files changed, 1138 insertions(+), 10 deletions(-) create mode 100644 fixtures/pull-request-baxterthehacker.json rename fixtures/{pull-request.json => pull-request-event-github-example.json} (100%) create mode 100644 fixtures/pull-request-event-realworld.json create mode 100644 fixtures/pull-request-realworld.json 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.json b/fixtures/pull-request-event-github-example.json similarity index 100% rename from fixtures/pull-request.json rename to fixtures/pull-request-event-github-example.json 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 67bea94d..a0773b9d 100644 --- a/github.cabal +++ b/github.cabal @@ -35,7 +35,10 @@ extra-source-files: fixtures/members-list.json, fixtures/user-organizations.json, fixtures/user.json, - fixtures/pull-request.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 diff --git a/spec/GitHub/PullRequestsSpec.hs b/spec/GitHub/PullRequestsSpec.hs index 02bed7d7..dfaeaf92 100644 --- a/spec/GitHub/PullRequestsSpec.hs +++ b/spec/GitHub/PullRequestsSpec.hs @@ -12,9 +12,12 @@ 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 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 @@ -36,10 +39,30 @@ spec = do GitHub.pullRequestsForR owner repo opts GitHub.FetchAll cs `shouldSatisfy` isRight describe "PullRequest" $ do - it "can parse PR json" $ do - let pr :: Either String PullRequestEvent = - eitherDecodeStrict $(embedFile "fixtures/pull-request.json") - pullRequestEventAction (fromRightS pr) `shouldBe` PullRequestOpened + 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 = diff --git a/src/GitHub/Data/PullRequests.hs b/src/GitHub/Data/PullRequests.hs index 0003eb2f..59c58975 100644 --- a/src/GitHub/Data/PullRequests.hs +++ b/src/GitHub/Data/PullRequests.hs @@ -24,6 +24,8 @@ 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 () @@ -37,7 +39,7 @@ data SimplePullRequest = SimplePullRequest , simplePullRequestHtmlUrl :: !URL , simplePullRequestUpdatedAt :: !UTCTime , simplePullRequestBody :: !(Maybe Text) - , simplePullRequestAssignee :: !(Maybe SimpleUser) + , simplePullRequestAssignees :: !(Vector SimpleUser) , simplePullRequestIssueUrl :: !URL , simplePullRequestDiffUrl :: !URL , simplePullRequestUrl :: !URL @@ -61,7 +63,7 @@ data PullRequest = PullRequest , pullRequestHtmlUrl :: !URL , pullRequestUpdatedAt :: !UTCTime , pullRequestBody :: !(Maybe Text) - , pullRequestAssignee :: !(Maybe SimpleUser) + , pullRequestAssignees :: !(Vector SimpleUser) , pullRequestIssueUrl :: !URL , pullRequestDiffUrl :: !URL , pullRequestUrl :: !URL @@ -182,8 +184,22 @@ instance Binary PullRequestReference -- JSON instances ------------------------------------------------------------------------------- +-- | Helper function, reads either the "assignee" OR "assigneed" 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" @@ -193,7 +209,7 @@ instance FromJSON SimplePullRequest where <*> o .: "html_url" <*> o .: "updated_at" <*> o .:? "body" - <*> o .: "assignee" + <*> getAssignees o <*> o .: "issue_url" <*> o .: "diff_url" <*> o .: "url" @@ -233,7 +249,7 @@ instance FromJSON PullRequest where <*> o .: "html_url" <*> o .: "updated_at" <*> o .:? "body" - <*> o .: "assignee" + <*> getAssignees o <*> o .: "issue_url" <*> o .: "diff_url" <*> o .: "url" From d067056eaf2d3ea211853a3f82e929df4fbbc65d Mon Sep 17 00:00:00 2001 From: Allen Nelson Date: Wed, 2 Aug 2017 12:19:22 -0500 Subject: [PATCH 4/4] fix cabal file, reintroduce mergeable_state field --- github.cabal | 4 ++-- src/GitHub/Data/PullRequests.hs | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/github.cabal b/github.cabal index a0773b9d..266a6dcb 100644 --- a/github.cabal +++ b/github.cabal @@ -37,8 +37,8 @@ extra-source-files: 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, + 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 diff --git a/src/GitHub/Data/PullRequests.hs b/src/GitHub/Data/PullRequests.hs index 59c58975..9df82dd3 100644 --- a/src/GitHub/Data/PullRequests.hs +++ b/src/GitHub/Data/PullRequests.hs @@ -19,7 +19,7 @@ module GitHub.Data.PullRequests ( import GitHub.Data.Definitions import GitHub.Data.Id (Id) -import GitHub.Data.Options (IssueState (..)) +import GitHub.Data.Options (IssueState (..), MergeableState (..)) import GitHub.Data.Repos (Repo) import GitHub.Data.Request (StatusMap) import GitHub.Data.URL (URL) @@ -81,6 +81,7 @@ data PullRequest = PullRequest , pullRequestCommits :: !Count , pullRequestMerged :: !Bool , pullRequestMergeable :: !(Maybe Bool) + , pullRequestMergeableState :: !MergeableState } deriving (Show, Data, Typeable, Eq, Ord, Generic) @@ -184,7 +185,7 @@ instance Binary PullRequestReference -- JSON instances ------------------------------------------------------------------------------- --- | Helper function, reads either the "assignee" OR "assigneed" OR +-- | Helper function, reads either the "assignee" OR "assignees" OR -- both from a JSON object. getAssignees :: Object -> Parser (Vector SimpleUser) getAssignees o = do @@ -267,6 +268,7 @@ instance FromJSON PullRequest where <*> o .: "commits" <*> o .: "merged" <*> o .:? "mergeable" + <*> o .: "mergeable_state" instance FromJSON PullRequestLinks where parseJSON = withObject "PullRequestLinks" $ \o -> PullRequestLinks