Interface AutoMergeService
public interface AutoMergeService
- Since:
- 8.15
-
Method Summary
Modifier and TypeMethodDescriptioncancelAutoMerge
(int repositoryId, long pullRequestId, AutoMergeCancelledReason cancelledReason) Cancels the automatic merging of the pull request by the system with a provided reason, and logs the cancellation as apull request activity
.getAutoMergeRequest
(PullRequest pullRequest) Finds anauto-merge request
for the given pull request.boolean
isSettingEnabledForPullRequest
(PullRequest pullRequest) submitAutoMergeRequest
(PullRequestMergeRequest pullRequestMergeRequest) Creates an auto-merge request for the provided pull request with all the parameters from the provided merge request, if all the following conditions are met: thesetting
is enabled for the repository that the pull request targets auto-merge is not already requested for this pull request there are no merge conflicts on the pull request the pull requestcannot be merged
immediatelytryAutoMerge
(int repositoryId, long pullRequestId) Requests the system to try auto-merging a pull request.
-
Method Details
-
cancelAutoMerge
@Nonnull PullRequest cancelAutoMerge(int repositoryId, long pullRequestId, @Nonnull AutoMergeCancelledReason cancelledReason) Cancels the automatic merging of the pull request by the system with a provided reason, and logs the cancellation as apull request activity
. If a pull request was set to auto-merge, and it has not been merged yet, invoking this method will ensure that the system does not try to merge this pull request, and it has to be merged manually. If the pull request is not set to auto-merge this method is a no-op.- Parameters:
repositoryId
- the ID of the repository to which the pull request is supposed to mergepullRequestId
- the ID of the pull request within the repositorycancelledReason
- the reason the auto-merge request has been cancelled- Returns:
- The pull request for which the cancellation of auto-merge is requested
- Throws:
NoSuchPullRequestException
- if the pull request is not foundIllegalPullRequestStateException
- if the pull request is currentlylocked
for some other operation.
-
getAutoMergeRequest
Finds anauto-merge request
for the given pull request.- Parameters:
pullRequest
- the pull request for which auto-merge request has to be fetched- Returns:
- an
Optional
containing auto-merge request for the pull request, if one exists, otherwiseOptional.empty()
-
isSettingEnabledForPullRequest
- Parameters:
pullRequest
- the pull request to check if its target repository has auto-merge settings enabled- Returns:
true
if auto-merge is enabled for the repository containing the pull request; otherwise,false
if it is disabled- Since:
- 8.15
-
submitAutoMergeRequest
@Nonnull PullRequest submitAutoMergeRequest(@Nonnull PullRequestMergeRequest pullRequestMergeRequest) Creates an auto-merge request for the provided pull request with all the parameters from the provided merge request, if all the following conditions are met:- the
setting
is enabled for the repository that the pull request targets - auto-merge is not already requested for this pull request
- there are no merge conflicts on the pull request
- the pull request
cannot be merged
immediately
If the auto-merge request is submitted successfully, the system will merge this pull request on behalf of the user that requested auto-merge once the pull request is
ready to merge
. If the pull request is already mergeable, it will be merged immediately.- Parameters:
pullRequestMergeRequest
- the parameters to be used to auto-merge the pull request when it is ready to merge- Returns:
- the updated pull request
- Throws:
AutoMergeSettingNotEnabledException
- if the auto-merge setting is not enabled for this repositoryIllegalPullRequestStateException
- if the pull request has merge conflict(s)
- the
-
tryAutoMerge
Requests the system to try auto-merging a pull request. A merge will be attempted if the following conditions are met:- There is a valid auto-merge request associated with the provided pull request. If the request is
invalid, e.g. because changes have been made to the
source branch
or the auto-merge request has expired, then the request is cancelled. - The pull request
can be merged
. If the pull request cannot be merged, e.g. because it islocked
due to rescoping orhas conflicts with the target branch
, then the request is cancelled.
If both conditions are met, then the merge will be attempted.
- Parameters:
repositoryId
- the ID of the repository to which the pull request is supposed to mergepullRequestId
- the ID of the pull request within the repository- Returns:
- the result of auto-merge processing
- Throws:
AutoMergeNotRequestedException
- if no auto-merge request is found for the specified pull requestAutoMergeSettingNotEnabledException
- if the auto-merge setting is not enabled for this repositoryNoSuchPullRequestException
- if the pull request is not foundPullRequestMergeVetoedException
- if the pull request was vetoed while merging but not duringdry run
- There is a valid auto-merge request associated with the provided pull request. If the request is
invalid, e.g. because changes have been made to the
-