@@ -7,12 +7,12 @@ import type { Issue, IssueShape } from '../../../git/models/issue';
77import type { IssueOrPullRequest , IssueOrPullRequestType } from '../../../git/models/issueOrPullRequest' ;
88import type { PullRequest , PullRequestMergeMethod , PullRequestState } from '../../../git/models/pullRequest' ;
99import type { RepositoryMetadata } from '../../../git/models/repositoryMetadata' ;
10+ import { getSettledValue } from '../../../system/promise' ;
1011import type { IntegrationAuthenticationProviderDescriptor } from '../authentication/integrationAuthenticationProvider' ;
1112import type { ProviderAuthenticationSession } from '../authentication/models' ;
1213import type { ResourceDescriptor } from '../integration' ;
1314import { HostingIntegration } from '../integration' ;
14- import type { ProviderPullRequest } from './models' ;
15- import { fromProviderPullRequest , providersMetadata } from './models' ;
15+ import { providersMetadata } from './models' ;
1616
1717const metadata = providersMetadata [ HostingIntegrationId . Bitbucket ] ;
1818const authProvider = Object . freeze ( { id : metadata . id , scopes : metadata . scopes } ) ;
@@ -263,7 +263,6 @@ export class BitbucketIntegration extends HostingIntegration<
263263 session : ProviderAuthenticationSession ,
264264 requestedRepositories ?: BitbucketRepositoryDescriptor [ ] ,
265265 ) : Promise < PullRequest [ ] | undefined > {
266- const api = await this . getProvidersApi ( ) ;
267266 if ( requestedRepositories != null ) {
268267 // TODO: implement repos version
269268 return undefined ;
@@ -278,14 +277,24 @@ export class BitbucketIntegration extends HostingIntegration<
278277 const repos = await this . getProviderProjectsForResources ( session , workspaces ) ;
279278 if ( repos == null || repos . length === 0 ) return undefined ;
280279
281- const prs = await api . getPullRequestsForRepos (
282- HostingIntegrationId . Bitbucket ,
283- repos . map ( repo => ( { namespace : repo . owner , name : repo . name } ) ) ,
284- {
285- accessToken : session . accessToken ,
286- } ,
280+ const api = await this . container . bitbucket ;
281+ if ( ! api ) return undefined ;
282+ const prsResult = await Promise . allSettled (
283+ repos . map ( repo =>
284+ api . getUsersPullRequestsForRepo (
285+ this ,
286+ session . accessToken ,
287+ user . id ,
288+ repo . owner ,
289+ repo . name ,
290+ this . apiBaseUrl ,
291+ ) ,
292+ ) ,
287293 ) ;
288- return prs . values . map ( pr => this . fromBitbucketProviderPullRequest ( pr ) ) ;
294+ return prsResult
295+ . map ( r => getSettledValue ( r ) )
296+ . filter ( r => r != null )
297+ . flat ( ) ;
289298 }
290299
291300 protected override async searchProviderMyIssues (
@@ -295,14 +304,6 @@ export class BitbucketIntegration extends HostingIntegration<
295304 return Promise . resolve ( undefined ) ;
296305 }
297306
298- private fromBitbucketProviderPullRequest (
299- remotePullRequest : ProviderPullRequest ,
300- // repoDescriptors: BitbucketRemoteRepositoryDescriptor[],
301- ) : PullRequest {
302- remotePullRequest . graphQLId = remotePullRequest . id ;
303- return fromProviderPullRequest ( remotePullRequest , this ) ;
304- }
305-
306307 protected override async providerOnConnect ( ) : Promise < void > {
307308 if ( this . _session == null ) return ;
308309
0 commit comments