{"action":"created","comment":{"url":"https://api.github.com/repos/badges/shields/pulls/comments/147439475","pull_request_review_id":72538446,"id":147439475,"diff_hunk":"@@ -66,6 +66,176 @@ t.create('GitHub closed issues raw')\n     value: Joi.string().regex(/^\\w+\\+?$/)\n   }));\n \n+// pull request state\n+\n+t.create('Pull request state, regular case')\n+  .get('/pr-state/badges/shields/578.json')\n+  .expectJSONTypes(Joi.object().keys({\n+    name: Joi.equal('pull request state'),\n+    value: Joi.equal('closed', 'merged', 'mergeable', 'has conflicts', 'need rebase')\n+  }));\n+\n+t.create('Pull request state, closed pull request')\n+  .get('/pr-state/badges/shields/578.json')\n+  .intercept(nock =>\n+    nock('https://api.github.com')\n+      .get('/repos/badges/shields/pulls/578')\n+      .query(true)\n+      .reply(200, {\n+        mergeable: null,\n+        mergeable_state: 'unknown',\n+        merged: false,\n+        state: 'closed'\n+      })\n+  )\n+  .expectJSON({\n+    name: 'pull request state',\n+    value: 'closed'\n+  });\n+\n+t.create('Pull request state, merged pull request')\n+  .get('/pr-state/badges/shields/578.json')\n+  .intercept(nock =>\n+    nock('https://api.github.com')\n+      .get('/repos/badges/shields/pulls/578')\n+      .query(true)\n+      .reply(200, {\n+        mergeable: null,\n+        mergeable_state: 'unknown',\n+        merged: true,\n+        state: 'closed'\n+      })\n+  )\n+  .expectJSON({\n+    name: 'pull request state',\n+    value: 'merged'\n+  });\n+\n+t.create('Pull request state, pull request with unknown state')\n+  .get('/pr-state/badges/shields/578.json')\n+  .intercept(nock =>\n+    nock('https://api.github.com')\n+      .get('/repos/badges/shields/pulls/578')\n+      .query(true)\n+      .reply(200, {\n+        mergeable: null,\n+        mergeable_state: 'unknown',\n+        merged: false,\n+        state: 'open'\n+      })\n+  )\n+  .expectJSON({\n+    name: 'pull request state',\n+    value: 'unknown'\n+  });\n+\n+t.create('Pull request state, mergeable pull request')\n+  .get('/pr-state/badges/shields/578.json')\n+  .intercept(nock =>\n+    nock('https://api.github.com')\n+      .get('/repos/badges/shields/pulls/578')\n+      .query(true)\n+      .reply(200, {\n+        mergeable: true,\n+        mergeable_state: 'clean',\n+        merged: false,\n+        state: 'open'\n+      })\n+  )\n+  .expectJSON({\n+    name: 'pull request state',\n+    value: 'mergeable'\n+  });\n+\n+t.create('Pull request state, pull request with conflicts')\n+  .get('/pr-state/badges/shields/578.json')\n+  .intercept(nock =>\n+    nock('https://api.github.com')\n+      .get('/repos/badges/shields/pulls/578')\n+      .query(true)\n+      .reply(200, {\n+        mergeable: false,\n+        mergeable_state: 'dirty',\n+        merged: false,\n+        state: 'open'\n+      })\n+  )\n+  .expectJSON({\n+    name: 'pull request state',\n+    value: 'has conflicts'\n+  });\n+\n+t.create('Pull request state, pull request that needs rebase')\n+  .get('/pr-state/badges/shields/578.json')\n+  .intercept(nock =>\n+    nock('https://api.github.com')\n+      .get('/repos/badges/shields/pulls/578')\n+      .query(true)\n+      .reply(200, {\n+        mergeable: false,\n+        mergeable_state: 'behind',\n+        merged: false,\n+        state: 'open'\n+      })\n+  )\n+  .expectJSON({\n+    name: 'pull request state',\n+    value: 'need rebase'\n+  });\n+\n+t.create('Pull request state, mergeable pull request but build unstable')\n+  .get('/pr-state/badges/shields/578.json')\n+  .intercept(nock =>\n+    nock('https://api.github.com')\n+      .get('/repos/badges/shields/pulls/578')\n+      .query(true)\n+      .reply(200, {\n+        mergeable: true,\n+        mergeable_state: 'unstable',\n+        merged: false,\n+        state: 'open'\n+      })\n+  )\n+  .expectJSON({\n+    name: 'pull request state',\n+    value: 'unstable'\n+  });\n+\n+t.create('Pull request state, valid response but not a Github issue')\n+  .get('/pr-state/badges/shields/-1.json')\n+  .expectJSONTypes(Joi.object().keys({\n+    name: Joi.equal('pull request state'),\n+    value: Joi.equal('inaccessible')\n+  }));\n+\n+t.create('Pull request state, invalid response')\n+  .get('/pr-state/badges/shields/578.json')\n+  .intercept(nock =>\n+    nock('https://api.github.com')\n+      .get('/repos/badges/shields/pulls/578')\n+      .query(true)\n+      .reply(200, 'This should be JSON')\n+  )\n+  .expectJSON({\n+    name: 'pull request state',\n+    value: 'inaccessible'\n+  });\n+\n+t.create('Pull request state, request error')\n+  .get('/pr-state/badges/shields/578.json')\n+  .networkOff()\n+  .expectJSON({\n+    name: 'pull request state',\n+    value: 'inaccessible'\n+  });\n+\n+t.create('GitHub pull request state')\n+  .get('/pr-state/badges/shields/6.json')\n+  .expectedJSONTypes(Joi.object().keys({\n+    name: 'pull request',\n+    value: Joi.string().regex(/^\\w+/)\n+  }));","path":"service-tests/github.js","position":172,"original_position":172,"commit_id":"852a21cf28060a762e2c19c87b39282c188fc3fc","original_commit_id":"852a21cf28060a762e2c19c87b39282c188fc3fc","user":{"login":"paulmelnikow","id":1487036,"avatar_url":"https://avatars2.githubusercontent.com/u/1487036?v=4","gravatar_id":"","url":"https://api.github.com/users/paulmelnikow","html_url":"https://github.com/paulmelnikow","followers_url":"https://api.github.com/users/paulmelnikow/followers","following_url":"https://api.github.com/users/paulmelnikow/following{/other_user}","gists_url":"https://api.github.com/users/paulmelnikow/gists{/gist_id}","starred_url":"https://api.github.com/users/paulmelnikow/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/paulmelnikow/subscriptions","organizations_url":"https://api.github.com/users/paulmelnikow/orgs","repos_url":"https://api.github.com/users/paulmelnikow/repos","events_url":"https://api.github.com/users/paulmelnikow/events{/privacy}","received_events_url":"https://api.github.com/users/paulmelnikow/received_events","type":"User","site_admin":false},"body":"Could you get these tests passing? Otherwise they look good!","created_at":"2017-10-27T15:18:53Z","updated_at":"2017-10-27T15:30:36Z","html_url":"https://github.com/badges/shields/pull/1207#discussion_r147439475","pull_request_url":"https://api.github.com/repos/badges/shields/pulls/1207","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/badges/shields/pulls/comments/147439475"},"html":{"href":"https://github.com/badges/shields/pull/1207#discussion_r147439475"},"pull_request":{"href":"https://api.github.com/repos/badges/shields/pulls/1207"}}},"pull_request":{"url":"https://api.github.com/repos/badges/shields/pulls/1207","id":148843173,"html_url":"https://github.com/badges/shields/pull/1207","diff_url":"https://github.com/badges/shields/pull/1207.diff","patch_url":"https://github.com/badges/shields/pull/1207.patch","issue_url":"https://api.github.com/repos/badges/shields/issues/1207","number":1207,"state":"open","locked":false,"title":"Add [Github] pull request state badge","user":{"login":"ivanovyordan","id":979329,"avatar_url":"https://avatars0.githubusercontent.com/u/979329?v=4","gravatar_id":"","url":"https://api.github.com/users/ivanovyordan","html_url":"https://github.com/ivanovyordan","followers_url":"https://api.github.com/users/ivanovyordan/followers","following_url":"https://api.github.com/users/ivanovyordan/following{/other_user}","gists_url":"https://api.github.com/users/ivanovyordan/gists{/gist_id}","starred_url":"https://api.github.com/users/ivanovyordan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ivanovyordan/subscriptions","organizations_url":"https://api.github.com/users/ivanovyordan/orgs","repos_url":"https://api.github.com/users/ivanovyordan/repos","events_url":"https://api.github.com/users/ivanovyordan/events{/privacy}","received_events_url":"https://api.github.com/users/ivanovyordan/received_events","type":"User","site_admin":false},"body":"URL pattern:\r\n\r\n`/github/pr-state/<user>/<repo>/<issueId>.<format>`\r\n\r\nThe issue (which ID is provided in the URL) must be a pull-request.\r\n\r\nThe following states are handled:\r\n`inaccessible` (lightgrey) if the request failed or the response was not a json-formatted issue\r\n`closed` (red) if the PR is closed and not merged\r\n`merged` (Github purple-ish) if the PR is closed and merged\r\n`mergeable` (green) if the PR is open and clean (build OK, no conflicts detected, rebased on latest version of the base branch)\r\n`unstable` (yellow) if the PR is open but unstabe\r\n`has conflicts` (red) if the PR is open but not mergeable (conflicts with base branch detected)\r\n`unknown` (lightgrey) if the PR is open but the mergeability is not computed yet (more details here)\r\n\r\nRelated PR: GH-806","created_at":"2017-10-26T05:46:39Z","updated_at":"2017-10-27T15:30:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9e2aaf1056ba4009effb6d947eaf074c5d3e7b43","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/badges/shields/pulls/1207/commits","review_comments_url":"https://api.github.com/repos/badges/shields/pulls/1207/comments","review_comment_url":"https://api.github.com/repos/badges/shields/pulls/comments{/number}","comments_url":"https://api.github.com/repos/badges/shields/issues/1207/comments","statuses_url":"https://api.github.com/repos/badges/shields/statuses/852a21cf28060a762e2c19c87b39282c188fc3fc","head":{"label":"ivanovyordan:github-pr-state","ref":"github-pr-state","sha":"852a21cf28060a762e2c19c87b39282c188fc3fc","user":{"login":"ivanovyordan","id":979329,"avatar_url":"https://avatars0.githubusercontent.com/u/979329?v=4","gravatar_id":"","url":"https://api.github.com/users/ivanovyordan","html_url":"https://github.com/ivanovyordan","followers_url":"https://api.github.com/users/ivanovyordan/followers","following_url":"https://api.github.com/users/ivanovyordan/following{/other_user}","gists_url":"https://api.github.com/users/ivanovyordan/gists{/gist_id}","starred_url":"https://api.github.com/users/ivanovyordan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ivanovyordan/subscriptions","organizations_url":"https://api.github.com/users/ivanovyordan/orgs","repos_url":"https://api.github.com/users/ivanovyordan/repos","events_url":"https://api.github.com/users/ivanovyordan/events{/privacy}","received_events_url":"https://api.github.com/users/ivanovyordan/received_events","type":"User","site_admin":false},"repo":{"id":108365893,"name":"shields","full_name":"ivanovyordan/shields","owner":{"login":"ivanovyordan","id":979329,"avatar_url":"https://avatars0.githubusercontent.com/u/979329?v=4","gravatar_id":"","url":"https://api.github.com/users/ivanovyordan","html_url":"https://github.com/ivanovyordan","followers_url":"https://api.github.com/users/ivanovyordan/followers","following_url":"https://api.github.com/users/ivanovyordan/following{/other_user}","gists_url":"https://api.github.com/users/ivanovyordan/gists{/gist_id}","starred_url":"https://api.github.com/users/ivanovyordan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ivanovyordan/subscriptions","organizations_url":"https://api.github.com/users/ivanovyordan/orgs","repos_url":"https://api.github.com/users/ivanovyordan/repos","events_url":"https://api.github.com/users/ivanovyordan/events{/privacy}","received_events_url":"https://api.github.com/users/ivanovyordan/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ivanovyordan/shields","description":"Concise, consistent, and legible badges in SVG and raster format","fork":true,"url":"https://api.github.com/repos/ivanovyordan/shields","forks_url":"https://api.github.com/repos/ivanovyordan/shields/forks","keys_url":"https://api.github.com/repos/ivanovyordan/shields/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ivanovyordan/shields/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ivanovyordan/shields/teams","hooks_url":"https://api.github.com/repos/ivanovyordan/shields/hooks","issue_events_url":"https://api.github.com/repos/ivanovyordan/shields/issues/events{/number}","events_url":"https://api.github.com/repos/ivanovyordan/shields/events","assignees_url":"https://api.github.com/repos/ivanovyordan/shields/assignees{/user}","branches_url":"https://api.github.com/repos/ivanovyordan/shields/branches{/branch}","tags_url":"https://api.github.com/repos/ivanovyordan/shields/tags","blobs_url":"https://api.github.com/repos/ivanovyordan/shields/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ivanovyordan/shields/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ivanovyordan/shields/git/refs{/sha}","trees_url":"https://api.github.com/repos/ivanovyordan/shields/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ivanovyordan/shields/statuses/{sha}","languages_url":"https://api.github.com/repos/ivanovyordan/shields/languages","stargazers_url":"https://api.github.com/repos/ivanovyordan/shields/stargazers","contributors_url":"https://api.github.com/repos/ivanovyordan/shields/contributors","subscribers_url":"https://api.github.com/repos/ivanovyordan/shields/subscribers","subscription_url":"https://api.github.com/repos/ivanovyordan/shields/subscription","commits_url":"https://api.github.com/repos/ivanovyordan/shields/commits{/sha}","git_commits_url":"https://api.github.com/repos/ivanovyordan/shields/git/commits{/sha}","comments_url":"https://api.github.com/repos/ivanovyordan/shields/comments{/number}","issue_comment_url":"https://api.github.com/repos/ivanovyordan/shields/issues/comments{/number}","contents_url":"https://api.github.com/repos/ivanovyordan/shields/contents/{+path}","compare_url":"https://api.github.com/repos/ivanovyordan/shields/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ivanovyordan/shields/merges","archive_url":"https://api.github.com/repos/ivanovyordan/shields/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ivanovyordan/shields/downloads","issues_url":"https://api.github.com/repos/ivanovyordan/shields/issues{/number}","pulls_url":"https://api.github.com/repos/ivanovyordan/shields/pulls{/number}","milestones_url":"https://api.github.com/repos/ivanovyordan/shields/milestones{/number}","notifications_url":"https://api.github.com/repos/ivanovyordan/shields/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ivanovyordan/shields/labels{/name}","releases_url":"https://api.github.com/repos/ivanovyordan/shields/releases{/id}","deployments_url":"https://api.github.com/repos/ivanovyordan/shields/deployments","created_at":"2017-10-26T05:32:01Z","updated_at":"2017-10-26T05:32:03Z","pushed_at":"2017-10-26T05:43:21Z","git_url":"git://github.com/ivanovyordan/shields.git","ssh_url":"git@github.com:ivanovyordan/shields.git","clone_url":"https://github.com/ivanovyordan/shields.git","svn_url":"https://github.com/ivanovyordan/shields","homepage":"https://shields.io","size":5414,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"badges:master","ref":"master","sha":"ffb6fdb884f1fd5510813238c80a509792b26998","user":{"login":"badges","id":6254238,"avatar_url":"https://avatars2.githubusercontent.com/u/6254238?v=4","gravatar_id":"","url":"https://api.github.com/users/badges","html_url":"https://github.com/badges","followers_url":"https://api.github.com/users/badges/followers","following_url":"https://api.github.com/users/badges/following{/other_user}","gists_url":"https://api.github.com/users/badges/gists{/gist_id}","starred_url":"https://api.github.com/users/badges/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/badges/subscriptions","organizations_url":"https://api.github.com/users/badges/orgs","repos_url":"https://api.github.com/users/badges/repos","events_url":"https://api.github.com/users/badges/events{/privacy}","received_events_url":"https://api.github.com/users/badges/received_events","type":"Organization","site_admin":false},"repo":{"id":7910045,"name":"shields","full_name":"badges/shields","owner":{"login":"badges","id":6254238,"avatar_url":"https://avatars2.githubusercontent.com/u/6254238?v=4","gravatar_id":"","url":"https://api.github.com/users/badges","html_url":"https://github.com/badges","followers_url":"https://api.github.com/users/badges/followers","following_url":"https://api.github.com/users/badges/following{/other_user}","gists_url":"https://api.github.com/users/badges/gists{/gist_id}","starred_url":"https://api.github.com/users/badges/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/badges/subscriptions","organizations_url":"https://api.github.com/users/badges/orgs","repos_url":"https://api.github.com/users/badges/repos","events_url":"https://api.github.com/users/badges/events{/privacy}","received_events_url":"https://api.github.com/users/badges/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/badges/shields","description":"Concise, consistent, and legible badges in SVG and raster format","fork":false,"url":"https://api.github.com/repos/badges/shields","forks_url":"https://api.github.com/repos/badges/shields/forks","keys_url":"https://api.github.com/repos/badges/shields/keys{/key_id}","collaborators_url":"https://api.github.com/repos/badges/shields/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/badges/shields/teams","hooks_url":"https://api.github.com/repos/badges/shields/hooks","issue_events_url":"https://api.github.com/repos/badges/shields/issues/events{/number}","events_url":"https://api.github.com/repos/badges/shields/events","assignees_url":"https://api.github.com/repos/badges/shields/assignees{/user}","branches_url":"https://api.github.com/repos/badges/shields/branches{/branch}","tags_url":"https://api.github.com/repos/badges/shields/tags","blobs_url":"https://api.github.com/repos/badges/shields/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/badges/shields/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/badges/shields/git/refs{/sha}","trees_url":"https://api.github.com/repos/badges/shields/git/trees{/sha}","statuses_url":"https://api.github.com/repos/badges/shields/statuses/{sha}","languages_url":"https://api.github.com/repos/badges/shields/languages","stargazers_url":"https://api.github.com/repos/badges/shields/stargazers","contributors_url":"https://api.github.com/repos/badges/shields/contributors","subscribers_url":"https://api.github.com/repos/badges/shields/subscribers","subscription_url":"https://api.github.com/repos/badges/shields/subscription","commits_url":"https://api.github.com/repos/badges/shields/commits{/sha}","git_commits_url":"https://api.github.com/repos/badges/shields/git/commits{/sha}","comments_url":"https://api.github.com/repos/badges/shields/comments{/number}","issue_comment_url":"https://api.github.com/repos/badges/shields/issues/comments{/number}","contents_url":"https://api.github.com/repos/badges/shields/contents/{+path}","compare_url":"https://api.github.com/repos/badges/shields/compare/{base}...{head}","merges_url":"https://api.github.com/repos/badges/shields/merges","archive_url":"https://api.github.com/repos/badges/shields/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/badges/shields/downloads","issues_url":"https://api.github.com/repos/badges/shields/issues{/number}","pulls_url":"https://api.github.com/repos/badges/shields/pulls{/number}","milestones_url":"https://api.github.com/repos/badges/shields/milestones{/number}","notifications_url":"https://api.github.com/repos/badges/shields/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/badges/shields/labels{/name}","releases_url":"https://api.github.com/repos/badges/shields/releases{/id}","deployments_url":"https://api.github.com/repos/badges/shields/deployments","created_at":"2013-01-30T07:41:54Z","updated_at":"2017-10-27T06:53:38Z","pushed_at":"2017-10-26T20:31:14Z","git_url":"git://github.com/badges/shields.git","ssh_url":"git@github.com:badges/shields.git","clone_url":"https://github.com/badges/shields.git","svn_url":"https://github.com/badges/shields","homepage":"https://shields.io","size":5414,"stargazers_count":4640,"watchers_count":4640,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":945,"mirror_url":null,"archived":false,"open_issues_count":132,"forks":945,"open_issues":132,"watchers":4640,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/badges/shields/pulls/1207"},"html":{"href":"https://github.com/badges/shields/pull/1207"},"issue":{"href":"https://api.github.com/repos/badges/shields/issues/1207"},"comments":{"href":"https://api.github.com/repos/badges/shields/issues/1207/comments"},"review_comments":{"href":"https://api.github.com/repos/badges/shields/pulls/1207/comments"},"review_comment":{"href":"https://api.github.com/repos/badges/shields/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/badges/shields/pulls/1207/commits"},"statuses":{"href":"https://api.github.com/repos/badges/shields/statuses/852a21cf28060a762e2c19c87b39282c188fc3fc"}},"author_association":"NONE"}}
{"actor":{"display_login":"paulmelnikow"}}