{"action":"created","comment":{"url":"https://api.github.com/repos/danger/danger-js/pulls/comments/111489245","pull_request_review_id":32741479,"id":111489245,"diff_hunk":"@@ -138,22 +138,33 @@ export default async function gitDSLForGitHub(api: GitHubAPI): Promise<GitDSL> {\n /**\n  * Gets the git-style diff for a single file.\n  *\n- * @param name File path for the diff\n+ * @param filename File path for the diff\n  */\n-  const diffForFile = (name: string, diffTypes?: string[]) => {\n-    const diff = find(fileDiffs, (diff: any) => diff.from === name || diff.to === name)\n-    if (!diff) { return null }\n+  const diffForFile = async (filename: string, diffTypes?: string[]) => {\n+    const structuredDiff = find(fileDiffs, (diff: any) => diff.from === filename || diff.to === filename)\n+    if (!structuredDiff) { return null }\n \n-    let changes = diff.chunks.map((c: any) => c.changes)\n-                             .reduce((a: any, b: any) => a.concat(b), [])\n+    let changes = structuredDiff.chunks.map((c: any) => c.changes)\n+                                .reduce((a: any, b: any) => a.concat(b), [])\n \n     // Filter the diffs by type\n     if (diffTypes && diffTypes.length > 0) {\n       changes = changes.filter((c: any) => diffTypes.indexOf(c.type) !== -1)\n     }\n \n+    const baseFile = await api.fileContents(filename, pr.base.repo.full_name, pr.base.sha)\n+    const headFile = await api.fileContents(filename, pr.head.repo.full_name, pr.head.sha)\n+\n     const lines = changes.map((c: any) => c.content)\n-    return lines.join(os.EOL)\n+\n+    return {\n+      before: baseFile,\n+      after: headFile,\n+      added: changes.filter(({type}: {type: string}) => type === \"add\"),\n+      removed: changes.filter(({type}: {type: string}) => type === \"del\"),\n+      normal: changes.filter(({type}: {type: string}) => type === \"normal\"),\n+      diff: lines.join(os.EOL)\n+    }\n   }","path":"source/platforms/github/GitHubGit.ts","position":38,"original_position":38,"commit_id":"79d2665baf30db383768de9fd570c826d5c76427","original_commit_id":"79d2665baf30db383768de9fd570c826d5c76427","user":{"login":"orta","id":49038,"avatar_url":"https://avatars1.githubusercontent.com/u/49038?v=3","gravatar_id":"","url":"https://api.github.com/users/orta","html_url":"https://github.com/orta","followers_url":"https://api.github.com/users/orta/followers","following_url":"https://api.github.com/users/orta/following{/other_user}","gists_url":"https://api.github.com/users/orta/gists{/gist_id}","starred_url":"https://api.github.com/users/orta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/orta/subscriptions","organizations_url":"https://api.github.com/users/orta/orgs","repos_url":"https://api.github.com/users/orta/repos","events_url":"https://api.github.com/users/orta/events{/privacy}","received_events_url":"https://api.github.com/users/orta/received_events","type":"User","site_admin":false},"body":"👍 ","created_at":"2017-04-13T21:17:01Z","updated_at":"2017-04-13T21:17:04Z","html_url":"https://github.com/danger/danger-js/pull/223#discussion_r111489245","pull_request_url":"https://api.github.com/repos/danger/danger-js/pulls/223","_links":{"self":{"href":"https://api.github.com/repos/danger/danger-js/pulls/comments/111489245"},"html":{"href":"https://github.com/danger/danger-js/pull/223#discussion_r111489245"},"pull_request":{"href":"https://api.github.com/repos/danger/danger-js/pulls/223"}}},"pull_request":{"url":"https://api.github.com/repos/danger/danger-js/pulls/223","id":115844542,"html_url":"https://github.com/danger/danger-js/pull/223","diff_url":"https://github.com/danger/danger-js/pull/223.diff","patch_url":"https://github.com/danger/danger-js/pull/223.patch","issue_url":"https://api.github.com/repos/danger/danger-js/issues/223","number":223,"state":"open","locked":false,"title":"Add convenience info to `danger.git.diffForFile`","user":{"login":"namuol","id":444629,"avatar_url":"https://avatars0.githubusercontent.com/u/444629?v=3","gravatar_id":"","url":"https://api.github.com/users/namuol","html_url":"https://github.com/namuol","followers_url":"https://api.github.com/users/namuol/followers","following_url":"https://api.github.com/users/namuol/following{/other_user}","gists_url":"https://api.github.com/users/namuol/gists{/gist_id}","starred_url":"https://api.github.com/users/namuol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/namuol/subscriptions","organizations_url":"https://api.github.com/users/namuol/orgs","repos_url":"https://api.github.com/users/namuol/repos","events_url":"https://api.github.com/users/namuol/events{/privacy}","received_events_url":"https://api.github.com/users/namuol/received_events","type":"User","site_admin":false},"body":"Fixes #221\r\n\r\nChanges the signature for `danger.git.diffForFile` to the following:\r\n\r\n```ts\r\n/** All Text diff values will be this shape */\r\nexport interface TextDiff {\r\n  /** The value before the PR's applied changes */\r\n  before: string\r\n  /** The value after the PR's applied changes */\r\n  after: string,\r\n  added: string[],\r\n  removed: string[],\r\n  normal: string[],\r\n  diff: string,\r\n}\r\n\r\ndiffForFile(filename: string, diffTypes?: string[]): Promise<TextDiff | null>\r\n```\r\n\r\n### TODO\r\n\r\n- [ ] Update docs\r\n- [ ] Update changelog (include dangerfile migration instructions)\r\n- [ ] Add tests\r\n  - [x] `before`\r\n  - [x] `after`\r\n  - [ ] `added[]`\r\n  - [ ] `removed[]`\r\n  - [ ] `normal[]`","created_at":"2017-04-13T21:14:38Z","updated_at":"2017-04-13T21:17:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7c6c35c3f815cdb7bb75cd20c6fe132c7dc4dde9","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/danger/danger-js/pulls/223/commits","review_comments_url":"https://api.github.com/repos/danger/danger-js/pulls/223/comments","review_comment_url":"https://api.github.com/repos/danger/danger-js/pulls/comments{/number}","comments_url":"https://api.github.com/repos/danger/danger-js/issues/223/comments","statuses_url":"https://api.github.com/repos/danger/danger-js/statuses/79d2665baf30db383768de9fd570c826d5c76427","head":{"label":"namuol:structured-file-diffs","ref":"structured-file-diffs","sha":"79d2665baf30db383768de9fd570c826d5c76427","user":{"login":"namuol","id":444629,"avatar_url":"https://avatars0.githubusercontent.com/u/444629?v=3","gravatar_id":"","url":"https://api.github.com/users/namuol","html_url":"https://github.com/namuol","followers_url":"https://api.github.com/users/namuol/followers","following_url":"https://api.github.com/users/namuol/following{/other_user}","gists_url":"https://api.github.com/users/namuol/gists{/gist_id}","starred_url":"https://api.github.com/users/namuol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/namuol/subscriptions","organizations_url":"https://api.github.com/users/namuol/orgs","repos_url":"https://api.github.com/users/namuol/repos","events_url":"https://api.github.com/users/namuol/events{/privacy}","received_events_url":"https://api.github.com/users/namuol/received_events","type":"User","site_admin":false},"repo":{"id":88191390,"name":"danger-js","full_name":"namuol/danger-js","owner":{"login":"namuol","id":444629,"avatar_url":"https://avatars0.githubusercontent.com/u/444629?v=3","gravatar_id":"","url":"https://api.github.com/users/namuol","html_url":"https://github.com/namuol","followers_url":"https://api.github.com/users/namuol/followers","following_url":"https://api.github.com/users/namuol/following{/other_user}","gists_url":"https://api.github.com/users/namuol/gists{/gist_id}","starred_url":"https://api.github.com/users/namuol/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/namuol/subscriptions","organizations_url":"https://api.github.com/users/namuol/orgs","repos_url":"https://api.github.com/users/namuol/repos","events_url":"https://api.github.com/users/namuol/events{/privacy}","received_events_url":"https://api.github.com/users/namuol/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/namuol/danger-js","description":"Danger on Node ","fork":true,"url":"https://api.github.com/repos/namuol/danger-js","forks_url":"https://api.github.com/repos/namuol/danger-js/forks","keys_url":"https://api.github.com/repos/namuol/danger-js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/namuol/danger-js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/namuol/danger-js/teams","hooks_url":"https://api.github.com/repos/namuol/danger-js/hooks","issue_events_url":"https://api.github.com/repos/namuol/danger-js/issues/events{/number}","events_url":"https://api.github.com/repos/namuol/danger-js/events","assignees_url":"https://api.github.com/repos/namuol/danger-js/assignees{/user}","branches_url":"https://api.github.com/repos/namuol/danger-js/branches{/branch}","tags_url":"https://api.github.com/repos/namuol/danger-js/tags","blobs_url":"https://api.github.com/repos/namuol/danger-js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/namuol/danger-js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/namuol/danger-js/git/refs{/sha}","trees_url":"https://api.github.com/repos/namuol/danger-js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/namuol/danger-js/statuses/{sha}","languages_url":"https://api.github.com/repos/namuol/danger-js/languages","stargazers_url":"https://api.github.com/repos/namuol/danger-js/stargazers","contributors_url":"https://api.github.com/repos/namuol/danger-js/contributors","subscribers_url":"https://api.github.com/repos/namuol/danger-js/subscribers","subscription_url":"https://api.github.com/repos/namuol/danger-js/subscription","commits_url":"https://api.github.com/repos/namuol/danger-js/commits{/sha}","git_commits_url":"https://api.github.com/repos/namuol/danger-js/git/commits{/sha}","comments_url":"https://api.github.com/repos/namuol/danger-js/comments{/number}","issue_comment_url":"https://api.github.com/repos/namuol/danger-js/issues/comments{/number}","contents_url":"https://api.github.com/repos/namuol/danger-js/contents/{+path}","compare_url":"https://api.github.com/repos/namuol/danger-js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/namuol/danger-js/merges","archive_url":"https://api.github.com/repos/namuol/danger-js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/namuol/danger-js/downloads","issues_url":"https://api.github.com/repos/namuol/danger-js/issues{/number}","pulls_url":"https://api.github.com/repos/namuol/danger-js/pulls{/number}","milestones_url":"https://api.github.com/repos/namuol/danger-js/milestones{/number}","notifications_url":"https://api.github.com/repos/namuol/danger-js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/namuol/danger-js/labels{/name}","releases_url":"https://api.github.com/repos/namuol/danger-js/releases{/id}","deployments_url":"https://api.github.com/repos/namuol/danger-js/deployments","created_at":"2017-04-13T17:47:39Z","updated_at":"2017-04-13T17:47:41Z","pushed_at":"2017-04-13T21:09:33Z","git_url":"git://github.com/namuol/danger-js.git","ssh_url":"git@github.com:namuol/danger-js.git","clone_url":"https://github.com/namuol/danger-js.git","svn_url":"https://github.com/namuol/danger-js","homepage":null,"size":878,"stargazers_count":0,"watchers_count":0,"language":"TypeScript","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":"danger:master","ref":"master","sha":"d3f193349f9b234c448a834088cfb6e7cd5efb85","user":{"login":"danger","id":17147106,"avatar_url":"https://avatars0.githubusercontent.com/u/17147106?v=3","gravatar_id":"","url":"https://api.github.com/users/danger","html_url":"https://github.com/danger","followers_url":"https://api.github.com/users/danger/followers","following_url":"https://api.github.com/users/danger/following{/other_user}","gists_url":"https://api.github.com/users/danger/gists{/gist_id}","starred_url":"https://api.github.com/users/danger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danger/subscriptions","organizations_url":"https://api.github.com/users/danger/orgs","repos_url":"https://api.github.com/users/danger/repos","events_url":"https://api.github.com/users/danger/events{/privacy}","received_events_url":"https://api.github.com/users/danger/received_events","type":"Organization","site_admin":false},"repo":{"id":66146807,"name":"danger-js","full_name":"danger/danger-js","owner":{"login":"danger","id":17147106,"avatar_url":"https://avatars0.githubusercontent.com/u/17147106?v=3","gravatar_id":"","url":"https://api.github.com/users/danger","html_url":"https://github.com/danger","followers_url":"https://api.github.com/users/danger/followers","following_url":"https://api.github.com/users/danger/following{/other_user}","gists_url":"https://api.github.com/users/danger/gists{/gist_id}","starred_url":"https://api.github.com/users/danger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danger/subscriptions","organizations_url":"https://api.github.com/users/danger/orgs","repos_url":"https://api.github.com/users/danger/repos","events_url":"https://api.github.com/users/danger/events{/privacy}","received_events_url":"https://api.github.com/users/danger/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/danger/danger-js","description":"Danger on Node ","fork":false,"url":"https://api.github.com/repos/danger/danger-js","forks_url":"https://api.github.com/repos/danger/danger-js/forks","keys_url":"https://api.github.com/repos/danger/danger-js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/danger/danger-js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/danger/danger-js/teams","hooks_url":"https://api.github.com/repos/danger/danger-js/hooks","issue_events_url":"https://api.github.com/repos/danger/danger-js/issues/events{/number}","events_url":"https://api.github.com/repos/danger/danger-js/events","assignees_url":"https://api.github.com/repos/danger/danger-js/assignees{/user}","branches_url":"https://api.github.com/repos/danger/danger-js/branches{/branch}","tags_url":"https://api.github.com/repos/danger/danger-js/tags","blobs_url":"https://api.github.com/repos/danger/danger-js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/danger/danger-js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/danger/danger-js/git/refs{/sha}","trees_url":"https://api.github.com/repos/danger/danger-js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/danger/danger-js/statuses/{sha}","languages_url":"https://api.github.com/repos/danger/danger-js/languages","stargazers_url":"https://api.github.com/repos/danger/danger-js/stargazers","contributors_url":"https://api.github.com/repos/danger/danger-js/contributors","subscribers_url":"https://api.github.com/repos/danger/danger-js/subscribers","subscription_url":"https://api.github.com/repos/danger/danger-js/subscription","commits_url":"https://api.github.com/repos/danger/danger-js/commits{/sha}","git_commits_url":"https://api.github.com/repos/danger/danger-js/git/commits{/sha}","comments_url":"https://api.github.com/repos/danger/danger-js/comments{/number}","issue_comment_url":"https://api.github.com/repos/danger/danger-js/issues/comments{/number}","contents_url":"https://api.github.com/repos/danger/danger-js/contents/{+path}","compare_url":"https://api.github.com/repos/danger/danger-js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/danger/danger-js/merges","archive_url":"https://api.github.com/repos/danger/danger-js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/danger/danger-js/downloads","issues_url":"https://api.github.com/repos/danger/danger-js/issues{/number}","pulls_url":"https://api.github.com/repos/danger/danger-js/pulls{/number}","milestones_url":"https://api.github.com/repos/danger/danger-js/milestones{/number}","notifications_url":"https://api.github.com/repos/danger/danger-js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/danger/danger-js/labels{/name}","releases_url":"https://api.github.com/repos/danger/danger-js/releases{/id}","deployments_url":"https://api.github.com/repos/danger/danger-js/deployments","created_at":"2016-08-20T12:57:06Z","updated_at":"2017-04-13T19:55:41Z","pushed_at":"2017-04-13T21:14:39Z","git_url":"git://github.com/danger/danger-js.git","ssh_url":"git@github.com:danger/danger-js.git","clone_url":"https://github.com/danger/danger-js.git","svn_url":"https://github.com/danger/danger-js","homepage":null,"size":878,"stargazers_count":306,"watchers_count":306,"language":"TypeScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":26,"mirror_url":null,"open_issues_count":25,"forks":26,"open_issues":25,"watchers":306,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/danger/danger-js/pulls/223"},"html":{"href":"https://github.com/danger/danger-js/pull/223"},"issue":{"href":"https://api.github.com/repos/danger/danger-js/issues/223"},"comments":{"href":"https://api.github.com/repos/danger/danger-js/issues/223/comments"},"review_comments":{"href":"https://api.github.com/repos/danger/danger-js/pulls/223/comments"},"review_comment":{"href":"https://api.github.com/repos/danger/danger-js/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/danger/danger-js/pulls/223/commits"},"statuses":{"href":"https://api.github.com/repos/danger/danger-js/statuses/79d2665baf30db383768de9fd570c826d5c76427"}}}}
{"actor":{"display_login":"orta"}}