• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

moosetechnology / GitProjectHealth / 14221025916

02 Apr 2025 01:36PM UTC coverage: 72.583% (+0.2%) from 72.341%
14221025916

Pull #180

github

web-flow
Merge ae118d5e3 into 9e642ecfa
Pull Request #180: add import projects to bitbucket

85 of 98 new or added lines in 4 files covered. (86.73%)

5 existing lines in 1 file now uncovered.

15461 of 21301 relevant lines covered (72.58%)

0.73 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.0
/src/BitBucketHealth-Model-Importer/BitBucketModelImporter.class.st
1
Class {
2
        #name : #BitBucketModelImporter,
3
        #superclass : #GitModelImporter,
4
        #instVars : [
5
                'withInitialCommits'
6
        ],
7
        #category : #'BitBucketHealth-Model-Importer'
8
}
9

10
{ #category : #accessing }
11
BitBucketModelImporter >> bitBucketApi [
×
12

×
13
        self
×
14
                deprecated: 'Use #repoApi instead'
×
15
                on: '7 October 2024'
×
16
                in:
×
17
                'Pharo-11.0.0+build.726.sha.aece1b5473acf3830a0e082c1bc3a15d4ff3522b (64 Bit)'.
×
18

×
19
        ^ repoApi
×
20
]
×
21

22
{ #category : #accessing }
23
BitBucketModelImporter >> bitBucketApi: anObject [
1✔
24

1✔
25
        self
1✔
26
                deprecated: 'Use #repoApi: instead'
1✔
27
                on: '7 October 2024'
1✔
28
                in:
1✔
29
                'Pharo-11.0.0+build.726.sha.aece1b5473acf3830a0e082c1bc3a15d4ff3522b (64 Bit)'.
1✔
30

1✔
31
        repoApi := anObject
1✔
32
]
1✔
33

34
{ #category : #'import - projects' }
35
BitBucketModelImporter >> completeImportProject: aGLHProject [
1✔
36

1✔
37
        aGLHProject repository: GLHRepository new.
1✔
38
        self glhModel add: aGLHProject repository.
1✔
39
        "TODO: import repository"
1✔
40
        ^ aGLHProject
1✔
41
]
1✔
42

43
{ #category : #commit }
44
BitBucketModelImporter >> completeImportedCommit: aCommit [ 
1✔
45
        
1✔
46
        ('completing commit: ' , aCommit short_id printString) recordInfo.
1✔
47
        self importCreatorOfCommit: aCommit.
1✔
48

1✔
49
        self withCommitDiffs ifTrue: [
1✔
50
                | diffs |
1✔
51
                aCommit diffs ifEmpty: [
1✔
52
                        diffs := self importDiffOfCommit: aCommit.
1✔
53
                        self glhModel addAll: diffs unless: self blockForDiffEquality ] ].
1✔
54

1✔
55
        ^ aCommit
1✔
56
]
1✔
57

58
{ #category : #'private - api' }
59
BitBucketModelImporter >> convertBitBucketDiffToGitDiff: response [
1✔
60

1✔
61
        | fromHash toHash sourceLine sourceSpan destinationLine destinationSpan result filePathSource filePathDestination |
1✔
62
        fromHash := (response at: 'fromHash') ifNil: ''.
1✔
63
        toHash := (response at: 'toHash') ifNil: ''.
1✔
64

1✔
65

1✔
66
        "Iterate over each diff in 'diffs'"
1✔
67
        result := (response at: #diffs) collect: [ :diff | "Extract file path, hashes"
1✔
68
                          | gitDiff hunks|
1✔
69
                          gitDiff := ''.
1✔
70
                          filePathSource := (diff at: 'source')
1✔
71
                                                    ifNil: ''
1✔
72
                                                    ifNotNil: [ :source |
1✔
73
                                                    source at: 'toString' ].
1✔
74
                          filePathDestination := (diff at: 'destination')
1✔
75
                                                         ifNil: ''
1✔
76
                                                         ifNotNil: [ :destination |
1✔
77
                                                         destination at: 'toString' ].
1✔
78

1✔
79
                          "Build the diff header"
1✔
80
                          " gitDiff := gitDiff , 'diff --git a/', filePath, ' b/', filePath, String cr."
1✔
81
                          " gitDiff := gitDiff , 'index ', fromHash, '..', toHash, ' 100644', String cr."
1✔
82
                          gitDiff := gitDiff , '--- a/' , filePathSource , String cr.
1✔
83
                          gitDiff := gitDiff , '+++ b/' , filePathDestination
1✔
84
                                     , String cr.
1✔
85

1✔
86
                          "Iterate over hunks"
1✔
87
                                         hunks := diff at: #hunks ifPresent: [ :value | value ]  ifAbsent: [ { } ]. 
1✔
88
                          hunks do: [ :hunk |
1✔
89
                                  sourceLine := hunk at: 'sourceLine'.
1✔
90
                                  sourceSpan := hunk at: 'sourceSpan'.
1✔
91
                                  destinationLine := hunk at: 'destinationLine'.
1✔
92
                                  destinationSpan := hunk at: 'destinationSpan'.
1✔
93

1✔
94
                                  "Hunk header"
1✔
95
                                  gitDiff := gitDiff
1✔
96
                                             , ('@@ -{1},{2} +{3},{4} @@' format: {
1✔
97
                                                                      sourceLine.
1✔
98
                                                                      sourceSpan.
1✔
99
                                                                      destinationLine.
1✔
100
                                                                      destinationSpan }) , String cr.
1✔
101

1✔
102
                                  "Iterate over segments"
1✔
103
                                  (hunk at: 'segments') do: [ :segment |
1✔
104
                                          (segment at: 'lines') do: [ :line |
1✔
105
                                                  (segment at: 'type') = 'CONTEXT' ifTrue: [
1✔
106
                                                          gitDiff := gitDiff , (line at: 'line') , String cr ].
1✔
107
                                                  (segment at: 'type') = 'REMOVED' ifTrue: [
1✔
108
                                                          gitDiff := gitDiff , '-' , (line at: 'line')
1✔
109
                                                                     , String cr ].
1✔
110
                                                  (segment at: 'type') = 'ADDED' ifTrue: [
1✔
111
                                                          gitDiff := gitDiff , '+' , (line at: 'line')
1✔
112
                                                                     , String cr ] ] ] ].
1✔
113
                          GLHDiff new
1✔
114
                                  diffString: gitDiff;
1✔
115
                                  old_path: filePathSource;
1✔
116
                                  new_path: filePathDestination ].
1✔
117

1✔
118
        ^ result
1✔
119
]
1✔
120

121
{ #category : #'private - api' }
122
BitBucketModelImporter >> getContributionFromDiffs: diffs [
1✔
123

1✔
124
        | contribution |
1✔
125
        contribution := {
1✔
126
                                ('additions' -> 0).
1✔
127
                                ('deletions' -> 0) } asDictionary.
1✔
128

1✔
129
        diffs do: [ :diff |
1✔
130
                | hunks segments |
1✔
131
                hunks := diff at: #hunks ifAbsent: Array new.
1✔
132

1✔
133
                hunks do: [ :hunk |
1✔
134
                        | addedSegment removedSegment |
1✔
135
                        segments := hunk at: #segments.
1✔
136

1✔
137
                        addedSegment := segments
1✔
138
                                                detect: [ :segment |
1✔
139
                                                (segment at: #type) = 'ADDED' ]
1✔
140
                                                ifNone: [ nil ].
1✔
141
                        removedSegment := segments
1✔
142
                                                  detect: [ :segment |
1✔
143
                                                  (segment at: #type) = 'REMOVED' ]
1✔
144
                                                  ifNone: [ nil ].
1✔
145

1✔
146
                        addedSegment ifNotNil: [
1✔
147
                                contribution
1✔
148
                                        at: #additions
1✔
149
                                        put:
1✔
150
                                        (contribution at: #additions) + (addedSegment at: #lines) size ].
1✔
151
                        removedSegment ifNotNil: [
1✔
152
                                contribution
1✔
153
                                        at: #deletions
1✔
154
                                        put:
1✔
155
                                        (contribution at: #deletions) + (removedSegment at: #lines) size ] ] ].
1✔
156

1✔
157
        ^ contribution
1✔
158
]
1✔
159

160
{ #category : #'import - commits' }
161
BitBucketModelImporter >> importAndLoadLatestsCommitsOfProject: aGLHProject [
1✔
162

1✔
163
        | commits |
1✔
164
        self completeImportProject: aGLHProject.
1✔
165

1✔
166
        commits := self
1✔
167
                           importCommitsOfProject: aGLHProject
1✔
168
                           since: (Date today - 3 week) asDateAndTime
1✔
169
                           until: Date today asDateAndTime.
1✔
170
        commits do: [ :commit | self completeImportedCommit: commit ].
1✔
171
        
1✔
172
        self chainsCommitsFrom: commits.
1✔
173
        
1✔
174
        ^ commits
1✔
175
]
1✔
176

177
{ #category : #'import - commits' }
178
BitBucketModelImporter >> importCommitsOfProject: aGLHProject since: since until: until [
1✔
179

1✔
180
        | commits |
1✔
181
        commits := self repoApi commits
1✔
182
                           allSince: since
1✔
183
                           until: until
1✔
184
                           inRepository: aGLHProject id
1✔
185
                           ofProject: aGLHProject group id.
1✔
186
                
1✔
187
        commits := commits collect: [ :commit |
1✔
188
                           self
1✔
189
                                   parseCommitIntoGLHCommit: commit
1✔
190
                                   ofProject: aGLHProject ].
1✔
191

1✔
192

1✔
193
        commits := self glhModel
1✔
194
                           addAll: commits
1✔
195
                           unless: self blockOnIdEquality.
1✔
196
        ^ aGLHProject repository commits
1✔
197
                  addAll: commits
1✔
198
                  unless: self blockOnIdEquality
1✔
199
]
1✔
200

201
{ #category : #'import - projects' }
202
BitBucketModelImporter >> importContributedProjectsOfUser: aGLHUser [
1✔
203

1✔
204
        | projects repositories repositoriesCommits userRepositories userProjects |
1✔
205
        "get all projects"
1✔
206
        projects := self repoApi projects all.
1✔
207

1✔
208
        "get all repos of projects"
1✔
209
        repositories := projects flatCollect: [ :project |
1✔
210
                                self repoApi repositories allInProject:
1✔
211
                                        (project at: #key) ].
1✔
212

1✔
213

1✔
214
        "get all commits of repo"
1✔
215
        repositoriesCommits := repositories collect: [ :repository |
1✔
216
                                       repository -> (self repoApi commits allSince: DateAndTime now - 10 days until: DateAndTime now inRepository: (repository at: #slug) ofProject:  ((repository at: #project) at: #key))
1✔
217
                                                 ].
1✔
218

1✔
219

1✔
220
        "look if user is author of min one commit"
1✔
221
        userRepositories := repositoriesCommits select: [ :repository |
1✔
222
                                    | repos |
1✔
223
                                    repos := repository value
1✔
224
                                                     ifEmpty: [ false ]
1✔
225
                                                     ifNotEmpty: [
1✔
226
                                                             repository value
1✔
227
                                                                     detect: [ :commit |
1✔
228
                                                                     ((commit at: #author) at: #name)
1✔
229
                                                                     = aGLHUser username ]
1✔
230
                                                                     ifFound: [ true ]
1✔
231
                                                                     ifNone: [ false ] ] ].
1✔
232

1✔
233

1✔
234
        "Transform user repositories in GLHProject"
1✔
235
        userProjects := userRepositories collect: [ :repoCommits |
1✔
236
                                | repo project |
1✔
237
                                repo := repoCommits key.
1✔
238
                                project := repo at: #project.
1✔
239

1✔
240
                                (self glhModel allWithType: GLHProject)
1✔
241
                                        detect: [ :glhProject |
1✔
242
                                        glhProject id = (project at: #key) ]
1✔
243
                                        ifFound: [ :glhProject | glhProject ]
1✔
244
                                        ifNone: [
1✔
245
                                                | glhProject |
1✔
246
                                                glhProject := self parseRepoIntoGLHProject: repo.
1✔
247
                                                glhModel add: glhProject.
1✔
248
                                                glhProject ] ].
1✔
249

1✔
250
        aGLHUser contributedProjects: userProjects.
1✔
251

1✔
252
        ^ userProjects
1✔
253
]
1✔
254

255
{ #category : #'import - commits' }
256
BitBucketModelImporter >> importCreatorOfCommit: aGLHCommit [
1✔
257

1✔
258
        | creator |
1✔
259
        (self glhModel allWithType: GLHUser)
1✔
260
                detect: [ :user | user username = aGLHCommit author_name ]
1✔
261
                ifFound: [ :user |
1✔
262
                        aGLHCommit commitCreator: user.
1✔
263
                        ^ user ].
1✔
264

1✔
265
        creator := self importUserByUsername: aGLHCommit author_name.
1✔
266
        aGLHCommit commitCreator: creator.
1✔
267
        ^ creator
1✔
268
]
1✔
269

270
{ #category : #'import - commits' }
271
BitBucketModelImporter >> importDiffOfCommit: aCommit [
1✔
272

1✔
273
        | result diffsResult |
1✔
274
        aCommit diffs ifNotEmpty: [
1✔
275
                'Diff already importer: ' , aCommit short_id printString recordInfo.
1✔
276
                ^ aCommit diffs ].
1✔
277
        ('Import diff of commit: ' , aCommit short_id printString) recordInfo.
1✔
278
        result := self repoApi commits diffOf: aCommit id inRepository: aCommit repository project id  ofProject: aCommit repository project group id.
1✔
279

1✔
280
        diffsResult := self convertBitBucketDiffToGitDiff: result.
1✔
281

1✔
282

1✔
283
        diffsResult := aCommit diffs
1✔
284
                               addAll: diffsResult
1✔
285
                               unless: self blockForDiffEquality.
1✔
286

1✔
287
        "changes are added into the model during the import"
1✔
288
        diffsResult do: [ :diff | self importDiffRangesForDiff: diff ].
1✔
289

1✔
290
        ^ diffsResult
1✔
291
]
1✔
292

293
{ #category : #'import - groups' }
294
BitBucketModelImporter >> importGroup: aGroupID [
1✔
295

1✔
296
        | result projectResult |
1✔
297
        ('Import group with id:  ' , aGroupID printString) recordInfo.
1✔
298

1✔
299
        (glhModel allWithType: GLHGroup)
1✔
300
                detect: [ :group | group id = aGroupID ]
1✔
301
                ifFound: [ :group | ^ group ].
1✔
302
        "group are named projects in bitbucket"
1✔
303
        result := self repoApi projects get: aGroupID.
1✔
304
        projectResult := self parseProjectResult: result.
1✔
305

1✔
306
        ^ self glhModel add: projectResult unless: self blockOnIdEquality
1✔
307
]
1✔
308

309
{ #category : #'import - merge-requests' }
310
BitBucketModelImporter >> importMergeRequestCommits: mergeRequest [
1✔
311

1✔
312
        | commits |
1✔
313
        commits := self repoApi pullRequests commitsOf: mergeRequest id inRepository: mergeRequest project id ofProject: mergeRequest project group id.
1✔
314

1✔
315
        commits := commits collect: [ :commit |
1✔
316
                           self
1✔
317
                                   parseCommitIntoGLHCommit: commit
1✔
318
                                   ofProject: mergeRequest project ].
1✔
319

1✔
320
        mergeRequest commits: commits.
1✔
321

1✔
322
        ^ commits
1✔
323
]
1✔
324

325
{ #category : #'import - merge-requests' }
326
BitBucketModelImporter >> importMergeRequests: aGLHProject since: fromDate until: toDate [
1✔
327

1✔
328
        | pullRequests params |
1✔
329
        params := { 
1✔
330
                #state -> 'all'
1✔
331
         } asDictionary.
1✔
332
        pullRequests := self repoApi pullRequests allSince: fromDate until: toDate withParams: params  inRepository: aGLHProject id ofProject: aGLHProject group id.
1✔
333

1✔
334
        pullRequests := pullRequests collect: [ :pullRequest |
1✔
335
                                self parsePullRequestIntoGLPHEMergeRequest:
1✔
336
                                        pullRequest ].
1✔
337

1✔
338
        pullRequests := self glhModel
1✔
339
                                addAll: pullRequests
1✔
340
                                unless: self blockOnIdEquality.
1✔
341

1✔
342
        ^ pullRequests
1✔
343
]
1✔
344

345
{ #category : #'import - merge-requests' }
346
BitBucketModelImporter >> importMergeResquestAuthor: mergeRequest [
×
347
        mergeRequest author ifNotNil: [ ^mergeRequest ]
×
348
]
×
349

350
{ #category : #'import - merge-requests' }
351
BitBucketModelImporter >> importMergeResquestMerger: mergeRequest [
1✔
352

1✔
353
        | activities mergeActivity mergeUser |
1✔
354
        mergeRequest merge_user ifNotNil: [ ^ mergeRequest merge_user ].
1✔
355
        mergeRequest state = 'merged' ifFalse: [ ^ nil ].
1✔
356

1✔
357
        activities := self repoApi pullRequests activitiesOf: mergeRequest id  inRepository: mergeRequest project id  ofProject: mergeRequest project group id.
1✔
358

1✔
359
        mergeActivity := activities detect: [ :activity |
1✔
360
                                 (activity at: #action) = 'MERGED' ].
1✔
361

1✔
362
        mergeUser := mergeActivity at: #user.
1✔
363

1✔
364
        mergeUser := (glhModel allWithType: GLHUser)
1✔
365
                             detect: [ :user | user id = (mergeUser at: #id) ]
1✔
366
                             ifFound: [ :user | user ]
1✔
367
                             ifNone: [
1✔
368
                                     | glhUser |
1✔
369
                                     glhUser := self parseUserIntoGLHUser: mergeUser.
1✔
370
                                     glhModel add: glhUser.
1✔
371
                                     glhUser ].
1✔
372

1✔
373
        mergeRequest merge_user: mergeUser.
1✔
374
        ^ mergeUser
1✔
375
]
1✔
376

377
{ #category : #'import - projects' }
NEW
378
BitBucketModelImporter >> importProject: aProjectID [
×
NEW
379

×
NEW
380
        Error signal:
×
NEW
381
                'Bitbucket api cannot import directly a project (in the sens of GPH). One need to import a group, then the projects of this group.'
×
NEW
382
]
×
383

384
{ #category : #'import - users' }
385
BitBucketModelImporter >> importUserByUsername: username [
1✔
386

1✔
387
        ^ self userCatalogue collectUsernames at: username ifAbsent: [
1✔
388
                  | users glhUser user params|
1✔
389
                  params := { #filter -> username } asDictionary. 
1✔
390
                  users := self repoApi users allWithParams: params.
1✔
391
                  users ifEmpty: [ ^ nil ].
1✔
392
                  user := users first.
1✔
393

1✔
394
                  glhUser := self parseUserIntoGLHUser: user.
1✔
395
                  self glhModel add: glhUser unless: self blockOnIdEquality.
1✔
396
                  self userCatalogue addUser: glhUser withName: username.
1✔
397
                  glhUser ]
1✔
398
]
1✔
399

400
{ #category : #parsing }
401
BitBucketModelImporter >> parseCommitIntoGLHCommit: commitDictionary ofProject: aGLHProject [
1✔
402

1✔
403
        | author committer parentIds commitDiffs contribution |
1✔
404
        author := commitDictionary at: #author.
1✔
405
        committer := commitDictionary at: #committer.
1✔
406

1✔
407
        parentIds := (commitDictionary at: #parents) collect: [ :parent |
1✔
408
                             parent at: #id ].
1✔
409

1✔
410
        commitDiffs := self repoApi commits
1✔
411
                               diffOf: (commitDictionary at: #id)
1✔
412
                               inRepository: aGLHProject id
1✔
413
                               ofProject: aGLHProject group id.
1✔
414

1✔
415
        contribution := self getContributionFromDiffs:
1✔
416
                                (commitDiffs at: #diffs).
1✔
417

1✔
418
        ^ GLHCommit new
1✔
419
                  id: (commitDictionary at: #id);
1✔
420
                  message: (commitDictionary at: #message);
1✔
421
                  author_email: (author at: #emailAddress);
1✔
422
                  author_name: (author at: #name);
1✔
423
                  authored_date: (DateAndTime fromUnixTime:
1✔
424
                                           (commitDictionary at: #authorTimestamp) / 1000);
1✔
425
                  created_at: (DateAndTime fromUnixTime:
1✔
426
                                           (commitDictionary at: #authorTimestamp) / 1000);
1✔
427
                  committed_date: (DateAndTime fromUnixTime:
1✔
428
                                           (commitDictionary at: #committerTimestamp) / 1000);
1✔
429
                  committer_email: (committer at: #emailAddress);
1✔
430
                  committer_name: (committer at: #name);
1✔
431
                  parent_ids: parentIds;
1✔
432
                  additions: (contribution at: #additions);
1✔
433
                  deletions: (contribution at: #deletions)
1✔
434
]
1✔
435

436
{ #category : #parsing }
437
BitBucketModelImporter >> parseProjectIntoGLHGroup: projectRepository [
1✔
438

1✔
439
        ^ GLHGroup new
1✔
440
                  name: (projectRepository at: #name);
1✔
441
                  id: (projectRepository at: #key);
1✔
442
                  description: (projectRepository at: #description)
1✔
443
]
1✔
444

445
{ #category : #parsing }
446
BitBucketModelImporter >> parseProjectResult: aDictionary [
1✔
447

1✔
448
        ^ GLHGroup new
1✔
449
                  id: (aDictionary at: #key);
1✔
450
                  "use key instead of id because key is use everywhere else for API"
1✔
451
                  description: (aDictionary at: #description);
1✔
452
                  name: (aDictionary at: #name);
1✔
453
                  web_url: ((aDictionary at: #links at: #self) anyOne at: #href);
1✔
454
                  yourself
1✔
455
]
1✔
456

457
{ #category : #parsing }
458
BitBucketModelImporter >> parsePullRequestIntoGLPHEMergeRequest: pullRequestDictionary [
1✔
459

1✔
460
        | repository project toRef fromRef glpheMergeRequest author state reviewers |
1✔
461
        toRef := pullRequestDictionary at: #toRef.
1✔
462
        fromRef := pullRequestDictionary at: #fromRef.
1✔
463

1✔
464
        reviewers := pullRequestDictionary at: #reviewers.
1✔
465
        reviewers := reviewers collect: [ :reviewer |
1✔
466
                             | reviewerUser |
1✔
467
                             reviewerUser := reviewer at: #user.
1✔
468
                             (self glhModel allWithType: GLHUser)
1✔
469
                                     detect: [ :user | user id = (reviewerUser at: #id) ]
1✔
470
                                     ifFound: [ :user | user ]
1✔
471
                                     ifNone: [
1✔
472
                                             | glhUser |
1✔
473
                                             glhUser := self parseUserIntoGLHUser: reviewerUser.
1✔
474
                                             glhModel add: glhUser.
1✔
475
                                             glhUser ] ].
1✔
476

1✔
477
        repository := toRef at: #repository.
1✔
478
        project := (self glhModel allWithType: GLHProject)
1✔
479
                           detect: [ :glhProject |
1✔
480
                           glhProject id = (repository at: #id) ]
1✔
481
                           ifFound: [ :glhProject | glhProject ]
1✔
482
                           ifNone: [
1✔
483
                                   project := self parseRepoIntoGLHProject: repository.
1✔
484
                                   self glhModel add: project.
1✔
485
                                   project ].
1✔
486

1✔
487

1✔
488
        author := pullRequestDictionary at: #author.
1✔
489
        author := (self glhModel allWithType: GLHUser)
1✔
490
                          detect: [ :user | user id = ((author at: #user) at: #id) ]
1✔
491
                          ifFound: [ :user | user ]
1✔
492
                          ifNone: [
1✔
493
                          self importUserByUsername:
1✔
494
                                  ((author at: #user) at: #displayName) ].
1✔
495

1✔
496

1✔
497
        glpheMergeRequest := GLHMergeRequest new
1✔
498
                                     name: (pullRequestDictionary at: #title);
1✔
499
                                     title: (pullRequestDictionary at: #title);
1✔
500
                                     id: (pullRequestDictionary at: #id);
1✔
501
                                     project: project;
1✔
502
                                     project_id: project id;
1✔
503
                                     target_branch: (toRef at: #id);
1✔
504
                                     target_project_id:
1✔
505
                                             ((toRef at: #repository) at: #id);
1✔
506
                                     source_branch: (fromRef at: #id);
1✔
507
                                     target_project_id:
1✔
508
                                             ((fromRef at: #repository) at: #id);
1✔
509
                                     updated_at: (DateAndTime fromUnixTime:
1✔
510
                                                              (pullRequestDictionary at: #updatedDate)
1✔
511
                                                              / 1000);
1✔
512
                                     created_at: (DateAndTime fromUnixTime:
1✔
513
                                                              (pullRequestDictionary at: #createdDate)
1✔
514
                                                              / 1000);
1✔
515
                                     author: author.
1✔
516

1✔
517
        "STATE"
1✔
518
        state := pullRequestDictionary at: #state.
1✔
519
        state = 'OPEN' ifTrue: [ glpheMergeRequest state: 'opened' ].
1✔
520
        state = 'MERGED' ifTrue: [
1✔
521
                glpheMergeRequest state: 'merged'.
1✔
522
                glpheMergeRequest merged_at: (DateAndTime fromUnixTime:
1✔
523
                                 (pullRequestDictionary at: #closedDate) / 1000) ].
1✔
524

1✔
525
        state = 'DECLINED' ifTrue: [
1✔
526
                glpheMergeRequest state: 'closed'.
1✔
527
                glpheMergeRequest closed_at: (DateAndTime fromUnixTime:
1✔
528
                                 (pullRequestDictionary at: #closedDate) / 1000) ].
1✔
529

1✔
530
        ^ glpheMergeRequest
1✔
531
]
1✔
532

533
{ #category : #parsing }
534
BitBucketModelImporter >> parseRepoIntoGLHProject: repositoryDictionary [
1✔
535

1✔
536
        | project group glhProject |
1✔
537
        project := repositoryDictionary at: #project.
1✔
538

1✔
539
        group := (self glhModel allWithType: GLHGroup)
1✔
540
                         detect: [ :glhGroup | glhGroup id = (project at: #key) ]
1✔
541
                         ifFound: [ :glhGroup | glhGroup ]
1✔
542
                         ifNone: [
1✔
543
                                 | newGroup |
1✔
544
                                 newGroup := self parseProjectIntoGLHGroup: project.
1✔
545
                                 glhModel add: newGroup.
1✔
546
                                 newGroup ].
1✔
547

1✔
548

1✔
549
        glhProject := GLHProject new
1✔
550
                              name: (repositoryDictionary at: #name);
1✔
551
                              id: (repositoryDictionary at: #slug);
1✔
552
                              repository: GLHRepository new;
1✔
553
                              group: group.
1✔
554

1✔
555
        group addProject: glhProject.
1✔
556

1✔
557
        ^ glhProject
1✔
558
]
1✔
559

560
{ #category : #parsing }
561
BitBucketModelImporter >> parseUserIntoGLHUser: userDictionnary [
1✔
562

1✔
563
        ^ GLHUser new
1✔
564
                  name: (userDictionnary at: #displayName);
1✔
565
                  public_email: (userDictionnary at: #emailAddress);
1✔
566
                  id: (userDictionnary at: #id);
1✔
567
                  username: (userDictionnary at: #name)
1✔
568
]
1✔
569

570
{ #category : #accessing }
UNCOV
571
BitBucketModelImporter >> withInitialCommits [
×
UNCOV
572

×
UNCOV
573
        ^ withInitialCommits
×
UNCOV
574
]
×
575

576
{ #category : #accessing }
NEW
577
BitBucketModelImporter >> withInitialCommits: anObject [
×
NEW
578

×
NEW
579
        withInitialCommits := anObject
×
UNCOV
580
]
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc