core-gitlens: add a single pull request read for Azure DevOps, Bitbucket Cloud and Bitbucket Server
Problem
Integration.getPullRequest(resource, id) returns undefined for Azure DevOps, Bitbucket Cloud and Bitbucket Server. The base method calls the optional getProviderPullRequest, and only GitHub, GitHub Enterprise, GitLab and GitLab self-hosted implement it. A consumer that needs one pull request by its URL or id has no direct read for these providers and has to scan a paginated list instead.
A list scan is bounded, so on an account with many open pull requests it can end before it reaches the wanted one. The consumer then cannot tell a missing pull request from an incomplete scan, and a pull request merged since it was last read can keep showing as open.
Issues do not have this gap: every provider implements getProviderIssue.
Evidence
Verified in @gitkraken/core-gitlens 0.7.0 (dist/plus/integrations):
models/integration.js:getPullRequestcallsthis.getProviderPullRequest?.(...), so a provider without the method resolvesundefinedwith no error.providers/github.jsandproviders/gitlab.jsimplementgetProviderPullRequestandgetProviderPullRequestIdentityFromMaybeUrl. The Enterprise and self-hosted classes inherit them.providers/azureDevOps.jsandproviders/bitbucket.jsimplement onlygetProviderPullRequestForBranch,getProviderPullRequestForCommitandgetProviderPullRequestIdentity.providers/bitbucket-server.jsimplements onlygetProviderPullRequestForBranchandgetProviderPullRequestForCommit.
Scope
- Implement
getProviderPullRequestfor Azure DevOps, Bitbucket Cloud and Bitbucket Server. The returnedPullRequestcarries its state, including merged, and its merged and closed dates. - Implement
getProviderPullRequestIdentityFromMaybeUrlfor the same providers, so a consumer can go from a pasted URL to the id the read takes. - For Azure DevOps, take the id from the URL. Azure pull requests have been seen in list results with
number: 0, so a number taken from a list is not a reliable key.
Related
- #5875 — Bitbucket Data Center PR search and counts. A different surface, not a duplicate.
- #5876 — Azure DevOps Server PR and work-item search and counts. A different surface, not a duplicate.
Source: gitkraken/vscode-gitlens