methods for listing PRs where the commit is head & listing branches which contain the commit

This commit is contained in:
Tadas Giniotis
2020-08-12 01:56:23 +03:00
parent fc38dba59a
commit def2f0b37d
2 changed files with 43 additions and 0 deletions

View File

@@ -11,6 +11,8 @@ import java.util.Collections;
import java.util.Date;
import java.util.List;
import static org.kohsuke.github.Previews.GROOT;
/**
* A commit in a repository.
*
@@ -446,6 +448,39 @@ public class GHCommit {
return owner.root.getUser(author.login);
}
/**
* Retrieves a list of pull requests which contain this commit.
*
* @return {@link PagedIterable} with the pull requests which contain this commit
*/
@Preview
@Deprecated
public PagedIterable<GHPullRequest> listPullRequests() {
return owner.root.createRequest()
.withPreview(GROOT)
.withUrlPath(String.format("/repos/%s/%s/commits/%s/pulls", owner.getOwnerName(), owner.getName(), sha))
.toIterable(GHPullRequest[].class, item -> item.wrapUp(owner));
}
/**
* Retrieves a list of branches where this commit is the head commit.
*
* @return {@link PagedIterable} with the branches where the commit is the head commit
* @throws IOException
* the io exception
*/
@Preview
@Deprecated
public PagedIterable<GHBranch> listBranchesWhereHead() throws IOException {
return owner.root.createRequest()
.withPreview(GROOT)
.withUrlPath(String.format("/repos/%s/%s/commits/%s/branches-where-head",
owner.getOwnerName(),
owner.getName(),
sha))
.toIterable(GHBranch[].class, item -> item.wrap(owner));
}
/**
* List comments paged iterable.
*

View File

@@ -37,6 +37,14 @@ class Previews {
*/
static final String GAMBIT = "application/vnd.github.gambit-preview+json";
/**
* List branches or pull requests for a commit
*
* @see <a href="https://developer.github.com/v3/previews/#list-branches-or-pull-requests-for-a-commit">GitHub API
* Previews</a>
*/
static final String GROOT = "application/vnd.github.groot-preview+json";
/**
* Manage projects
*