Interface GitPullRequestService
PullRequestService specific to working with pull requests between Git
repositories.- Since:
- 5.5
-
Method Summary
Modifier and TypeMethodDescriptioncanRebase(com.atlassian.bitbucket.pull.PullRequest pullRequest) Checks preconditions to determine whether the specifiedpull requestcan be rebased.Optional<com.atlassian.bitbucket.repository.RefChange>rebase(PullRequestRebaseRequest request) Rebases apull request, updating the"from" refwith 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 specifiedpull requestcan 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" refis 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
- In other words, the qualified ID for the "from" ref must start with
- The current user has an e-mail address
- Pull requests cannot be rebased anonymously
git rebaserecords 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
- Note that in order to view a pull request a user is only required to have read
access to the
PreRepositoryHooks and handlingGitRebaseHookRequests.- 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 apull request, updating the"from" refwith new commits starting from the"to" ref.Rebasing a pull request requires
readaccess to the"to" ref's repository, andwriteaccess 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 handlingGitRebaseHookRequests.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
RefChangedescribing how the pull request's "from" ref was updated, which may beempty()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
-