Class GHPullRequest

All Implemented Interfaces:
Reactable, Refreshable

public class GHPullRequest extends GHIssue implements Refreshable
A pull request.
Author:
Kohsuke Kawaguchi
See Also:
  • Constructor Details

    • GHPullRequest

      public GHPullRequest()
      Create default GHPullRequest instance
  • Method Details

    • getApiRoute

      protected String getApiRoute()
      Gets the api route.
      Overrides:
      getApiRoute in class GHIssue
      Returns:
      the api route
    • getAutoMerge

      public GHPullRequest.AutoMerge getAutoMerge()
      The status of auto merging a pull request.
      Returns:
      the GHPullRequest.AutoMerge or null if no auto merge is set.
    • 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
    • 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()
      Gets the closed by.
      Overrides:
      getClosedBy in class GHIssue
      Returns:
      the closed by
    • getPullRequest

      public GHIssue.PullRequest getPullRequest()
      Gets the pull request.
      Overrides:
      getPullRequest in class GHIssue
      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 IOException
      Gets review comments.
      Returns:
      the review comments
      Throws:
      IOException - the io exception
    • getAdditions

      public int getAdditions() throws IOException
      Gets additions.
      Returns:
      the additions
      Throws:
      IOException - the io exception
    • getCommits

      public int getCommits() throws IOException
      Gets the number of commits.
      Returns:
      the number of commits
      Throws:
      IOException - the io exception
    • isMerged

      public boolean isMerged() throws IOException
      Is merged boolean.
      Returns:
      the boolean
      Throws:
      IOException - the io exception
    • canMaintainerModify

      public boolean canMaintainerModify() throws IOException
      Can maintainer modify boolean.
      Returns:
      the boolean
      Throws:
      IOException - the io exception
    • isDraft

      public boolean isDraft() throws IOException
      Is 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 IOException
      Gets 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 IOException
      Gets changed files.
      Returns:
      the changed files
      Throws:
      IOException - the io exception
    • getMergeCommitSha

      public String getMergeCommitSha() throws IOException
      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 IOException
      Repopulates this object.
      Specified by:
      refresh in interface Refreshable
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • 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:
    • 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

      Retrieves all the commits associated to this pull request.
      Returns:
      the paged iterable
    • createReview

      public GHPullRequestReviewBuilder createReview()
      Create review gh pull request review builder.
      Returns:
      the gh pull request review builder
    • createReviewComment

      public GHPullRequestReviewCommentBuilder createReviewComment()
      Create gh pull request review comment builder.
      Returns:
      the gh pull request review comment builder.
    • createReviewComment

      @Deprecated public GHPullRequestReviewComment createReviewComment(String body, String sha, String path, int position) throws IOException
      Deprecated.
      Create review comment gh pull request review comment.
      Parameters:
      body - the body
      sha - the sha
      path - the path
      position - 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

      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 sha
      method - SHA that pull request head must match to allow merge.
      Throws:
      IOException - the io exception