Skip to content

Commit

Permalink
Merge pull request #231 from recena/MergeCommitSha
Browse files Browse the repository at this point in the history
Support for merge_commit_sha
  • Loading branch information
recena committed Nov 25, 2015
2 parents bb17ca9 + c6d2b1a commit f7d1327
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/main/java/org/kohsuke/github/GHPullRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -185,6 +186,14 @@ public int getChangedFiles() throws IOException {
return changed_files;
}

/**
* See <a href="https://developer.github.com/changes/2013-04-25-deprecating-merge-commit-sha">GitHub blog post</a>
*/
public String getMergeCommitSha() throws IOException {
populate();
return merge_commit_sha;
}

/**
* Fully populate the data by retrieving missing data.
*
Expand Down
9 changes: 9 additions & 0 deletions src/test/java/org/kohsuke/github/PullRequestTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ public void testPullRequestReviewComments() throws Exception {
assertTrue(comments.isEmpty());
}

@Test
public void testMergeCommitSHA() throws Exception {
String name = rnd.next();
GHPullRequest p = getRepository().createPullRequest(name, "stable", "master", "## test");
GHPullRequest updated = getRepository().getPullRequest(p.getNumber());
GHCommit commit = getRepository().getCommit(updated.getMergeCommitSha());
assertNotNull(commit);
}

@Test
// Requires push access to the test repo to pass
public void setLabels() throws Exception {
Expand Down

0 comments on commit f7d1327

Please sign in to comment.