File tree Expand file tree Collapse file tree 3 files changed +47
-6
lines changed
src/plus/integrations/providers Expand file tree Collapse file tree 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<
9696 id : string ,
9797 type : undefined | IssueOrPullRequestType ,
9898 ) : Promise < IssueOrPullRequest | undefined > {
99- if ( type !== 'pullrequest ') {
99+ if ( type === 'issue ') {
100100 return undefined ;
101101 }
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 (
103107 this ,
104108 accessToken ,
105109 repo . owner ,
106110 repo . name ,
107111 id ,
108112 this . apiBaseUrl ,
109- {
110- type : 'pullrequest' ,
111- } ,
113+ integration ,
112114 ) ;
113115 }
114116
Original file line number Diff line number Diff line change @@ -185,7 +185,7 @@ export const normalizeBitbucketServerPullRequest = (pr: BitbucketServerPullReque
185185 name : pr . fromRef . displayId ,
186186 oid : pr . fromRef . latestCommit ,
187187 } ,
188- commentCount : pr . properties . commentCount ,
188+ commentCount : pr . properties ? .commentCount ,
189189 upvoteCount : null ,
190190 commitCount : null ,
191191 fileCount : null ,
Original file line number Diff line number Diff line change @@ -275,6 +275,45 @@ export class BitbucketApi implements Disposable {
275275 return undefined ;
276276 }
277277
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+
278317 @debug < BitbucketApi [ 'getRepositoriesForWorkspace' ] > ( { args : { 0 : p => p . name , 1 : '<token>' } } )
279318 async getRepositoriesForWorkspace (
280319 provider : Provider ,
You can’t perform that action at this time.
0 commit comments