File tree 3 files changed +47
-6
lines changed
src/plus/integrations/providers
3 files changed +47
-6
lines changed Original file line number Diff line number Diff line change @@ -96,19 +96,21 @@ export class BitbucketServerIntegration extends HostingIntegration<
96
96
id : string ,
97
97
type : undefined | IssueOrPullRequestType ,
98
98
) : Promise < IssueOrPullRequest | undefined > {
99
- if ( type !== 'pullrequest ') {
99
+ if ( type === 'issue ') {
100
100
return undefined ;
101
101
}
102
- return ( await this . container . bitbucket ) ?. getIssueOrPullRequest (
102
+ const integration = await this . container . integrations . get ( this . id ) ;
103
+ if ( ! integration ) {
104
+ return undefined ;
105
+ }
106
+ return ( await this . container . bitbucket ) ?. getServerPullRequestById (
103
107
this ,
104
108
accessToken ,
105
109
repo . owner ,
106
110
repo . name ,
107
111
id ,
108
112
this . apiBaseUrl ,
109
- {
110
- type : 'pullrequest' ,
111
- } ,
113
+ integration ,
112
114
) ;
113
115
}
114
116
Original file line number Diff line number Diff line change @@ -185,7 +185,7 @@ export const normalizeBitbucketServerPullRequest = (pr: BitbucketServerPullReque
185
185
name : pr . fromRef . displayId ,
186
186
oid : pr . fromRef . latestCommit ,
187
187
} ,
188
- commentCount : pr . properties . commentCount ,
188
+ commentCount : pr . properties ? .commentCount ,
189
189
upvoteCount : null ,
190
190
commitCount : null ,
191
191
fileCount : null ,
Original file line number Diff line number Diff line change @@ -275,6 +275,45 @@ export class BitbucketApi implements Disposable {
275
275
return undefined ;
276
276
}
277
277
278
+ @debug < BitbucketApi [ 'getServerPullRequestById' ] > ( { args : { 0 : p => p . name , 1 : '<token>' } } )
279
+ public async getServerPullRequestById (
280
+ provider : Provider ,
281
+ token : string ,
282
+ owner : string ,
283
+ repo : string ,
284
+ id : string ,
285
+ baseUrl : string ,
286
+ integration : Integration ,
287
+ ) : Promise < IssueOrPullRequest | undefined > {
288
+ const scope = getLogScope ( ) ;
289
+
290
+ try {
291
+ const prResponse = await this . request < BitbucketServerPullRequest > (
292
+ provider ,
293
+ token ,
294
+ baseUrl ,
295
+ `projects/${ owner } /repos/${ repo } /pull-requests/${ id } ` ,
296
+ {
297
+ method : 'GET' ,
298
+ } ,
299
+ scope ,
300
+ ) ;
301
+
302
+ if ( prResponse ) {
303
+ const providersPr = normalizeBitbucketServerPullRequest ( prResponse ) ;
304
+ const gitlensPr = fromProviderPullRequest ( providersPr , integration ) ;
305
+ return gitlensPr ;
306
+ }
307
+ } catch ( ex ) {
308
+ if ( ex . original ?. status !== 404 ) {
309
+ Logger . error ( ex , scope ) ;
310
+ return undefined ;
311
+ }
312
+ }
313
+
314
+ return undefined ;
315
+ }
316
+
278
317
@debug < BitbucketApi [ 'getRepositoriesForWorkspace' ] > ( { args : { 0 : p => p . name , 1 : '<token>' } } )
279
318
async getRepositoriesForWorkspace (
280
319
provider : Provider ,
You can’t perform that action at this time.
0 commit comments