From bafddf4bafc9f897f2c0dbb9d4e42de244e08ead Mon Sep 17 00:00:00 2001 From: Manuel Recena Date: Sat, 14 Nov 2015 12:11:24 +0100 Subject: [PATCH 1/5] Initial source code modifications --- src/main/java/org/kohsuke/github/GHPullRequest.java | 12 +++++++++--- .../java/org/kohsuke/github/PullRequestTest.java | 9 +++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/kohsuke/github/GHPullRequest.java b/src/main/java/org/kohsuke/github/GHPullRequest.java index 909110b727..42cc38992e 100644 --- a/src/main/java/org/kohsuke/github/GHPullRequest.java +++ b/src/main/java/org/kohsuke/github/GHPullRequest.java @@ -50,6 +50,7 @@ public class GHPullRequest extends GHIssue { private int deletions; private String mergeable_state; private int changed_files; + private String merge_commit_sha; /** * GitHub doesn't return some properties of {@link GHIssue} when requesting the GET on the 'pulls' API @@ -142,9 +143,9 @@ public PullRequest getPullRequest() { } // -// details that are only available via get with ID -// -// + // details that are only available via get with ID + // + public GHUser getMergedBy() throws IOException { populate(); return merged_by; @@ -185,6 +186,11 @@ public int getChangedFiles() throws IOException { return changed_files; } + public String getMergeCommitSha() throws IOException { + populate(); + return merge_commit_sha; + } + /** * Fully populate the data by retrieving missing data. * diff --git a/src/test/java/org/kohsuke/github/PullRequestTest.java b/src/test/java/org/kohsuke/github/PullRequestTest.java index 9fc55f7519..9ef582cb79 100644 --- a/src/test/java/org/kohsuke/github/PullRequestTest.java +++ b/src/test/java/org/kohsuke/github/PullRequestTest.java @@ -49,6 +49,15 @@ public void testPullRequestReviewComments() throws Exception { assertTrue(comments.isEmpty()); } + @Test + public void testMergeCommitSHA() throws Exception { + String name = rnd.next(); + GHRepository repo = gitHub.getMyself().getRepository("website"); + GHPullRequest p = repo.createPullRequest(name, "feature5", "master", "## test"); + GHRef ref = repo.getRef("pull/" + p.getNumber() + "/merge"); + assertTrue(ref.getObject().getSha() == p.getMergeCommitSha()); + } + @Test // Requires push access to the test repo to pass public void setLabels() throws Exception { From 08be8eb4f8ae4b202c7ab74de51958c632a13223 Mon Sep 17 00:00:00 2001 From: Manuel Recena Date: Sun, 15 Nov 2015 11:46:18 +0100 Subject: [PATCH 2/5] Added a new test testMergeCommitSHA() --- src/test/java/org/kohsuke/github/PullRequestTest.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/java/org/kohsuke/github/PullRequestTest.java b/src/test/java/org/kohsuke/github/PullRequestTest.java index 9ef582cb79..4ed9dd5b0f 100644 --- a/src/test/java/org/kohsuke/github/PullRequestTest.java +++ b/src/test/java/org/kohsuke/github/PullRequestTest.java @@ -52,10 +52,10 @@ public void testPullRequestReviewComments() throws Exception { @Test public void testMergeCommitSHA() throws Exception { String name = rnd.next(); - GHRepository repo = gitHub.getMyself().getRepository("website"); - GHPullRequest p = repo.createPullRequest(name, "feature5", "master", "## test"); - GHRef ref = repo.getRef("pull/" + p.getNumber() + "/merge"); - assertTrue(ref.getObject().getSha() == p.getMergeCommitSha()); + GHPullRequest p = getRepository().createPullRequest(name, "stable", "master", "## test"); + GHPullRequest updated = getRepository().getPullRequest(p.getNumber()); + GHCommit commit = getRepository().getCommit(updated.getMergeCommitSha()); + assertNotNull(commit); } @Test From b0789a7ce72b6e1773b47d4e778535f839863480 Mon Sep 17 00:00:00 2001 From: Manuel Recena Date: Sun, 15 Nov 2015 11:50:13 +0100 Subject: [PATCH 3/5] Set merge_commit_sha as deprecated --- src/main/java/org/kohsuke/github/GHPullRequest.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/org/kohsuke/github/GHPullRequest.java b/src/main/java/org/kohsuke/github/GHPullRequest.java index 42cc38992e..b9078d9c30 100644 --- a/src/main/java/org/kohsuke/github/GHPullRequest.java +++ b/src/main/java/org/kohsuke/github/GHPullRequest.java @@ -50,6 +50,8 @@ public class GHPullRequest extends GHIssue { private int deletions; private String mergeable_state; private int changed_files; + + @Deprecated private String merge_commit_sha; /** @@ -186,6 +188,10 @@ public int getChangedFiles() throws IOException { return changed_files; } + /** + * FYI: https://developer.github.com/changes/2013-04-25-deprecating-merge-commit-sha + */ + @Deprecated public String getMergeCommitSha() throws IOException { populate(); return merge_commit_sha; From 354969d5fae984af50a648cded5300e04cf3d512 Mon Sep 17 00:00:00 2001 From: Manuel Recena Date: Mon, 16 Nov 2015 11:16:58 +0100 Subject: [PATCH 4/5] Javadoc comment reviewed --- src/main/java/org/kohsuke/github/GHPullRequest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/kohsuke/github/GHPullRequest.java b/src/main/java/org/kohsuke/github/GHPullRequest.java index b9078d9c30..8d1f0cab2f 100644 --- a/src/main/java/org/kohsuke/github/GHPullRequest.java +++ b/src/main/java/org/kohsuke/github/GHPullRequest.java @@ -189,7 +189,7 @@ public int getChangedFiles() throws IOException { } /** - * FYI: https://developer.github.com/changes/2013-04-25-deprecating-merge-commit-sha + * See GitHub blog post */ @Deprecated public String getMergeCommitSha() throws IOException { From c6d2b1a22257f15963d3e4bd79929af10670b918 Mon Sep 17 00:00:00 2001 From: Manuel Recena Date: Mon, 23 Nov 2015 09:33:32 +0100 Subject: [PATCH 5/5] @deprecated annotations were removed --- src/main/java/org/kohsuke/github/GHPullRequest.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/java/org/kohsuke/github/GHPullRequest.java b/src/main/java/org/kohsuke/github/GHPullRequest.java index 8d1f0cab2f..5604d2355e 100644 --- a/src/main/java/org/kohsuke/github/GHPullRequest.java +++ b/src/main/java/org/kohsuke/github/GHPullRequest.java @@ -50,8 +50,6 @@ public class GHPullRequest extends GHIssue { private int deletions; private String mergeable_state; private int changed_files; - - @Deprecated private String merge_commit_sha; /** @@ -191,7 +189,6 @@ public int getChangedFiles() throws IOException { /** * See GitHub blog post */ - @Deprecated public String getMergeCommitSha() throws IOException { populate(); return merge_commit_sha;