{"action":"created","comment":{"url":"https://api.github.com/repos/sourcecred/sourcecred/pulls/comments/184839161","pull_request_review_id":116120803,"id":184839161,"diff_hunk":"@@ -0,0 +1,76 @@\n+// @flow\n+\n+import {parse} from \"./parser\";\n+import exampleRepoData from \"./demoData/example-repo.json\";\n+import {Repository, Issue, PullRequest, Comment, Author} from \"./api\";\n+import {\n+  AUTHOR_NODE_TYPE,\n+  COMMENT_NODE_TYPE,\n+  ISSUE_NODE_TYPE,\n+  PULL_REQUEST_NODE_TYPE,\n+} from \"./types\";\n+describe(\"GitHub porcelain API\", () => {\n+  const graph = parse(\"sourcecred/example-repo\", exampleRepoData);\n+  const repo = new Repository(\"sourcecred/example-repo\", graph);\n+\n+  it(\"Issue\", () => {\n+    const issue = repo.issueOrPRByNumber(1);\n+    if (issue == null) {\n+      throw new Error(\"Issue reaching issue!\");\n+    }\n+    expect(issue.title()).toBe(\"An example issue.\");\n+    expect(issue.body()).toBe(\"This is just an example issue.\");\n+    expect(issue.number()).toBe(1);\n+    expect(issue.type()).toBe(ISSUE_NODE_TYPE);\n+    expect(issue.url()).toBe(\n+      \"https://github.com/sourcecred/example-repo/issues/1\"\n+    );\n+    expect(issue.type()).toMatchSnapshot();\n+    expect(issue.authors()[0].login()).toBe(\"decentralion\");","path":"src/plugins/github/api.test.js","position":29,"original_position":29,"commit_id":"81ec7c6ebcaf4d872bd9a273c3c6df120958274e","original_commit_id":"81ec7c6ebcaf4d872bd9a273c3c6df120958274e","user":{"login":"wchargin","id":4317806,"avatar_url":"https://avatars3.githubusercontent.com/u/4317806?v=4","gravatar_id":"","url":"https://api.github.com/users/wchargin","html_url":"https://github.com/wchargin","followers_url":"https://api.github.com/users/wchargin/followers","following_url":"https://api.github.com/users/wchargin/following{/other_user}","gists_url":"https://api.github.com/users/wchargin/gists{/gist_id}","starred_url":"https://api.github.com/users/wchargin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wchargin/subscriptions","organizations_url":"https://api.github.com/users/wchargin/orgs","repos_url":"https://api.github.com/users/wchargin/repos","events_url":"https://api.github.com/users/wchargin/events{/privacy}","received_events_url":"https://api.github.com/users/wchargin/received_events","type":"User","site_admin":false},"body":"Stronger with `expect(issue.authors().map((x) => x.login())).toEqual([\"decentralion\"])`; up to you whether to change.","created_at":"2018-04-28T04:12:28Z","updated_at":"2018-04-28T04:27:15Z","html_url":"https://github.com/sourcecred/sourcecred/pull/170#discussion_r184839161","pull_request_url":"https://api.github.com/repos/sourcecred/sourcecred/pulls/170","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/sourcecred/sourcecred/pulls/comments/184839161"},"html":{"href":"https://github.com/sourcecred/sourcecred/pull/170#discussion_r184839161"},"pull_request":{"href":"https://api.github.com/repos/sourcecred/sourcecred/pulls/170"}}},"pull_request":{"url":"https://api.github.com/repos/sourcecred/sourcecred/pulls/170","id":184762912,"html_url":"https://github.com/sourcecred/sourcecred/pull/170","diff_url":"https://github.com/sourcecred/sourcecred/pull/170.diff","patch_url":"https://github.com/sourcecred/sourcecred/pull/170.patch","issue_url":"https://api.github.com/repos/sourcecred/sourcecred/issues/170","number":170,"state":"open","locked":false,"title":"Add a porcelain api for Github data","user":{"login":"decentralion","id":1400023,"avatar_url":"https://avatars2.githubusercontent.com/u/1400023?v=4","gravatar_id":"","url":"https://api.github.com/users/decentralion","html_url":"https://github.com/decentralion","followers_url":"https://api.github.com/users/decentralion/followers","following_url":"https://api.github.com/users/decentralion/following{/other_user}","gists_url":"https://api.github.com/users/decentralion/gists{/gist_id}","starred_url":"https://api.github.com/users/decentralion/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/decentralion/subscriptions","organizations_url":"https://api.github.com/users/decentralion/orgs","repos_url":"https://api.github.com/users/decentralion/repos","events_url":"https://api.github.com/users/decentralion/events{/privacy}","received_events_url":"https://api.github.com/users/decentralion/received_events","type":"User","site_admin":false},"body":"Interacting with raw contribution graphs is cumbersome. We'll need\r\nmore fluent and convenient ways to retrieve data from them; we can do\r\nthis by creating porcelain APIs that wrap the underlying graph.\r\n\r\nThis commit adds a simple porcelain API for the GitHub data. It creates\r\nthe following classes:\r\n\r\n* `api.Repository`\r\n* `api.Issue`\r\n* `api.PullRequest`\r\n* `api.Comment`\r\n* `api.Author`\r\n\r\nThe classes all wrap a graph and a nodeAddress. They provide read-only\r\nfunctions for retreiving data from the graph; that data might be a part\r\nof the node payload, or it might do some graph traversal under the hood.\r\n\r\nThe choice to have the wrapper hold onto the Address rather than the\r\nnode itself was deliberate; in the future, the graph may contain nodes\r\nthat are not synchronously reachable, so this approach allows us to\r\ncreate wrappers for nodes we can't synchronously reach. When this comes\r\nup in practice, we can then add async methods to the wrapper.\r\n\r\nNote that some data already included in our graph, such as\r\nPullRequestReviews and PullRequestReviewComments, were deliberately\r\nexcluded, so as to allow the core ideas to be reviewed without\r\nunnecessary clutter.\r\n\r\nTest plan:\r\nCheck that the unit tests appropriately test the behavior, and that the\r\nAPI seems pleasant to use.","created_at":"2018-04-28T04:09:18Z","updated_at":"2018-04-28T04:27:15Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0fc90c411b4c9882847070d6c760c9fd73a0e56f","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/sourcecred/sourcecred/pulls/170/commits","review_comments_url":"https://api.github.com/repos/sourcecred/sourcecred/pulls/170/comments","review_comment_url":"https://api.github.com/repos/sourcecred/sourcecred/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sourcecred/sourcecred/issues/170/comments","statuses_url":"https://api.github.com/repos/sourcecred/sourcecred/statuses/81ec7c6ebcaf4d872bd9a273c3c6df120958274e","head":{"label":"sourcecred:github-higher-api","ref":"github-higher-api","sha":"81ec7c6ebcaf4d872bd9a273c3c6df120958274e","user":{"login":"sourcecred","id":35711667,"avatar_url":"https://avatars1.githubusercontent.com/u/35711667?v=4","gravatar_id":"","url":"https://api.github.com/users/sourcecred","html_url":"https://github.com/sourcecred","followers_url":"https://api.github.com/users/sourcecred/followers","following_url":"https://api.github.com/users/sourcecred/following{/other_user}","gists_url":"https://api.github.com/users/sourcecred/gists{/gist_id}","starred_url":"https://api.github.com/users/sourcecred/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sourcecred/subscriptions","organizations_url":"https://api.github.com/users/sourcecred/orgs","repos_url":"https://api.github.com/users/sourcecred/repos","events_url":"https://api.github.com/users/sourcecred/events{/privacy}","received_events_url":"https://api.github.com/users/sourcecred/received_events","type":"Organization","site_admin":false},"repo":{"id":120145570,"name":"sourcecred","full_name":"sourcecred/sourcecred","owner":{"login":"sourcecred","id":35711667,"avatar_url":"https://avatars1.githubusercontent.com/u/35711667?v=4","gravatar_id":"","url":"https://api.github.com/users/sourcecred","html_url":"https://github.com/sourcecred","followers_url":"https://api.github.com/users/sourcecred/followers","following_url":"https://api.github.com/users/sourcecred/following{/other_user}","gists_url":"https://api.github.com/users/sourcecred/gists{/gist_id}","starred_url":"https://api.github.com/users/sourcecred/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sourcecred/subscriptions","organizations_url":"https://api.github.com/users/sourcecred/orgs","repos_url":"https://api.github.com/users/sourcecred/repos","events_url":"https://api.github.com/users/sourcecred/events{/privacy}","received_events_url":"https://api.github.com/users/sourcecred/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sourcecred/sourcecred","description":"shine a light on open-source contributors","fork":false,"url":"https://api.github.com/repos/sourcecred/sourcecred","forks_url":"https://api.github.com/repos/sourcecred/sourcecred/forks","keys_url":"https://api.github.com/repos/sourcecred/sourcecred/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sourcecred/sourcecred/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sourcecred/sourcecred/teams","hooks_url":"https://api.github.com/repos/sourcecred/sourcecred/hooks","issue_events_url":"https://api.github.com/repos/sourcecred/sourcecred/issues/events{/number}","events_url":"https://api.github.com/repos/sourcecred/sourcecred/events","assignees_url":"https://api.github.com/repos/sourcecred/sourcecred/assignees{/user}","branches_url":"https://api.github.com/repos/sourcecred/sourcecred/branches{/branch}","tags_url":"https://api.github.com/repos/sourcecred/sourcecred/tags","blobs_url":"https://api.github.com/repos/sourcecred/sourcecred/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sourcecred/sourcecred/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sourcecred/sourcecred/git/refs{/sha}","trees_url":"https://api.github.com/repos/sourcecred/sourcecred/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sourcecred/sourcecred/statuses/{sha}","languages_url":"https://api.github.com/repos/sourcecred/sourcecred/languages","stargazers_url":"https://api.github.com/repos/sourcecred/sourcecred/stargazers","contributors_url":"https://api.github.com/repos/sourcecred/sourcecred/contributors","subscribers_url":"https://api.github.com/repos/sourcecred/sourcecred/subscribers","subscription_url":"https://api.github.com/repos/sourcecred/sourcecred/subscription","commits_url":"https://api.github.com/repos/sourcecred/sourcecred/commits{/sha}","git_commits_url":"https://api.github.com/repos/sourcecred/sourcecred/git/commits{/sha}","comments_url":"https://api.github.com/repos/sourcecred/sourcecred/comments{/number}","issue_comment_url":"https://api.github.com/repos/sourcecred/sourcecred/issues/comments{/number}","contents_url":"https://api.github.com/repos/sourcecred/sourcecred/contents/{+path}","compare_url":"https://api.github.com/repos/sourcecred/sourcecred/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sourcecred/sourcecred/merges","archive_url":"https://api.github.com/repos/sourcecred/sourcecred/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sourcecred/sourcecred/downloads","issues_url":"https://api.github.com/repos/sourcecred/sourcecred/issues{/number}","pulls_url":"https://api.github.com/repos/sourcecred/sourcecred/pulls{/number}","milestones_url":"https://api.github.com/repos/sourcecred/sourcecred/milestones{/number}","notifications_url":"https://api.github.com/repos/sourcecred/sourcecred/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sourcecred/sourcecred/labels{/name}","releases_url":"https://api.github.com/repos/sourcecred/sourcecred/releases{/id}","deployments_url":"https://api.github.com/repos/sourcecred/sourcecred/deployments","created_at":"2018-02-04T01:32:53Z","updated_at":"2018-04-28T03:51:56Z","pushed_at":"2018-04-28T04:09:19Z","git_url":"git://github.com/sourcecred/sourcecred.git","ssh_url":"git@github.com:sourcecred/sourcecred.git","clone_url":"https://github.com/sourcecred/sourcecred.git","svn_url":"https://github.com/sourcecred/sourcecred","homepage":"","size":681,"stargazers_count":31,"watchers_count":31,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"archived":false,"open_issues_count":14,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":4,"open_issues":14,"watchers":31,"default_branch":"master"}},"base":{"label":"sourcecred:master","ref":"master","sha":"1c28c75e39153d0c36fbde3dbc9b3ff4743a219b","user":{"login":"sourcecred","id":35711667,"avatar_url":"https://avatars1.githubusercontent.com/u/35711667?v=4","gravatar_id":"","url":"https://api.github.com/users/sourcecred","html_url":"https://github.com/sourcecred","followers_url":"https://api.github.com/users/sourcecred/followers","following_url":"https://api.github.com/users/sourcecred/following{/other_user}","gists_url":"https://api.github.com/users/sourcecred/gists{/gist_id}","starred_url":"https://api.github.com/users/sourcecred/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sourcecred/subscriptions","organizations_url":"https://api.github.com/users/sourcecred/orgs","repos_url":"https://api.github.com/users/sourcecred/repos","events_url":"https://api.github.com/users/sourcecred/events{/privacy}","received_events_url":"https://api.github.com/users/sourcecred/received_events","type":"Organization","site_admin":false},"repo":{"id":120145570,"name":"sourcecred","full_name":"sourcecred/sourcecred","owner":{"login":"sourcecred","id":35711667,"avatar_url":"https://avatars1.githubusercontent.com/u/35711667?v=4","gravatar_id":"","url":"https://api.github.com/users/sourcecred","html_url":"https://github.com/sourcecred","followers_url":"https://api.github.com/users/sourcecred/followers","following_url":"https://api.github.com/users/sourcecred/following{/other_user}","gists_url":"https://api.github.com/users/sourcecred/gists{/gist_id}","starred_url":"https://api.github.com/users/sourcecred/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sourcecred/subscriptions","organizations_url":"https://api.github.com/users/sourcecred/orgs","repos_url":"https://api.github.com/users/sourcecred/repos","events_url":"https://api.github.com/users/sourcecred/events{/privacy}","received_events_url":"https://api.github.com/users/sourcecred/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sourcecred/sourcecred","description":"shine a light on open-source contributors","fork":false,"url":"https://api.github.com/repos/sourcecred/sourcecred","forks_url":"https://api.github.com/repos/sourcecred/sourcecred/forks","keys_url":"https://api.github.com/repos/sourcecred/sourcecred/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sourcecred/sourcecred/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sourcecred/sourcecred/teams","hooks_url":"https://api.github.com/repos/sourcecred/sourcecred/hooks","issue_events_url":"https://api.github.com/repos/sourcecred/sourcecred/issues/events{/number}","events_url":"https://api.github.com/repos/sourcecred/sourcecred/events","assignees_url":"https://api.github.com/repos/sourcecred/sourcecred/assignees{/user}","branches_url":"https://api.github.com/repos/sourcecred/sourcecred/branches{/branch}","tags_url":"https://api.github.com/repos/sourcecred/sourcecred/tags","blobs_url":"https://api.github.com/repos/sourcecred/sourcecred/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sourcecred/sourcecred/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sourcecred/sourcecred/git/refs{/sha}","trees_url":"https://api.github.com/repos/sourcecred/sourcecred/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sourcecred/sourcecred/statuses/{sha}","languages_url":"https://api.github.com/repos/sourcecred/sourcecred/languages","stargazers_url":"https://api.github.com/repos/sourcecred/sourcecred/stargazers","contributors_url":"https://api.github.com/repos/sourcecred/sourcecred/contributors","subscribers_url":"https://api.github.com/repos/sourcecred/sourcecred/subscribers","subscription_url":"https://api.github.com/repos/sourcecred/sourcecred/subscription","commits_url":"https://api.github.com/repos/sourcecred/sourcecred/commits{/sha}","git_commits_url":"https://api.github.com/repos/sourcecred/sourcecred/git/commits{/sha}","comments_url":"https://api.github.com/repos/sourcecred/sourcecred/comments{/number}","issue_comment_url":"https://api.github.com/repos/sourcecred/sourcecred/issues/comments{/number}","contents_url":"https://api.github.com/repos/sourcecred/sourcecred/contents/{+path}","compare_url":"https://api.github.com/repos/sourcecred/sourcecred/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sourcecred/sourcecred/merges","archive_url":"https://api.github.com/repos/sourcecred/sourcecred/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sourcecred/sourcecred/downloads","issues_url":"https://api.github.com/repos/sourcecred/sourcecred/issues{/number}","pulls_url":"https://api.github.com/repos/sourcecred/sourcecred/pulls{/number}","milestones_url":"https://api.github.com/repos/sourcecred/sourcecred/milestones{/number}","notifications_url":"https://api.github.com/repos/sourcecred/sourcecred/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sourcecred/sourcecred/labels{/name}","releases_url":"https://api.github.com/repos/sourcecred/sourcecred/releases{/id}","deployments_url":"https://api.github.com/repos/sourcecred/sourcecred/deployments","created_at":"2018-02-04T01:32:53Z","updated_at":"2018-04-28T03:51:56Z","pushed_at":"2018-04-28T04:09:19Z","git_url":"git://github.com/sourcecred/sourcecred.git","ssh_url":"git@github.com:sourcecred/sourcecred.git","clone_url":"https://github.com/sourcecred/sourcecred.git","svn_url":"https://github.com/sourcecred/sourcecred","homepage":"","size":681,"stargazers_count":31,"watchers_count":31,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"archived":false,"open_issues_count":14,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":4,"open_issues":14,"watchers":31,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sourcecred/sourcecred/pulls/170"},"html":{"href":"https://github.com/sourcecred/sourcecred/pull/170"},"issue":{"href":"https://api.github.com/repos/sourcecred/sourcecred/issues/170"},"comments":{"href":"https://api.github.com/repos/sourcecred/sourcecred/issues/170/comments"},"review_comments":{"href":"https://api.github.com/repos/sourcecred/sourcecred/pulls/170/comments"},"review_comment":{"href":"https://api.github.com/repos/sourcecred/sourcecred/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sourcecred/sourcecred/pulls/170/commits"},"statuses":{"href":"https://api.github.com/repos/sourcecred/sourcecred/statuses/81ec7c6ebcaf4d872bd9a273c3c6df120958274e"}},"author_association":"OWNER"}}
{"actor":{"display_login":"wchargin"}}