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 {
@@ -196,6 +197,12 @@ export interface BitbucketIssue {
196
197
created_on : string ;
197
198
updated_on : string ;
198
199
repository : BitbucketRepository ;
200
+ votes ?: number ;
201
+ content : {
202
+ raw : string ;
203
+ markup : string ;
204
+ html : string ;
205
+ } ;
199
206
links : {
200
207
self : BitbucketLink ;
201
208
html : BitbucketLink ;
@@ -240,6 +247,10 @@ export function isClosedBitbucketPullRequestState(state: BitbucketPullRequestSta
240
247
return bitbucketPullRequestStateToState ( state ) !== 'opened' ;
241
248
}
242
249
250
+ export function isClosedBitbucketIssueState ( state : BitbucketIssueState ) : boolean {
251
+ return bitbucketIssueStateToState ( state ) !== 'opened' ;
252
+ }
253
+
243
254
export function fromBitbucketUser ( user : BitbucketUser ) : PullRequestMember {
244
255
return {
245
256
avatarUrl : user . links . avatar . href ,
@@ -295,6 +306,46 @@ function getBitbucketReviewDecision(pr: BitbucketPullRequest): PullRequestReview
295
306
return PullRequestReviewDecision . ReviewRequired ; // nobody has reviewed yet.
296
307
}
297
308
309
+ function fromBitbucketRepository ( repo : BitbucketRepository ) : IssueRepository {
310
+ return {
311
+ owner : repo . full_name . split ( '/' ) [ 0 ] ,
312
+ repo : repo . name ,
313
+ id : repo . uuid ,
314
+ // TODO: Remove this assumption once actual access level is available
315
+ accessLevel : RepositoryAccessLevel . Write ,
316
+ } ;
317
+ }
318
+
319
+ export function fromBitbucketIssue ( issue : BitbucketIssue , provider : Provider ) : Issue {
320
+ return new Issue (
321
+ provider ,
322
+ issue . id . toString ( ) ,
323
+ issue . id . toString ( ) ,
324
+ issue . title ,
325
+ issue . links . html . href ,
326
+ new Date ( issue . created_on ) ,
327
+ new Date ( issue . updated_on ) ,
328
+ isClosedBitbucketIssueState ( issue . state ) ,
329
+ bitbucketIssueStateToState ( issue . state ) ,
330
+ fromBitbucketUser ( issue . reporter ) ,
331
+ issue . assignee ? [ fromBitbucketUser ( issue . assignee ) ] : [ ] ,
332
+ fromBitbucketRepository ( issue . repository ) ,
333
+ undefined , // closedDate
334
+ undefined , // labels
335
+ undefined , // commentsCount
336
+ issue . votes , // thumbsUpCount
337
+ issue . content . html , // body
338
+ ! issue . repository ?. project
339
+ ? undefined
340
+ : {
341
+ id : issue . repository . project . uuid ,
342
+ name : issue . repository . project . name ,
343
+ resourceId : issue . repository . project . uuid ,
344
+ resourceName : issue . repository . project . name ,
345
+ } ,
346
+ ) ;
347
+ }
348
+
298
349
export function fromBitbucketPullRequest ( pr : BitbucketPullRequest , provider : Provider ) : PullRequest {
299
350
return new PullRequest (
300
351
provider ,
@@ -303,13 +354,7 @@ export function fromBitbucketPullRequest(pr: BitbucketPullRequest, provider: Pro
303
354
pr . id . toString ( ) ,
304
355
pr . title ,
305
356
pr . links . html . href ,
306
- {
307
- owner : pr . destination . repository . full_name . split ( '/' ) [ 0 ] ,
308
- repo : pr . destination . repository . name ,
309
- id : pr . destination . repository . uuid ,
310
- // TODO: Remove this assumption once actual access level is available
311
- accessLevel : RepositoryAccessLevel . Write ,
312
- } ,
357
+ fromBitbucketRepository ( pr . destination . repository ) ,
313
358
bitbucketPullRequestStateToState ( pr . state ) ,
314
359
new Date ( pr . created_on ) ,
315
360
new Date ( pr . updated_on ) ,
0 commit comments