Class BitbucketServerPullRequestHandler


  • public class BitbucketServerPullRequestHandler
    extends Object
    • Constructor Detail

      • BitbucketServerPullRequestHandler

        public BitbucketServerPullRequestHandler​(@NotNull
                                                 @NotNull com.atlassian.stash.rest.client.api.StashClient stashClient,
                                                 @NotNull
                                                 @NotNull VcsRepositoryData vcsRepositoryData)
    • Method Detail

      • getOpenPullRequests

        @NotNull
        public @NotNull com.atlassian.stash.rest.client.api.entity.Page<com.atlassian.stash.rest.client.api.entity.PullRequestStatus> getOpenPullRequests​(@Nullable
                                                                                                                                                          @Nullable String branchName,
                                                                                                                                                          long start,
                                                                                                                                                          long limit,
                                                                                                                                                          long avatarSize)
        Retrieves open pull requests. Pull requests URLs are based on the application link 'Display URL'.

        Note (as of BBS 4.10-4.12 at least) this method will return only cached values of pull request merge outcome, if no cached value is found the PullRequestStatus.getMergeOutcome() will be empty. Consider using canMergePullRequest(long) to trigger actual checks when necessary.

        trigger calculation of pull request mergeability state if no current mergeability status is cached, what is not the case re getOpenPullRequests(String, long, long, long).

        Parameters:
        branchName - if empty, branch is taken from repository definition
        start - index of the first result to retrieve (for paging)
        limit - total number of results to retrieve after start (for Paging)
        avatarSize - desired avatar size
        Returns:
        page of open pull requests
      • getCreatePullRequestUrl

        @Nullable
        public @Nullable String getCreatePullRequestUrl​(@Nullable
                                                        @Nullable String branchName)
        Retrieves pull request creation URL. It is based on the application link 'Display URL'.
        Parameters:
        branchName - if empty, branch is taken from repository definition
        Returns:
        pull request creation URL
      • mergePullRequest

        @NotNull
        public @NotNull com.atlassian.stash.rest.client.api.entity.PullRequestStatus mergePullRequest​(long pullRequestId,
                                                                                                      long version)
        Merges given pull request.
        Parameters:
        pullRequestId - pull request id, assigned by BBS
        version - version version of pull request data user had seen when deciding to merge it. BBS would reject merge attempt if data changed in the meantime, forcing user to refresh the view
        Returns:
        merged pull request
      • canMergePullRequest

        @NotNull
        public @NotNull com.atlassian.stash.rest.client.api.entity.PullRequestMergeability canMergePullRequest​(long pullRequestId)
        Retrieves given pull request mergeability state.

        Note (as of BBS 4.10-4.12 at least) this method will trigger calculation of pull request mergeability state if no current mergeability status is cached, what is not the case re getOpenPullRequests(String, long, long, long).

        Parameters:
        pullRequestId - pull request id, assigned by BBS
        Returns:
        mergeability status of pull request