@@ -7,12 +7,12 @@ import type { Issue, IssueShape } from '../../../git/models/issue';
7
7
import type { IssueOrPullRequest , IssueOrPullRequestType } from '../../../git/models/issueOrPullRequest' ;
8
8
import type { PullRequest , PullRequestMergeMethod , PullRequestState } from '../../../git/models/pullRequest' ;
9
9
import type { RepositoryMetadata } from '../../../git/models/repositoryMetadata' ;
10
+ import { getSettledValue } from '../../../system/promise' ;
10
11
import type { IntegrationAuthenticationProviderDescriptor } from '../authentication/integrationAuthenticationProvider' ;
11
12
import type { ProviderAuthenticationSession } from '../authentication/models' ;
12
13
import type { ResourceDescriptor } from '../integration' ;
13
14
import { HostingIntegration } from '../integration' ;
14
- import type { ProviderPullRequest } from './models' ;
15
- import { fromProviderPullRequest , providersMetadata } from './models' ;
15
+ import { providersMetadata } from './models' ;
16
16
17
17
const metadata = providersMetadata [ HostingIntegrationId . Bitbucket ] ;
18
18
const authProvider = Object . freeze ( { id : metadata . id , scopes : metadata . scopes } ) ;
@@ -263,7 +263,6 @@ export class BitbucketIntegration extends HostingIntegration<
263
263
session : ProviderAuthenticationSession ,
264
264
requestedRepositories ?: BitbucketRepositoryDescriptor [ ] ,
265
265
) : Promise < PullRequest [ ] | undefined > {
266
- const api = await this . getProvidersApi ( ) ;
267
266
if ( requestedRepositories != null ) {
268
267
// TODO: implement repos version
269
268
return undefined ;
@@ -278,14 +277,24 @@ export class BitbucketIntegration extends HostingIntegration<
278
277
const repos = await this . getProviderProjectsForResources ( session , workspaces ) ;
279
278
if ( repos == null || repos . length === 0 ) return undefined ;
280
279
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
+ ) ,
287
293
) ;
288
- return prs . values . map ( pr => this . fromBitbucketProviderPullRequest ( pr ) ) ;
294
+ return prsResult
295
+ . map ( r => getSettledValue ( r ) )
296
+ . filter ( r => r != null )
297
+ . flat ( ) ;
289
298
}
290
299
291
300
protected override async searchProviderMyIssues (
@@ -295,14 +304,6 @@ export class BitbucketIntegration extends HostingIntegration<
295
304
return Promise . resolve ( undefined ) ;
296
305
}
297
306
298
- private fromBitbucketProviderPullRequest (
299
- remotePullRequest : ProviderPullRequest ,
300
- // repoDescriptors: BitbucketRemoteRepositoryDescriptor[],
301
- ) : PullRequest {
302
- remotePullRequest . graphQLId = remotePullRequest . id ;
303
- return fromProviderPullRequest ( remotePullRequest , this ) ;
304
- }
305
-
306
307
protected override async providerOnConnect ( ) : Promise < void > {
307
308
if ( this . _session == null ) return ;
308
309
0 commit comments