@@ -13,10 +13,12 @@ import {
1313 RequestClientError ,
1414 RequestNotFoundError ,
1515} from '../../../../errors' ;
16+ import type { IssueOrPullRequest } from '../../../../git/models/issueOrPullRequest' ;
1617import type { PullRequest } from '../../../../git/models/pullRequest' ;
1718import type { Provider } from '../../../../git/models/remoteProvider' ;
1819import { showIntegrationRequestFailed500WarningMessage } from '../../../../messages' ;
1920import { configuration } from '../../../../system/-webview/configuration' ;
21+ import { debug } from '../../../../system/decorators/log' ;
2022import { Logger } from '../../../../system/logger' ;
2123import type { LogScope } from '../../../../system/logger.scope' ;
2224import { getLogScope } from '../../../../system/logger.scope' ;
@@ -56,6 +58,7 @@ export class BitbucketApi implements Disposable {
5658 this . _proxyAgent = null ;
5759 }
5860
61+ @debug < BitbucketApi [ 'getPullRequestForBranch' ] > ( { args : { 0 : p => p . name , 1 : '<token>' } } )
5962 public async getPullRequestForBranch (
6063 provider : Provider ,
6164 token : string ,
@@ -90,6 +93,36 @@ export class BitbucketApi implements Disposable {
9093 return fromBitbucketPullRequest ( response . values [ 0 ] , provider ) ;
9194 }
9295
96+ @debug < BitbucketApi [ 'getIssueOrPullRequest' ] > ( { args : { 0 : p => p . name , 1 : '<token>' } } )
97+ public async getIssueOrPullRequest (
98+ provider : Provider ,
99+ token : string ,
100+ owner : string ,
101+ repo : string ,
102+ id : string ,
103+ options : {
104+ baseUrl : string ;
105+ } ,
106+ ) : Promise < IssueOrPullRequest | undefined > {
107+ const scope = getLogScope ( ) ;
108+
109+ const response = await this . request < BitbucketPullRequest > (
110+ provider ,
111+ token ,
112+ options . baseUrl ,
113+ `repositories/${ owner } /${ repo } /pullrequests/${ id } ?fields=*` ,
114+ {
115+ method : 'GET' ,
116+ } ,
117+ scope ,
118+ ) ;
119+
120+ if ( ! response ) {
121+ return undefined ;
122+ }
123+ return fromBitbucketPullRequest ( response , provider ) ;
124+ }
125+
93126 private async request < T > (
94127 provider : Provider ,
95128 token : string ,
0 commit comments