@@ -7,6 +7,7 @@ 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 { HostingIntegration } from '../integration' ;
@@ -15,8 +16,7 @@ import type {
15
16
BitbucketRepositoryDescriptor ,
16
17
BitbucketWorkspaceDescriptor ,
17
18
} from './bitbucket/models' ;
18
- import type { ProviderPullRequest } from './models' ;
19
- import { fromProviderPullRequest , providersMetadata } from './models' ;
19
+ import { providersMetadata } from './models' ;
20
20
21
21
const metadata = providersMetadata [ HostingIntegrationId . Bitbucket ] ;
22
22
const authProvider = Object . freeze ( { id : metadata . id , scopes : metadata . scopes } ) ;
@@ -246,7 +246,6 @@ export class BitbucketIntegration extends HostingIntegration<
246
246
session : ProviderAuthenticationSession ,
247
247
repos ?: BitbucketRepositoryDescriptor [ ] ,
248
248
) : Promise < PullRequest [ ] | undefined > {
249
- const api = await this . getProvidersApi ( ) ;
250
249
if ( repos != null ) {
251
250
// TODO: implement repos version
252
251
return undefined ;
@@ -261,14 +260,24 @@ export class BitbucketIntegration extends HostingIntegration<
261
260
const allBitbucketRepos = await this . getProviderProjectsForResources ( session , workspaces ) ;
262
261
if ( allBitbucketRepos == null || allBitbucketRepos . length === 0 ) return undefined ;
263
262
264
- const prs = await api . getPullRequestsForRepos (
265
- HostingIntegrationId . Bitbucket ,
266
- allBitbucketRepos . map ( repo => ( { namespace : repo . owner , name : repo . name } ) ) ,
267
- {
268
- accessToken : session . accessToken ,
269
- } ,
263
+ const api = await this . container . bitbucket ;
264
+ if ( ! api ) return undefined ;
265
+ const prsResult = await Promise . allSettled (
266
+ allBitbucketRepos . map ( repo =>
267
+ api . getUsersPullRequestsForRepo (
268
+ this ,
269
+ session . accessToken ,
270
+ user . id ,
271
+ repo . owner ,
272
+ repo . name ,
273
+ this . apiBaseUrl ,
274
+ ) ,
275
+ ) ,
270
276
) ;
271
- return prs . values . map ( pr => this . fromBitbucketProviderPullRequest ( pr ) ) ;
277
+ return prsResult
278
+ . map ( r => getSettledValue ( r ) )
279
+ . filter ( r => r != null )
280
+ . flat ( ) ;
272
281
}
273
282
274
283
protected override async searchProviderMyIssues (
@@ -278,14 +287,6 @@ export class BitbucketIntegration extends HostingIntegration<
278
287
return Promise . resolve ( undefined ) ;
279
288
}
280
289
281
- private fromBitbucketProviderPullRequest (
282
- remotePullRequest : ProviderPullRequest ,
283
- // repoDescriptors: BitbucketRemoteRepositoryDescriptor[],
284
- ) : PullRequest {
285
- remotePullRequest . graphQLId = remotePullRequest . id ;
286
- return fromProviderPullRequest ( remotePullRequest , this ) ;
287
- }
288
-
289
290
protected override async providerOnConnect ( ) : Promise < void > {
290
291
if ( this . _session == null ) return ;
291
292
0 commit comments