{"action":"created","comment":{"url":"https://api.github.com/repos/jcabi/jcabi-github/pulls/comments/32561633","id":32561633,"diff_hunk":"@@ -0,0 +1,182 @@\n+/**\n+ * Copyright (c) 2013-2015, jcabi.com\n+ * All rights reserved.\n+ *\n+ * Redistribution and use in source and binary forms, with or without\n+ * modification, are permitted provided that the following conditions\n+ * are met: 1) Redistributions of source code must retain the above\n+ * copyright notice, this list of conditions and the following\n+ * disclaimer. 2) Redistributions in binary form must reproduce the above\n+ * copyright notice, this list of conditions and the following\n+ * disclaimer in the documentation and/or other materials provided\n+ * with the distribution. 3) Neither the name of the jcabi.com nor\n+ * the names of its contributors may be used to endorse or promote\n+ * products derived from this software without specific prior written\n+ * permission.\n+ *\n+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n+ * \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT\n+ * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND\n+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL\n+ * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,\n+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\n+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n+ * OF THE POSSIBILITY OF SUCH DAMAGE.\n+ */\n+package com.jcabi.github;\n+\n+import com.jcabi.github.mock.MkGithub;\n+import java.io.IOException;\n+import javax.json.Json;\n+import javax.json.JsonObject;\n+import org.hamcrest.MatcherAssert;\n+import org.hamcrest.Matchers;\n+import org.junit.Test;\n+\n+/**\n+ * Test case for {@link PullRef}.\n+ *\n+ * @author Chris Rebert (github@rebertia.com)\n+ * @version $Id$\n+ * @since 0.24\n+ */\n+public final class PullRefTest {\n+    /**\n+     * Test ref.\n+     */\n+    private static final String REF = \"the-ref\";\n+    /**\n+     * Test commit SHA.\n+     * @checkstyle LineLength (2 lines)\n+     */\n+    private static final String SHA = \"7a1f68e743e8a81e158136c8661011fb55abd703\";\n+    /**\n+     * Test pull request ref label.\n+     */\n+    private static final String LABEL = \"pr-ref-label\";\n+\n+    /**\n+     * PullRef.Smart can fetch its repo.\n+     * @throws IOException If there is an I/O problem.\n+     */\n+    @Test\n+    public void fetchesRepo() throws IOException {\n+        final Repo repo = new MkGithub().randomRepo();\n+        MatcherAssert.assertThat(\n+            pullRef(repo).repo().coordinates(),\n+            Matchers.equalTo(repo.coordinates())\n+        );\n+    }\n+\n+    /**\n+     * PullRef.Smart can fetch its ref name.\n+     * @throws IOException If there is an I/O problem.\n+     */\n+    @Test\n+    public void fetchesRef() throws IOException {\n+        MatcherAssert.assertThat(\n+            pullRef().ref(),\n+            Matchers.equalTo(REF)\n+        );\n+    }\n+\n+    /**\n+     * PullRef.Smart can fetch its commit sha.\n+     * @throws IOException If there is an I/O problem.\n+     */\n+    @Test\n+    public void fetchesSha() throws IOException {\n+        MatcherAssert.assertThat(\n+            pullRef().sha(),\n+            Matchers.equalTo(SHA)\n+        );\n+    }\n+\n+    /**\n+     * PullRef.Smart can fetch its label.\n+     * @throws IOException If there is an I/O problem.\n+     */\n+    @Test\n+    public void fetchesLabel() throws IOException {\n+        MatcherAssert.assertThat(\n+            pullRef().label(),\n+            Matchers.equalTo(LABEL)\n+        );\n+    }\n+\n+    /**\n+     * PullRef.Smart can fetch its commit.\n+     * @throws IOException If there is an I/O problem.\n+     */\n+    @Test\n+    public void fetchesCommit() throws IOException {\n+        final Repo repo = new MkGithub().randomRepo();\n+        final Commit commit = pullRef(repo).commit();\n+        MatcherAssert.assertThat(\n+            commit.repo().coordinates(),\n+            Matchers.equalTo(repo.coordinates())\n+        );\n+        MatcherAssert.assertThat(\n+            commit.sha(),\n+            Matchers.equalTo(SHA)\n+        );\n+    }\n+\n+    /**\n+     * PullRef.Smart can fetch its user.\n+     * @throws IOException If there is an I/O problem.\n+     */\n+    @Test\n+    public void fetchesUser() throws IOException {\n+        final Repo repo = new MkGithub().randomRepo();\n+        MatcherAssert.assertThat(\n+            pullRef(repo).user().login(),\n+            Matchers.equalTo(repo.coordinates().user())\n+        );\n+    }\n+\n+    /**\n+     * Returns a smart pull request ref in the given repo for testing.\n+     * @param repo Repo to create the pull request ref in\n+     * @return PullRef.Smart\n+     * @throws IOException If there is an I/O problem.\n+     */\n+    private static PullRef.Smart pullRef(final Repo repo) throws IOException {\n+        final Coordinates coords = repo.coordinates();\n+        final JsonObject user = Json.createObjectBuilder()\n+            .add(\"login\", coords.user())\n+            .build();\n+        return new PullRef.Smart(\n+            new RtPullRef(\n+                repo.github(),\n+                Json.createObjectBuilder()\n+                    .add(\"label\", LABEL)\n+                    .add(\"ref\", REF)\n+                    .add(\"sha\", SHA)","path":"src/test/java/com/jcabi/github/PullRefTest.java","position":159,"original_position":159,"commit_id":"d6d503e7cdb323cfe84e6bffea3346f37c8cf0fa","original_commit_id":"d6d503e7cdb323cfe84e6bffea3346f37c8cf0fa","user":{"login":"pinaf","id":1054771,"avatar_url":"https://avatars.githubusercontent.com/u/1054771?v=3","gravatar_id":"","url":"https://api.github.com/users/pinaf","html_url":"https://github.com/pinaf","followers_url":"https://api.github.com/users/pinaf/followers","following_url":"https://api.github.com/users/pinaf/following{/other_user}","gists_url":"https://api.github.com/users/pinaf/gists{/gist_id}","starred_url":"https://api.github.com/users/pinaf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pinaf/subscriptions","organizations_url":"https://api.github.com/users/pinaf/orgs","repos_url":"https://api.github.com/users/pinaf/repos","events_url":"https://api.github.com/users/pinaf/events{/privacy}","received_events_url":"https://api.github.com/users/pinaf/received_events","type":"User","site_admin":false},"body":"@cvrebert same here","created_at":"2015-06-16T19:37:38Z","updated_at":"2015-06-16T19:37:38Z","html_url":"https://github.com/jcabi/jcabi-github/pull/1125#discussion_r32561633","pull_request_url":"https://api.github.com/repos/jcabi/jcabi-github/pulls/1125","_links":{"self":{"href":"https://api.github.com/repos/jcabi/jcabi-github/pulls/comments/32561633"},"html":{"href":"https://github.com/jcabi/jcabi-github/pull/1125#discussion_r32561633"},"pull_request":{"href":"https://api.github.com/repos/jcabi/jcabi-github/pulls/1125"}}},"pull_request":{"url":"https://api.github.com/repos/jcabi/jcabi-github/pulls/1125","id":37666417,"html_url":"https://github.com/jcabi/jcabi-github/pull/1125","diff_url":"https://github.com/jcabi/jcabi-github/pull/1125.diff","patch_url":"https://github.com/jcabi/jcabi-github/pull/1125.patch","issue_url":"https://api.github.com/repos/jcabi/jcabi-github/issues/1125","number":1125,"state":"open","locked":false,"title":"Add Pull.head/base, which return (newly-added) PullRef","user":{"login":"cvrebert","id":419884,"avatar_url":"https://avatars.githubusercontent.com/u/419884?v=3","gravatar_id":"","url":"https://api.github.com/users/cvrebert","html_url":"https://github.com/cvrebert","followers_url":"https://api.github.com/users/cvrebert/followers","following_url":"https://api.github.com/users/cvrebert/following{/other_user}","gists_url":"https://api.github.com/users/cvrebert/gists{/gist_id}","starred_url":"https://api.github.com/users/cvrebert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cvrebert/subscriptions","organizations_url":"https://api.github.com/users/cvrebert/orgs","repos_url":"https://api.github.com/users/cvrebert/repos","events_url":"https://api.github.com/users/cvrebert/events{/privacy}","received_events_url":"https://api.github.com/users/cvrebert/received_events","type":"User","site_admin":false},"body":"Fixes #1090 by adding `Pull.base()` and `Pull.head()` getters, which return instances of the new `PullRef` class, which allows structured access to the pull request branch+commit data. Thus, the user no longer has to resort to dealing with the raw JSON directly themselves.","created_at":"2015-06-15T07:59:35Z","updated_at":"2015-06-16T19:37:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a48c5fd9e4bf8500e1977e06388621245eb6d89d","assignee":{"login":"pinaf","id":1054771,"avatar_url":"https://avatars.githubusercontent.com/u/1054771?v=3","gravatar_id":"","url":"https://api.github.com/users/pinaf","html_url":"https://github.com/pinaf","followers_url":"https://api.github.com/users/pinaf/followers","following_url":"https://api.github.com/users/pinaf/following{/other_user}","gists_url":"https://api.github.com/users/pinaf/gists{/gist_id}","starred_url":"https://api.github.com/users/pinaf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pinaf/subscriptions","organizations_url":"https://api.github.com/users/pinaf/orgs","repos_url":"https://api.github.com/users/pinaf/repos","events_url":"https://api.github.com/users/pinaf/events{/privacy}","received_events_url":"https://api.github.com/users/pinaf/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/jcabi/jcabi-github/pulls/1125/commits","review_comments_url":"https://api.github.com/repos/jcabi/jcabi-github/pulls/1125/comments","review_comment_url":"https://api.github.com/repos/jcabi/jcabi-github/pulls/comments{/number}","comments_url":"https://api.github.com/repos/jcabi/jcabi-github/issues/1125/comments","statuses_url":"https://api.github.com/repos/jcabi/jcabi-github/statuses/d6d503e7cdb323cfe84e6bffea3346f37c8cf0fa","head":{"label":"cvrebert:impl-1090-pr-head-base","ref":"impl-1090-pr-head-base","sha":"d6d503e7cdb323cfe84e6bffea3346f37c8cf0fa","user":{"login":"cvrebert","id":419884,"avatar_url":"https://avatars.githubusercontent.com/u/419884?v=3","gravatar_id":"","url":"https://api.github.com/users/cvrebert","html_url":"https://github.com/cvrebert","followers_url":"https://api.github.com/users/cvrebert/followers","following_url":"https://api.github.com/users/cvrebert/following{/other_user}","gists_url":"https://api.github.com/users/cvrebert/gists{/gist_id}","starred_url":"https://api.github.com/users/cvrebert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cvrebert/subscriptions","organizations_url":"https://api.github.com/users/cvrebert/orgs","repos_url":"https://api.github.com/users/cvrebert/repos","events_url":"https://api.github.com/users/cvrebert/events{/privacy}","received_events_url":"https://api.github.com/users/cvrebert/received_events","type":"User","site_admin":false},"repo":{"id":36204267,"name":"jcabi-github","full_name":"cvrebert/jcabi-github","owner":{"login":"cvrebert","id":419884,"avatar_url":"https://avatars.githubusercontent.com/u/419884?v=3","gravatar_id":"","url":"https://api.github.com/users/cvrebert","html_url":"https://github.com/cvrebert","followers_url":"https://api.github.com/users/cvrebert/followers","following_url":"https://api.github.com/users/cvrebert/following{/other_user}","gists_url":"https://api.github.com/users/cvrebert/gists{/gist_id}","starred_url":"https://api.github.com/users/cvrebert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cvrebert/subscriptions","organizations_url":"https://api.github.com/users/cvrebert/orgs","repos_url":"https://api.github.com/users/cvrebert/repos","events_url":"https://api.github.com/users/cvrebert/events{/privacy}","received_events_url":"https://api.github.com/users/cvrebert/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/cvrebert/jcabi-github","description":"Object Oriented Wrapper of Github API","fork":true,"url":"https://api.github.com/repos/cvrebert/jcabi-github","forks_url":"https://api.github.com/repos/cvrebert/jcabi-github/forks","keys_url":"https://api.github.com/repos/cvrebert/jcabi-github/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cvrebert/jcabi-github/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cvrebert/jcabi-github/teams","hooks_url":"https://api.github.com/repos/cvrebert/jcabi-github/hooks","issue_events_url":"https://api.github.com/repos/cvrebert/jcabi-github/issues/events{/number}","events_url":"https://api.github.com/repos/cvrebert/jcabi-github/events","assignees_url":"https://api.github.com/repos/cvrebert/jcabi-github/assignees{/user}","branches_url":"https://api.github.com/repos/cvrebert/jcabi-github/branches{/branch}","tags_url":"https://api.github.com/repos/cvrebert/jcabi-github/tags","blobs_url":"https://api.github.com/repos/cvrebert/jcabi-github/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cvrebert/jcabi-github/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cvrebert/jcabi-github/git/refs{/sha}","trees_url":"https://api.github.com/repos/cvrebert/jcabi-github/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cvrebert/jcabi-github/statuses/{sha}","languages_url":"https://api.github.com/repos/cvrebert/jcabi-github/languages","stargazers_url":"https://api.github.com/repos/cvrebert/jcabi-github/stargazers","contributors_url":"https://api.github.com/repos/cvrebert/jcabi-github/contributors","subscribers_url":"https://api.github.com/repos/cvrebert/jcabi-github/subscribers","subscription_url":"https://api.github.com/repos/cvrebert/jcabi-github/subscription","commits_url":"https://api.github.com/repos/cvrebert/jcabi-github/commits{/sha}","git_commits_url":"https://api.github.com/repos/cvrebert/jcabi-github/git/commits{/sha}","comments_url":"https://api.github.com/repos/cvrebert/jcabi-github/comments{/number}","issue_comment_url":"https://api.github.com/repos/cvrebert/jcabi-github/issues/comments{/number}","contents_url":"https://api.github.com/repos/cvrebert/jcabi-github/contents/{+path}","compare_url":"https://api.github.com/repos/cvrebert/jcabi-github/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cvrebert/jcabi-github/merges","archive_url":"https://api.github.com/repos/cvrebert/jcabi-github/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cvrebert/jcabi-github/downloads","issues_url":"https://api.github.com/repos/cvrebert/jcabi-github/issues{/number}","pulls_url":"https://api.github.com/repos/cvrebert/jcabi-github/pulls{/number}","milestones_url":"https://api.github.com/repos/cvrebert/jcabi-github/milestones{/number}","notifications_url":"https://api.github.com/repos/cvrebert/jcabi-github/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cvrebert/jcabi-github/labels{/name}","releases_url":"https://api.github.com/repos/cvrebert/jcabi-github/releases{/id}","created_at":"2015-05-25T02:01:20Z","updated_at":"2015-05-25T02:01:22Z","pushed_at":"2015-06-16T00:49:54Z","git_url":"git://github.com/cvrebert/jcabi-github.git","ssh_url":"git@github.com:cvrebert/jcabi-github.git","clone_url":"https://github.com/cvrebert/jcabi-github.git","svn_url":"https://github.com/cvrebert/jcabi-github","homepage":"github.jcabi.com","size":5283,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"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":"jcabi:master","ref":"master","sha":"361bb23ed4c028914d45d53c3727c48b035ee643","user":{"login":"jcabi","id":5272640,"avatar_url":"https://avatars.githubusercontent.com/u/5272640?v=3","gravatar_id":"","url":"https://api.github.com/users/jcabi","html_url":"https://github.com/jcabi","followers_url":"https://api.github.com/users/jcabi/followers","following_url":"https://api.github.com/users/jcabi/following{/other_user}","gists_url":"https://api.github.com/users/jcabi/gists{/gist_id}","starred_url":"https://api.github.com/users/jcabi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jcabi/subscriptions","organizations_url":"https://api.github.com/users/jcabi/orgs","repos_url":"https://api.github.com/users/jcabi/repos","events_url":"https://api.github.com/users/jcabi/events{/privacy}","received_events_url":"https://api.github.com/users/jcabi/received_events","type":"Organization","site_admin":false},"repo":{"id":14204295,"name":"jcabi-github","full_name":"jcabi/jcabi-github","owner":{"login":"jcabi","id":5272640,"avatar_url":"https://avatars.githubusercontent.com/u/5272640?v=3","gravatar_id":"","url":"https://api.github.com/users/jcabi","html_url":"https://github.com/jcabi","followers_url":"https://api.github.com/users/jcabi/followers","following_url":"https://api.github.com/users/jcabi/following{/other_user}","gists_url":"https://api.github.com/users/jcabi/gists{/gist_id}","starred_url":"https://api.github.com/users/jcabi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jcabi/subscriptions","organizations_url":"https://api.github.com/users/jcabi/orgs","repos_url":"https://api.github.com/users/jcabi/repos","events_url":"https://api.github.com/users/jcabi/events{/privacy}","received_events_url":"https://api.github.com/users/jcabi/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/jcabi/jcabi-github","description":"Object Oriented Wrapper of Github API","fork":false,"url":"https://api.github.com/repos/jcabi/jcabi-github","forks_url":"https://api.github.com/repos/jcabi/jcabi-github/forks","keys_url":"https://api.github.com/repos/jcabi/jcabi-github/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jcabi/jcabi-github/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jcabi/jcabi-github/teams","hooks_url":"https://api.github.com/repos/jcabi/jcabi-github/hooks","issue_events_url":"https://api.github.com/repos/jcabi/jcabi-github/issues/events{/number}","events_url":"https://api.github.com/repos/jcabi/jcabi-github/events","assignees_url":"https://api.github.com/repos/jcabi/jcabi-github/assignees{/user}","branches_url":"https://api.github.com/repos/jcabi/jcabi-github/branches{/branch}","tags_url":"https://api.github.com/repos/jcabi/jcabi-github/tags","blobs_url":"https://api.github.com/repos/jcabi/jcabi-github/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jcabi/jcabi-github/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jcabi/jcabi-github/git/refs{/sha}","trees_url":"https://api.github.com/repos/jcabi/jcabi-github/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jcabi/jcabi-github/statuses/{sha}","languages_url":"https://api.github.com/repos/jcabi/jcabi-github/languages","stargazers_url":"https://api.github.com/repos/jcabi/jcabi-github/stargazers","contributors_url":"https://api.github.com/repos/jcabi/jcabi-github/contributors","subscribers_url":"https://api.github.com/repos/jcabi/jcabi-github/subscribers","subscription_url":"https://api.github.com/repos/jcabi/jcabi-github/subscription","commits_url":"https://api.github.com/repos/jcabi/jcabi-github/commits{/sha}","git_commits_url":"https://api.github.com/repos/jcabi/jcabi-github/git/commits{/sha}","comments_url":"https://api.github.com/repos/jcabi/jcabi-github/comments{/number}","issue_comment_url":"https://api.github.com/repos/jcabi/jcabi-github/issues/comments{/number}","contents_url":"https://api.github.com/repos/jcabi/jcabi-github/contents/{+path}","compare_url":"https://api.github.com/repos/jcabi/jcabi-github/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jcabi/jcabi-github/merges","archive_url":"https://api.github.com/repos/jcabi/jcabi-github/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jcabi/jcabi-github/downloads","issues_url":"https://api.github.com/repos/jcabi/jcabi-github/issues{/number}","pulls_url":"https://api.github.com/repos/jcabi/jcabi-github/pulls{/number}","milestones_url":"https://api.github.com/repos/jcabi/jcabi-github/milestones{/number}","notifications_url":"https://api.github.com/repos/jcabi/jcabi-github/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jcabi/jcabi-github/labels{/name}","releases_url":"https://api.github.com/repos/jcabi/jcabi-github/releases{/id}","created_at":"2013-11-07T13:23:16Z","updated_at":"2015-06-12T23:21:20Z","pushed_at":"2015-06-16T19:17:41Z","git_url":"git://github.com/jcabi/jcabi-github.git","ssh_url":"git@github.com:jcabi/jcabi-github.git","clone_url":"https://github.com/jcabi/jcabi-github.git","svn_url":"https://github.com/jcabi/jcabi-github","homepage":"github.jcabi.com","size":39923,"stargazers_count":67,"watchers_count":67,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":66,"mirror_url":null,"open_issues_count":52,"forks":66,"open_issues":52,"watchers":67,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/jcabi/jcabi-github/pulls/1125"},"html":{"href":"https://github.com/jcabi/jcabi-github/pull/1125"},"issue":{"href":"https://api.github.com/repos/jcabi/jcabi-github/issues/1125"},"comments":{"href":"https://api.github.com/repos/jcabi/jcabi-github/issues/1125/comments"},"review_comments":{"href":"https://api.github.com/repos/jcabi/jcabi-github/pulls/1125/comments"},"review_comment":{"href":"https://api.github.com/repos/jcabi/jcabi-github/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/jcabi/jcabi-github/pulls/1125/commits"},"statuses":{"href":"https://api.github.com/repos/jcabi/jcabi-github/statuses/d6d503e7cdb323cfe84e6bffea3346f37c8cf0fa"}}}}