Package org.kohsuke.github
Class GHPullRequest
- java.lang.Object
-
- org.kohsuke.github.GHObject
-
- org.kohsuke.github.GHIssue
-
- org.kohsuke.github.GHPullRequest
-
- All Implemented Interfaces:
Reactable,Refreshable
public class GHPullRequest extends GHIssue implements Refreshable
A pull request.- Author:
- Kohsuke Kawaguchi
- See Also:
GHRepository#getPullRequest(int)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classGHPullRequest.MergeMethodThe enum MergeMethod.-
Nested classes/interfaces inherited from class org.kohsuke.github.GHIssue
GHIssue.PullRequest
-
-
Constructor Summary
Constructors Constructor Description GHPullRequest()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleancanMaintainerModify()Can maintainer modify boolean.GHPullRequestReviewBuildercreateReview()Create review gh pull request review builder.GHPullRequestReviewcreateReview(String body, GHPullRequestReviewState event, List<GHPullRequestReviewComment> comments)Deprecated.UsecreateReview()GHPullRequestReviewcreateReview(String body, GHPullRequestReviewState event, GHPullRequestReviewComment... comments)Deprecated.UsecreateReview()GHPullRequestReviewCommentcreateReviewComment(String body, String sha, String path, int position)Create review comment gh pull request review comment.intgetAdditions()Gets additions.protected StringgetApiRoute()Gets api route.GHCommitPointergetBase()This points to where the change should be pulled into, but I'm not really sure what exactly it means.intgetChangedFiles()Gets changed files.GHUsergetClosedBy()Reports who has closed the issue.intgetCommits()Gets commits.intgetDeletions()Gets deletions.URLgetDiffUrl()The diff file, like https://github.com/jenkinsci/jenkins/pull/100.diffGHCommitPointergetHead()The change that should be pulled.DategetIssueUpdatedAt()Deprecated.URLgetIssueUrl()The URL of the patch file.BooleangetMergeable()Is this PR mergeable?StringgetMergeableState()Gets mergeable state.StringgetMergeCommitSha()See GitHub blog postDategetMergedAt()Gets merged at.GHUsergetMergedBy()Gets merged by.URLgetPatchUrl()The URL of the patch file.GHIssue.PullRequestgetPullRequest()Returns non-null if this issue is a shadow of a pull request.List<GHUser>getRequestedReviewers()Gets requested reviewers.List<GHTeam>getRequestedTeams()Gets requested teams.intgetReviewComments()Gets review comments.booleanisDraft()Is draft boolean.booleanisMerged()Is merged boolean.PagedIterable<GHPullRequestCommitDetail>listCommits()Retrieves all the commits associated to this pull request.PagedIterable<GHPullRequestFileDetail>listFiles()Retrieves all the files associated to this pull request.PagedIterable<GHPullRequestReviewComment>listReviewComments()Obtains all the review comments associated with this pull request.PagedIterable<GHPullRequestReview>listReviews()Retrieves all the reviews associated to this pull request.voidmerge(String msg)Merge this pull request.voidmerge(String msg, String sha)Merge this pull request.voidmerge(String msg, String sha, GHPullRequest.MergeMethod method)Merge this pull request, using the specified merge method.voidrefresh()Repopulates this object.voidrequestReviewers(List<GHUser> reviewers)Request reviewers.voidrequestTeamReviewers(List<GHTeam> teams)Request team reviewers.GHPullRequestsetBaseBranch(String newBaseBranch)Set the base branch on the pull requestvoidupdateBranch()Updates the branch.-
Methods inherited from class org.kohsuke.github.GHIssue
addAssignees, addAssignees, addLabels, addLabels, addLabels, assignTo, close, comment, createReaction, getApiURL, getAssignee, getAssignees, getBody, getClosedAt, getComments, getCommentsCount, getHtmlUrl, getIssuesApiRoute, getLabels, getLogins, getMilestone, getNumber, getRepository, getState, getTitle, getUser, isLocked, isPullRequest, listComments, listEvents, listReactions, lock, removeAssignees, removeAssignees, removeLabel, removeLabels, removeLabels, removeLabels, reopen, setAssignees, setAssignees, setBody, setLabels, setMilestone, setTitle, unlock
-
Methods inherited from class org.kohsuke.github.GHObject
getCreatedAt, getId, getNodeId, getResponseHeaderFields, getUpdatedAt, getUrl, setResponseHeaderFields, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.kohsuke.github.Refreshable
refresh
-
-
-
-
Method Detail
-
getApiRoute
protected String getApiRoute()
Description copied from class:GHIssueGets api route.- Overrides:
getApiRoutein classGHIssue- Returns:
- the api route
-
getPatchUrl
public URL getPatchUrl()
The URL of the patch file. like https://github.com/jenkinsci/jenkins/pull/100.patch- Returns:
- the patch url
-
getIssueUrl
public URL getIssueUrl()
The URL of the patch file. like https://github.com/jenkinsci/jenkins/pull/100.patch- Returns:
- the issue url
-
getBase
public GHCommitPointer getBase()
This points to where the change should be pulled into, but I'm not really sure what exactly it means.- Returns:
- the base
-
getHead
public GHCommitPointer getHead()
The change that should be pulled. The tip of the commits to merge.- Returns:
- the head
-
getIssueUpdatedAt
@Deprecated public Date getIssueUpdatedAt() throws IOException
Deprecated.Gets issue updated at.- Returns:
- the issue updated at
- Throws:
IOException- the io exception
-
getDiffUrl
public URL getDiffUrl()
The diff file, like https://github.com/jenkinsci/jenkins/pull/100.diff- Returns:
- the diff url
-
getMergedAt
public Date getMergedAt()
Gets merged at.- Returns:
- the merged at
-
getClosedBy
public GHUser getClosedBy()
Description copied from class:GHIssueReports who has closed the issue.Note that GitHub doesn't always seem to report this information even for an issue that's already closed. See https://github.com/kohsuke/github-api/issues/60.
- Overrides:
getClosedByin classGHIssue- Returns:
- the closed by
-
getPullRequest
public GHIssue.PullRequest getPullRequest()
Description copied from class:GHIssueReturns non-null if this issue is a shadow of a pull request.- Overrides:
getPullRequestin classGHIssue- Returns:
- the pull request
-
getMergedBy
public GHUser getMergedBy() throws IOException
Gets merged by.- Returns:
- the merged by
- Throws:
IOException- the io exception
-
getReviewComments
public int getReviewComments() throws IOExceptionGets review comments.- Returns:
- the review comments
- Throws:
IOException- the io exception
-
getAdditions
public int getAdditions() throws IOExceptionGets additions.- Returns:
- the additions
- Throws:
IOException- the io exception
-
getCommits
public int getCommits() throws IOExceptionGets commits.- Returns:
- the commits
- Throws:
IOException- the io exception
-
isMerged
public boolean isMerged() throws IOExceptionIs merged boolean.- Returns:
- the boolean
- Throws:
IOException- the io exception
-
canMaintainerModify
public boolean canMaintainerModify() throws IOExceptionCan maintainer modify boolean.- Returns:
- the boolean
- Throws:
IOException- the io exception
-
isDraft
public boolean isDraft() throws IOExceptionIs draft boolean.- Returns:
- the boolean
- Throws:
IOException- the io exception
-
getMergeable
public Boolean getMergeable() throws IOException
Is this PR mergeable?- Returns:
- null if the state has not been determined yet, for example when a PR is newly created. If this method is called on an instance whose mergeable state is not yet known, API call is made to retrieve the latest state.
- Throws:
IOException- the io exception
-
getDeletions
public int getDeletions() throws IOExceptionGets deletions.- Returns:
- the deletions
- Throws:
IOException- the io exception
-
getMergeableState
public String getMergeableState() throws IOException
Gets mergeable state.- Returns:
- the mergeable state
- Throws:
IOException- the io exception
-
getChangedFiles
public int getChangedFiles() throws IOExceptionGets changed files.- Returns:
- the changed files
- Throws:
IOException- the io exception
-
getMergeCommitSha
public String getMergeCommitSha() throws IOException
See GitHub blog post- Returns:
- the merge commit sha
- Throws:
IOException- the io exception
-
getRequestedReviewers
public List<GHUser> getRequestedReviewers() throws IOException
Gets requested reviewers.- Returns:
- the requested reviewers
- Throws:
IOException- the io exception
-
getRequestedTeams
public List<GHTeam> getRequestedTeams() throws IOException
Gets requested teams.- Returns:
- the requested teams
- Throws:
IOException- the io exception
-
refresh
public void refresh() throws IOExceptionRepopulates this object.- Specified by:
refreshin interfaceRefreshable- Throws:
IOException- the io exception
-
listFiles
public PagedIterable<GHPullRequestFileDetail> listFiles()
Retrieves all the files associated to this pull request. The paginated response returns 30 files per page by default.- Returns:
- the paged iterable
- See Also:
- List pull requests files
-
listReviews
public PagedIterable<GHPullRequestReview> listReviews()
Retrieves all the reviews associated to this pull request.- Returns:
- the paged iterable
-
listReviewComments
public PagedIterable<GHPullRequestReviewComment> listReviewComments() throws IOException
Obtains all the review comments associated with this pull request.- Returns:
- the paged iterable
- Throws:
IOException- the io exception
-
listCommits
public PagedIterable<GHPullRequestCommitDetail> listCommits()
Retrieves all the commits associated to this pull request.- Returns:
- the paged iterable
-
createReview
@Deprecated public GHPullRequestReview createReview(String body, @CheckForNull GHPullRequestReviewState event, GHPullRequestReviewComment... comments) throws IOException
Deprecated.UsecreateReview()Create review gh pull request review.- Parameters:
body- the bodyevent- the eventcomments- the comments- Returns:
- the gh pull request review
- Throws:
IOException- the io exception
-
createReview
@Deprecated public GHPullRequestReview createReview(String body, @CheckForNull GHPullRequestReviewState event, List<GHPullRequestReviewComment> comments) throws IOException
Deprecated.UsecreateReview()Create review gh pull request review.- Parameters:
body- the bodyevent- the eventcomments- the comments- Returns:
- the gh pull request review
- Throws:
IOException- the io exception
-
createReview
public GHPullRequestReviewBuilder createReview()
Create review gh pull request review builder.- Returns:
- the gh pull request review builder
-
createReviewComment
public GHPullRequestReviewComment createReviewComment(String body, String sha, String path, int position) throws IOException
Create review comment gh pull request review comment.- Parameters:
body- the bodysha- the shapath- the pathposition- the position- Returns:
- the gh pull request review comment
- Throws:
IOException- the io exception
-
requestReviewers
public void requestReviewers(List<GHUser> reviewers) throws IOException
Request reviewers.- Parameters:
reviewers- the reviewers- Throws:
IOException- the io exception
-
requestTeamReviewers
public void requestTeamReviewers(List<GHTeam> teams) throws IOException
Request team reviewers.- Parameters:
teams- the teams- Throws:
IOException- the io exception
-
setBaseBranch
public GHPullRequest setBaseBranch(String newBaseBranch) throws IOException
Set the base branch on the pull request- Parameters:
newBaseBranch- the name of the new base branch- Returns:
- the updated pull request
- Throws:
IOException- the io exception
-
updateBranch
@Preview(LYDIAN) public void updateBranch() throws IOException
Updates the branch. The same as pressing the button in the web GUI.- Throws:
IOException- the io exception
-
merge
public void merge(String msg) throws IOException
Merge this pull request.The equivalent of the big green "Merge pull request" button.
- Parameters:
msg- Commit message. If null, the default one will be used.- Throws:
IOException- the io exception
-
merge
public void merge(String msg, String sha) throws IOException
Merge this pull request.The equivalent of the big green "Merge pull request" button.
- Parameters:
msg- Commit message. If null, the default one will be used.sha- SHA that pull request head must match to allow merge.- Throws:
IOException- the io exception
-
merge
public void merge(String msg, String sha, GHPullRequest.MergeMethod method) throws IOException
Merge this pull request, using the specified merge method.The equivalent of the big green "Merge pull request" button.
- Parameters:
msg- Commit message. If null, the default one will be used.sha- the shamethod- SHA that pull request head must match to allow merge.- Throws:
IOException- the io exception
-
-