Interface GitPullRequestService


public interface GitPullRequestService
Provides extensions to the PullRequestService specific to working with pull requests between Git repositories.
Since:
5.5
  • Method Summary

    Modifier and Type
    Method
    Description
    canRebase(com.atlassian.bitbucket.pull.PullRequest pullRequest)
    Checks preconditions to determine whether the specified pull request can be rebased.
    Optional<com.atlassian.bitbucket.repository.RefChange>
    Rebases a pull request, updating the "from" ref with new commits starting from the "to" ref.
  • Method Details

    • canRebase

      @Nonnull PullRequestRebaseability canRebase(@Nonnull com.atlassian.bitbucket.pull.PullRequest pullRequest)
      Checks preconditions to determine whether the specified pull request can be rebased.

      Some of the preconditions are:

      • The pull request is between Git repositories
      • The pull request is currently open
      • The pull request's "from" ref is a branch
        • In other words, the qualified ID for the "from" ref must start with refs/heads/
        • Tags, and other non-standard refs, cannot be rebased
      • The current user has an e-mail address
        • Pull requests cannot be rebased anonymously
        • git rebase records the current user as the committer for the rebased commits, which requires a name and e-mail address
      • The current user has write access to the "from" ref's repository
        • Note that in order to view a pull request a user is only required to have read access to the toRef's repository, so just because a user can see a pull request does not mean they can request a rebase
      This list is not exhaustive, and the exact set of preconditions applied can be extended by third-party add-ons by implementing PreRepositoryHooks and handling GitRebaseHookRequests.
      Parameters:
      pullRequest - the pull request to check
      Returns:
      the result of the rebase checks
    • rebase

      @Nonnull Optional<com.atlassian.bitbucket.repository.RefChange> rebase(@Nonnull PullRequestRebaseRequest request)
      Rebases a pull request, updating the "from" ref with new commits starting from the "to" ref.

      Rebasing a pull request requires read access to the "to" ref's repository, and write access to the "from" ref's repository.

      This operation checks branch permissions for the "from" ref. If the ref has been marked read only, or has restrictions preventing changes without a pull request or rewriting history have been applied, the rebase will be rejected and the ref will not be updated. Third-party add-ons can enforce additional checks by implementing PreRepositoryHooks and handling GitRebaseHookRequests.

      This operation may discard one or more commits from the "from" ref if matching changes are already present on the "to" ref, but it may not discard all of the incoming commits. At least one unique commit must remain on the "from" ref or the rebase will fail. This means a pull request cannot be automatically closed as a byproduct of rebasing it.

      After a pull request is successfully rebased, the refs in the database are updated asynchronously, so the new commits may not be immediately visible.

      Parameters:
      request - a request describing the pull request to rebase
      Returns:
      a RefChange describing how the pull request's "from" ref was updated, which may be empty() if the "from" ref is already up-to-date with all commits on the "to" ref
      Throws:
      com.atlassian.bitbucket.repository.RepositoryArchivedException - if target repository is archived