1
- import { RepositoryAccessLevel } from '../../../../git/models/issue' ;
1
+ import type { IssueRepository } from '../../../../git/models/issue' ;
2
+ import { Issue , RepositoryAccessLevel } from '../../../../git/models/issue' ;
2
3
import type { IssueOrPullRequestState } from '../../../../git/models/issueOrPullRequest' ;
3
4
import type { PullRequestMember , PullRequestReviewer } from '../../../../git/models/pullRequest' ;
4
5
import { PullRequest , PullRequestReviewDecision , PullRequestReviewState } from '../../../../git/models/pullRequest' ;
@@ -199,6 +200,12 @@ export interface BitbucketIssue {
199
200
created_on : string ;
200
201
updated_on : string ;
201
202
repository : BitbucketRepository ;
203
+ votes ?: number ;
204
+ content : {
205
+ raw : string ;
206
+ markup : string ;
207
+ html : string ;
208
+ } ;
202
209
links : {
203
210
self : BitbucketLink ;
204
211
html : BitbucketLink ;
@@ -243,6 +250,10 @@ export function isClosedBitbucketPullRequestState(state: BitbucketPullRequestSta
243
250
return bitbucketPullRequestStateToState ( state ) !== 'opened' ;
244
251
}
245
252
253
+ export function isClosedBitbucketIssueState ( state : BitbucketIssueState ) : boolean {
254
+ return bitbucketIssueStateToState ( state ) !== 'opened' ;
255
+ }
256
+
246
257
export function fromBitbucketUser ( user : BitbucketUser ) : PullRequestMember {
247
258
return {
248
259
avatarUrl : user . links . avatar . href ,
@@ -298,6 +309,46 @@ function getBitbucketReviewDecision(pr: BitbucketPullRequest): PullRequestReview
298
309
return PullRequestReviewDecision . ReviewRequired ; // nobody has reviewed yet.
299
310
}
300
311
312
+ function fromBitbucketRepository ( repo : BitbucketRepository ) : IssueRepository {
313
+ return {
314
+ owner : repo . full_name . split ( '/' ) [ 0 ] ,
315
+ repo : repo . name ,
316
+ id : repo . uuid ,
317
+ // TODO: Remove this assumption once actual access level is available
318
+ accessLevel : RepositoryAccessLevel . Write ,
319
+ } ;
320
+ }
321
+
322
+ export function fromBitbucketIssue ( issue : BitbucketIssue , provider : Provider ) : Issue {
323
+ return new Issue (
324
+ provider ,
325
+ issue . id . toString ( ) ,
326
+ issue . id . toString ( ) ,
327
+ issue . title ,
328
+ issue . links . html . href ,
329
+ new Date ( issue . created_on ) ,
330
+ new Date ( issue . updated_on ) ,
331
+ isClosedBitbucketIssueState ( issue . state ) ,
332
+ bitbucketIssueStateToState ( issue . state ) ,
333
+ fromBitbucketUser ( issue . reporter ) ,
334
+ issue . assignee ? [ fromBitbucketUser ( issue . assignee ) ] : [ ] ,
335
+ fromBitbucketRepository ( issue . repository ) ,
336
+ undefined , // closedDate
337
+ undefined , // labels
338
+ undefined , // commentsCount
339
+ issue . votes , // thumbsUpCount
340
+ issue . content . html , // body
341
+ ! issue . repository ?. project
342
+ ? undefined
343
+ : {
344
+ id : issue . repository . project . uuid ,
345
+ name : issue . repository . project . name ,
346
+ resourceId : issue . repository . project . uuid ,
347
+ resourceName : issue . repository . project . name ,
348
+ } ,
349
+ ) ;
350
+ }
351
+
301
352
export function fromBitbucketPullRequest ( pr : BitbucketPullRequest , provider : Provider ) : PullRequest {
302
353
return new PullRequest (
303
354
provider ,
@@ -306,13 +357,7 @@ export function fromBitbucketPullRequest(pr: BitbucketPullRequest, provider: Pro
306
357
pr . id . toString ( ) ,
307
358
pr . title ,
308
359
pr . links . html . href ,
309
- {
310
- owner : pr . destination . repository . full_name . split ( '/' ) [ 0 ] ,
311
- repo : pr . destination . repository . name ,
312
- id : pr . destination . repository . uuid ,
313
- // TODO: Remove this assumption once actual access level is available
314
- accessLevel : RepositoryAccessLevel . Write ,
315
- } ,
360
+ fromBitbucketRepository ( pr . destination . repository ) ,
316
361
bitbucketPullRequestStateToState ( pr . state ) ,
317
362
new Date ( pr . created_on ) ,
318
363
new Date ( pr . updated_on ) ,
0 commit comments