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

moosetechnology / GitProjectHealth / 18275233369

01 Oct 2025 07:30AM UTC coverage: 77.946% (+4.6%) from 73.342%
18275233369

Pull #233

github

web-flow
Merge 47f5f8427 into dd8ffa1f6
Pull Request #233: V2.0.0 : Refactoring importers

4743 of 5132 new or added lines in 45 files covered. (92.42%)

32 existing lines in 8 files now uncovered.

23068 of 29595 relevant lines covered (77.95%)

0.78 hits per line

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

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

11
{ #category : #private }
12
GitlabModelImporter >> addCommits: commitsList toRepository: aProjectRepository [
×
13
        "I take a list of GLHCommit. But some might have been parsed but are already on the model..."
×
14

×
15
        "I return the list of added commits"
×
16

×
17
        | existingCommits newlyFoundCommit |
×
18
        existingCommits := aProjectRepository mooseModel allWithType:
×
19
                                   GLHCommit.
×
20
        newlyFoundCommit := commitsList reject: [ :commitParsed |
×
21
                                    existingCommits anySatisfy: [ :existingCommit |
×
22
                                            existingCommit id = commitParsed id ] ].
×
23
        aProjectRepository mooseModel addAll: newlyFoundCommit.
×
24
        aProjectRepository commits addAll: newlyFoundCommit.
×
25
        ^ newlyFoundCommit
×
26
]
×
27

28
{ #category : #private }
29
GitlabModelImporter >> addGroupResultToModel: groupResult [
1✔
30
        |group|
1✔
31
        group := self glhModel add: groupResult unless: self blockOnIdEquality.
1✔
32
        self glhModel
1✔
33
                addAll: group projects
1✔
34
                unless: self blockOnIdEquality.
1✔
35
        ^ group 
1✔
36
]
1✔
37

38
{ #category : #'import - pipelines' }
39
GitlabModelImporter >> allPipelinesOf: aProjectID [
×
40

×
41
        | result |
×
42
        ('Search pipelines of: ' , aProjectID printString) recordInfo.
×
43
        result := self repoApi pipelines getAllInProject: aProjectID.
×
44
        result isString ifTrue: [ ^ self parsePipelinesResult: result ].
×
45

×
46
        ^ (result collect: [ :pipelinesJson |
×
47
                           self parsePipelinesResult: pipelinesJson ]) flattened
×
48
]
×
49

50
{ #category : #'import - commits' }
UNCOV
51
GitlabModelImporter >> commitsOfProject: aGLHProject forRefName: refName until: toDate [
×
52

×
53
        | params results allCommits |
×
54
        
×
55
        params := { 
×
56
                #ref_name -> refName.
×
57
                #until -> (toDate ifNotNil: [ toDate asDateAndTime asString ] ifNil: [ '' ]) 
×
58
        } asDictionary.
×
59
        results := self repoApi commits getAllInProject: aGLHProject id withParams: params.
×
60
        allCommits := (results collect: [ :commitsJson | self parseCommitsResult: commitsJson ]) flattened.
×
61
        
×
62
        self glhModel addAll: allCommits unless: self blockOnIdEquality.
×
63
        aGLHProject repository commits addAll: allCommits unless: self blockOnIdEquality.
×
64

×
65
        self withCommitDiffs ifTrue: [
×
66
                aGLHProject repository commits do: [ :commit |
×
67
                        self importDiffOfCommit: commit ] ].
×
68
        
×
69
        ^allCommits
×
70
]
×
71

72
{ #category : #'import - projects' }
73
GitlabModelImporter >> completeImportProject: aGLHProject [
×
74

×
75
        | importedProject |
×
76
        ('Complete import of project: ' , aGLHProject id printString)
×
77
                recordInfo.
×
78
        aGLHProject repository ifNotNil: [ ^ aGLHProject ].
×
79

×
80
        importedProject := self glhModel
×
81
                                   add: aGLHProject
×
82
                                   unless: self blockOnIdEquality.
×
83

×
84
        self importLatestPipelinesOfProject: importedProject.
×
85

×
86
        "aGLHProject creator: (self importUser: aGLHProject creator_id)."
×
87

×
88
        (self importUser: importedProject creator_id) addCreatedProject:
×
89
                importedProject.
×
90

×
91

×
92
        importedProject repository: GLHRepository new.
×
93
        self glhModel add: importedProject repository.
×
NEW
94
        self completeImportsOfRepository: importedProject repository.
×
95

×
96

×
97
        withInitialMergeRequest ifTrue: [
×
98
                self
×
NEW
99
                        importMergeRequestsOfProject: importedProject
×
100
                        since: DateAndTime today
×
101
                        until: DateAndTime now ].
×
102

×
103
        ^ importedProject
×
104
        
×
105

×
106
]
×
107

108
{ #category : #'import - commits' }
109
GitlabModelImporter >> completeImportedCommit: aCommit [
1✔
110

1✔
111
        ('completing commit: ' , aCommit short_id printString) recordInfo.
1✔
112
        self importCreatorOfCommit: aCommit.
1✔
113

1✔
114
        self withCommitDiffs ifTrue: [
1✔
115
                | diffs |
1✔
116
                aCommit diffs ifEmpty: [
1✔
117
                        diffs := self importDiffOfCommit: aCommit.
1✔
118
                        self glhModel addAll: diffs unless: self blockForDiffEquality ] ].
1✔
119

1✔
120
        ^ aCommit
1✔
121
]
1✔
122

123
{ #category : #'import - jobs' }
124
GitlabModelImporter >> completeImportedJob: aGLHJob [
1✔
125
        
1✔
126
        aGLHJob commit ifNil: [ 
1✔
127
                |commit|
1✔
128
                commit := self
1✔
129
                          importCommit:
1✔
130
                          (aGLHJob cacheAt: #commitID ifAbsent: [ '' ])
1✔
131
                          ofProject: aGLHJob pipeline project.
1✔
132
                aGLHJob commit: commit. ].
1✔
133
        
1✔
134
        aGLHJob user ifNil: [ 
1✔
135
                |user|
1✔
136
                user := self importUser: (aGLHJob cacheAt: #userID ifAbsent: [ '' ]).
1✔
137
        aGLHJob user: user.
1✔
138
                 ]. 
1✔
139
        
1✔
140
        
1✔
141
        ^ aGLHJob
1✔
142
]
1✔
143

144
{ #category : #'import - pipelines' }
145
GitlabModelImporter >> completeImportedPipeline: aGLHPipeline [ 
1✔
146
        |result parsedResult|
1✔
147
        
1✔
148
        aGLHPipeline duration ifNotNil: [ ^ aGLHPipeline ].
1✔
149
        
1✔
150
        result := self repoApi pipelines get: aGLHPipeline id inProject: aGLHPipeline project id. 
1✔
151
        parsedResult := self parsePipelineResult: result. 
1✔
152
        
1✔
153
        "aGLHPipeline methods".
1✔
154
        { #'created_at:' . #'status:' . #'finished_at:' . #'duration:' . #'started_at:' . #'updated_at:' . #'ref:' } do: [ :m |
1✔
155
                aGLHPipeline perform: m asSymbol with: (parsedResult perform: (m withoutSuffix: ':') asSymbol )
1✔
156
                 ].
1✔
157
        
1✔
158
        parsedResult cacheAt: #userID ifPresent: [:id |
1✔
159
                aGLHPipeline user: (self importUser: id). 
1✔
160
                ].
1✔
161
        
1✔
162
        ^ aGLHPipeline. 
1✔
163
]
1✔
164

165
{ #category : #'import - pipelines' }
166
GitlabModelImporter >> completeImportedPipelines: aCollectionOfGLHPipeline [
×
167
        ^ aCollectionOfGLHPipeline collect: [ :pipeline | self completeImportedPipeline: pipeline ].  
×
168
]
×
169

170
{ #category : #'import - projects' }
171
GitlabModelImporter >> completeImportedProject: aGLHProject [
1✔
172

1✔
173
        | importedProject |
1✔
174
        ('Complete import of project: ' , aGLHProject id printString)
1✔
175
                recordInfo.
1✔
176
        aGLHProject repository ifNotNil: [ ^ aGLHProject ].
1✔
177

1✔
178
        importedProject := self glhModel
1✔
179
                                   add: aGLHProject
1✔
180
                                   unless: self blockOnIdEquality.
1✔
181

1✔
182
        self importLatestPipelinesOfProject: importedProject.
1✔
183

1✔
184
        "aGLHProject creator: (self importUser: aGLHProject creator_id)."
1✔
185

1✔
186
        (self importUser: importedProject creator_id) addCreatedProject:
1✔
187
                importedProject.
1✔
188

1✔
189
        
1✔
190
        importedProject repository: GLHRepository new.
1✔
191
        self glhModel add: importedProject repository.
1✔
192
        self completeImportsOfRepository: importedProject repository.
1✔
193
        
1✔
194

1✔
195
        withInitialMergeRequest ifTrue: [
1✔
196
                self
1✔
197
                        importMergeRequestsOfProject: importedProject
1✔
198
                        since: DateAndTime today
1✔
199
                        until: DateAndTime now ].
1✔
200

1✔
201
        ^ importedProject
1✔
202
        
1✔
203

1✔
204
]
1✔
205

206
{ #category : #'import - repositories' }
207
GitlabModelImporter >> completeImportsOfRepository: aGLHRepository [
1✔
208

1✔
209
        | branches |
1✔
210
        [
1✔
211
        ('import the repository of project ' , aGLHRepository project name)
1✔
212
                recordInfo.
1✔
213
        branches := self importBranchesOf: aGLHRepository project.
1✔
214
        self withFiles ifTrue: [
1✔
215
                branches do: [ :branch | self importFilesOfBranch: branch ] ] ]
1✔
216
                on: NeoJSONParseError
1✔
217
                do: [
1✔
218
                self inform: aGLHRepository project name , ' has no repository' ].
1✔
219

1✔
220
        withInitialCommits ifTrue: [
1✔
221
                aGLHRepository branches do: [ :branch |
1✔
222
                        self importCommitsOfBranch: branch ] ].
1✔
223
        
1✔
224
        ^ aGLHRepository 
1✔
225
]
1✔
226

227
{ #category : #'private - configure reader' }
228
GitlabModelImporter >> configureReaderForBranch: reader [
1✔
229

1✔
230
        super configureReaderForBranch: reader.
1✔
231
        
1✔
232
                reader for: GLHBranch do: [ :mapping |
1✔
233
                mapping
1✔
234
                        mapProperty: #commit
1✔
235
                        getter: [  ]
1✔
236
                        setter: [ :branch :rawCommit | branch sha: (rawCommit at: #id) ] ].
1✔
237
]
1✔
238

239
{ #category : #'private - configure reader' }
240
GitlabModelImporter >> configureReaderForCommit: reader [
1✔
241

1✔
242
        super configureReaderForCommit: reader.
1✔
243

1✔
244
        reader for: GLHCommit do: [ :mapping |
1✔
245

1✔
246
                (mapping mapInstVar: #authored_date) valueSchema: DateAndTime.
1✔
247
                (mapping mapInstVar: #committed_date) valueSchema: DateAndTime.
1✔
248
                (mapping mapInstVar: #created_at) valueSchema: DateAndTime.
1✔
249
                (mapping mapInstVar: #parent_ids) valueSchema: #ArrayOfIds.
1✔
250
                mapping
1✔
251
                        mapProperty: 'stats'
1✔
252
                        getter: [ :el | "Not used" ]
1✔
253
                        setter: [ :commit :value |
1✔
254
                                commit deletions: (value at: #deletions).
1✔
255
                                commit additions: (value at: #additions) ] ].
1✔
256

1✔
257
        reader
1✔
258
                for: #ArrayOfIds
1✔
259
                customDo: [ :mapping | mapping decoder: [ :string | string ] ]
1✔
260
]
1✔
261

262
{ #category : #'private - configure reader' }
263
GitlabModelImporter >> configureReaderForDiff: reader [
1✔
264

1✔
265
        super configureReaderForDiff: reader.
1✔
266
        reader
1✔
267
                for: GLHDiff
1✔
268
                do: [ :mapping | 
1✔
269
                        "mapping mapInstVars:
1✔
270
                        #( deleted_file new_file new_path old_path renamed_file )."
1✔
271
                        mapping mapInstVar: #diffString to: #diff ].
1✔
272

1✔
273
        ^ reader
1✔
274
]
1✔
275

276
{ #category : #'private - configure reader' }
277
GitlabModelImporter >> configureReaderForGroup: reader [
1✔
278

1✔
279
        super configureReaderForGroup: reader.
1✔
280

1✔
281
        reader for: GLHGroup do: [ :mapping |
1✔
282
                (mapping mapInstVar: #projects) valueSchema: #ArrayOfProject ]
1✔
283
]
1✔
284

285
{ #category : #'private - configure reader' }
286
GitlabModelImporter >> configureReaderForJob: reader [
1✔
287

1✔
288
        super configureReaderForJob: reader.
1✔
289

1✔
290
        reader
1✔
291
                for: GLHJob
1✔
292
                do: [ :mapping | "(mapping mapInstVar: #user) valueSchema: GLHUser.
1✔
293
                (mapping mapInstVar: #pipeline) valueSchema: GLHPipeline."
1✔
294
                        mapping
1✔
295
                                mapProperty: #user
1✔
296
                                getter: [  ]
1✔
297
                                setter: [ :job :rawUser |
1✔
298
                                job cacheAt: #userID put: (rawUser at: #id) ].
1✔
299

1✔
300
                        mapping
1✔
301
                                mapProperty: #pipeline
1✔
302
                                getter: [  ]
1✔
303
                                setter: [ :job :rawPipeline |
1✔
304
                                        job cacheAt: #pipelineID put: (rawPipeline at: #id) ].
1✔
305
                                
1✔
306
                        mapping
1✔
307
                                mapProperty: #commit
1✔
308
                                getter: [  ]
1✔
309
                                setter: [ :job :rawCommit |
1✔
310
                                        job cacheAt: #commitID put: (rawCommit at: #id) ].
1✔
311

1✔
312
                        "mapping
1✔
313
                        mapProperty: #user
1✔
314
                        getter: [ :object | #ignore ]
1✔
315
                        setter: [ :object :value |
1✔
316
                        object user: (self importUser: (value at: #id)) ]."
1✔
317

1✔
318
                        mapping
1✔
319
                                mapProperty: #duration
1✔
320
                                getter: [ :object | #ignore ]
1✔
321
                                setter: [ :object :value |
1✔
322
                                value ifNotNil: [ object duration: value seconds ] ] ]
1✔
323
]
1✔
324

325
{ #category : #'private - configure reader' }
326
GitlabModelImporter >> configureReaderForMergeRequest: reader [
1✔
327
        "declare quil y a un array a mapper"
1✔
328
        self flag: 'assignee.s must be parsed with nil condition'.
1✔
329
        super configureReaderForMergeRequest: reader.
1✔
330

1✔
331
        "declare la liste des properties"
1✔
332
        reader
1✔
333
                for: GLHMergeRequest
1✔
334
                do: [ :mapping | 
1✔
335
                         
1✔
336
                        "(mapping mapInstVar: #assignee) valueSchema: GLHUser."
1✔
337
                        "(mapping mapInstVar: #assignees) valueSchema: #ArrayOfUser."
1✔
338
                        (mapping mapInstVar: #created_at) valueSchema: DateAndTime.
1✔
339
                        (mapping mapInstVar: #updated_at) valueSchema: DateAndTime.
1✔
340
                        (mapping mapInstVar: #merged_at) valueSchema: DateAndTime.
1✔
341
                        (mapping mapInstVar: #closed_at) valueSchema: DateAndTime.
1✔
342

1✔
343
                        mapping
1✔
344
                                mapProperty: #author
1✔
345
                                getter: [  ]
1✔
346
                                setter: [ :object :value |
1✔
347
                                object cacheAt: #authorID put: (value at: #id) ].
1✔
348
                        mapping
1✔
349
                                mapProperty: #merge_user
1✔
350
                                getter: [  ]
1✔
351
                                setter: [ :object :value |
1✔
352
                                        value ifNotNil: [
1✔
353
                                                object cacheAt: #mergeUserID put: (value at: #id) ] ] ]
1✔
354
]
1✔
355

356
{ #category : #'private - parsing' }
357
GitlabModelImporter >> configureReaderForNote: reader [
1✔
358

1✔
359
        super configureReaderForNote: reader.
1✔
360

1✔
361
        reader for: GLHNote do: [ :mapping |
1✔
362
                
1✔
363
                (mapping mapInstVar: #created_at) valueSchema: DateAndTime.
1✔
364
                (mapping mapInstVar: #updated_at) valueSchema: DateAndTime ]
1✔
365
]
1✔
366

367
{ #category : #'private - configure reader' }
368
GitlabModelImporter >> configureReaderForPipeline: reader [
1✔
369

1✔
370
        super configureReaderForPipeline: reader.
1✔
371

1✔
372
        reader for: GLHPipeline do: [ :mapping |
1✔
373
                mapping
1✔
374
                        mapProperty: #created_at
1✔
375
                        getter: [ :object | #ignore ]
1✔
376
                        setter: [ :object :value |
1✔
377
                                object created_at:
1✔
378
                                        (value ifNotNil: [ DateAndTime fromString: value ]).
1✔
379
                                object runDate:
1✔
380
                                        (value ifNotNil: [ DateAndTime fromString: value ]) ].
1✔
381

1✔
382
                mapping
1✔
383
                        mapProperty: #updated_at
1✔
384
                        getter: [ :object | #ignore ]
1✔
385
                        setter: [ :object :value |
1✔
386
                                object updated_at:
1✔
387
                                        (value ifNotNil: [ DateAndTime fromString: value ]) ].
1✔
388

1✔
389
                mapping
1✔
390
                        mapProperty: #finished_at
1✔
391
                        getter: [ :object | #ignore ]
1✔
392
                        setter: [ :object :value |
1✔
393
                                object finished_at:
1✔
394
                                        (value ifNotNil: [ DateAndTime fromString: value ]) ].
1✔
395

1✔
396
                mapping
1✔
397
                        mapProperty: #started_at
1✔
398
                        getter: [ :object | #ignore ]
1✔
399
                        setter: [ :object :value |
1✔
400
                                object started_at:
1✔
401
                                        (value ifNotNil: [ DateAndTime fromString: value ]) ].
1✔
402

1✔
403
                mapping
1✔
404
                        mapProperty: #source
1✔
405
                        getter: [ :object | #ignore ]
1✔
406
                        setter: [ :object :value | object sourceEvent: value ].
1✔
407

1✔
408
                mapping
1✔
409
                        mapProperty: #duration
1✔
410
                        getter: [ :object | #ignore ]
1✔
411
                        setter: [ :object :value |
1✔
412
                                object duration: (value ifNotNil: [ value asDuration ]) ].
1✔
413

1✔
414
                mapping
1✔
415
                        mapProperty: #user
1✔
416
                        getter: [ :object | #ignore ]
1✔
417
                        setter: [ :object :value |
1✔
418
                                value ifNotNil: [ object cacheAt: #userID put: (value at: #id) ] ] ].
1✔
419

1✔
420
]
1✔
421

422
{ #category : #'private - configure reader' }
423
GitlabModelImporter >> configureReaderForProject: reader [
1✔
424

1✔
425
        super configureReaderForProject: reader.
1✔
426
        
1✔
427
        reader for: GLHProject do: [ :mapping |
1✔
428
                mapping mapInstVar: #web_url to: #html_url.
1✔
429
                ].
1✔
430
]
1✔
431

432
{ #category : #'private - configure reader' }
433
GitlabModelImporter >> configureReaderForRelease: reader [
1✔
434

1✔
435
        super configureReaderForRelease: reader.
1✔
436

1✔
437

1✔
438
        reader
1✔
439
                for: GLHRelease
1✔
440
                do: [ :mapping | (mapping mapInstVar: #author) valueSchema: GLHUser ].
1✔
441

1✔
442
]
1✔
443

444
{ #category : #'private - configure reader' }
445
GitlabModelImporter >> configureReaderForTag: reader [
1✔
446

1✔
447
        reader mapInstVarsFor: GLHTag .
1✔
448
        
1✔
449
        reader for: GLHTag do: [ :mapping |
1✔
450
                
1✔
451
                (mapping mapInstVar: #commit) valueSchema: GLHCommit .
1✔
452
"                (mapping mapInstVar: #release) valueSchema: GLHRelease ."
1✔
453
                (mapping mapInstVar: #created_at) valueSchema: DateAndTime .
1✔
454
                
1✔
455
                mapping
1✔
456
                        mapProperty: #release
1✔
457
                        getter: [ :object | #ignore ]
1✔
458
                        setter: [ :object :value |
1✔
459
                        object release: (value ifNotNil: [ GLHRelease new description: (value at:#description); tag_name: (value at: #tag_name); yourself ]).
1✔
460
                        ].
1✔
461
                 ].
1✔
462
        
1✔
463
        reader
1✔
464
                for: #ArrayOfTags
1✔
465
                customDo: [ :customMappting |
1✔
466
                customMappting listOfElementSchema: GLHTag ].
1✔
467
]
1✔
468

1✔
469
{ #category : #'private - configure reader' }
1✔
470
GitlabModelImporter >> configureReaderForUser: reader [
1✔
471

1✔
472
        super configureReaderForUser: reader
1✔
473
        
1✔
474
]
1✔
475

1✔
476
{ #category : #private }
1✔
477
GitlabModelImporter >> convertApiFileAsFile: aAPIFile [
1✔
478

1✔
479
        aAPIFile type = 'tree' ifTrue: [ 
1✔
480
                ^ GLHFileDirectory new
1✔
481
                          name: aAPIFile name;
1✔
482
                          yourself ].
1✔
483
        ^ GLHFileBlob new
1✔
484
                  name: aAPIFile name;
1✔
485
                  yourself
1✔
486
]
1✔
487

1✔
488
{ #category : #private }
1✔
489
GitlabModelImporter >> detectEntityType: aType overAttribut: aSelector equalTo: value [
1✔
490

1✔
491
        ^ (self glhModel allWithType: aType) detect: [ :entity |
1✔
492
                  (entity perform: aSelector) = value ] ifNone: [ nil ]. 
1✔
493
]
1✔
494

1✔
495
{ #category : #accessing }
1✔
496
GitlabModelImporter >> glhApi [
1✔
497

1✔
498
        self
1✔
499
                deprecated: 'Use #repoApi instead'
1✔
500
                on: '7 October 2024'
1✔
501
                in:
1✔
502
                'Pharo-11.0.0+build.726.sha.aece1b5473acf3830a0e082c1bc3a15d4ff3522b (64 Bit)'.
1✔
503

1✔
504
        ^ repoApi
1✔
505
]
1✔
506

1✔
507
{ #category : #accessing }
1✔
508
GitlabModelImporter >> glhApi: anObject [
1✔
509

1✔
510
        self
1✔
511
                deprecated: 'Use #repoApi: instead'
1✔
512
                on: '7 October 2024'
1✔
513
                in:
1✔
514
                'Pharo-11.0.0+build.726.sha.aece1b5473acf3830a0e082c1bc3a15d4ff3522b (64 Bit)'.
1✔
515

1✔
516
        repoApi := anObject
1✔
517
]
1✔
518

1✔
519
{ #category : #accessing }
1✔
520
GitlabModelImporter >> glhModel [
1✔
521

1✔
522
        ^ glhModel
1✔
523
]
1✔
524

1✔
525
{ #category : #accessing }
1✔
526
GitlabModelImporter >> glhModel: anObject [
1✔
527

1✔
528
        glhModel := anObject
1✔
529
]
1✔
530

1✔
531
{ #category : #'import - users' }
1✔
532
GitlabModelImporter >> importActiveHumanUsers [
1✔
533

1✔
534
        | params result users |
1✔
535
        params := { 
1✔
536
                #humans -> 'true'.
1✔
537
                #active -> 'true'.
1✔
538
                #without_project_bots -> 'true'
1✔
539
        } asDictionary.
1✔
540
        result := self repoApi users allWithParams: params.
1✔
541
        users := (result collect: [ :usersJson | self parseUsersResult: usersJson ]) flattened.
1✔
542
        
1✔
543
        self glhModel
1✔
544
                                 addAll: users
1✔
545
                                 unless: self blockOnIdEquality.
1✔
546

1✔
547
        ^ users
1✔
548
]
1✔
549

1✔
550
{ #category : #'import - groups' }
1✔
551
GitlabModelImporter >> importAllGroups [
1✔
552

1✔
553
        | params results groups |
1✔
554
        
1✔
555
        params := { 
1✔
556
                        #top_level_only -> 'true'
1✔
557
        } asDictionary.
1✔
558
        results := self repoApi groups getAllWithParams: params.
1✔
559
        
1✔
560
        groups := (results collect: [ :groupsJson | generalReader
1✔
561
                                            on: groupsJson readStream;
1✔
562
                                            nextAs: #ArrayOfGroups. ]) flattened.
1✔
563
        ^ groups
1✔
564
]
1✔
565

1✔
566
{ #category : #'import - pipelines' }
1✔
567
GitlabModelImporter >> importAllPipelinesOfProject: aGLHProject [
1✔
568
        
1✔
569
        (self allPipelinesOf: aGLHProject id) do: [ :pipeline |
1✔
570
                | pip |
1✔
571
                pip := self glhModel add: pipeline unless: self blockOnIdEquality.
1✔
572
                pip := aGLHProject pipelines add: pip unless: self blockOnIdEquality.
1✔
573
                self completeImportedPipeline: pip ].
1✔
574

1✔
575
        ^ aGLHProject pipelines
1✔
576
]
1✔
577

1✔
578
{ #category : #'import - commits' }
1✔
579
GitlabModelImporter >> importAndLoadLatestsCommitsOfProject: aGLHProject [
1✔
580

1✔
581
        | commits completedProject |
1✔
582
        completedProject := self completeImportedProject: aGLHProject.
1✔
583
        commits := self importLatestCommitsOfProject: completedProject.
1✔
584
        commits do: [ :commit | self completeImportedCommit: commit ].
1✔
585
        self chainsCommitsFrom: commits.
1✔
586
        ^ commits
1✔
587
]
1✔
588

1✔
589
{ #category : #'import - users' }
1✔
590
GitlabModelImporter >> importAuthorOfCommit: aGLHCommit [
1✔
591

1✔
592
        | user |
1✔
593
                self
1✔
594
                deprecated: 'Use importCreatorOfCommit: instead of current one'
1✔
595
                on: '19 September 2025'
1✔
596
                in:
1✔
597
                'Pharo-12.0.0+SNAPSHOT.build.1571.sha.cf5fcd22e66957962c97dffc58b0393b7f368147 (64 Bit)'.
1✔
598

1✔
599
        
1✔
600
        user := self importUserByUsername: aGLHCommit author_name.
1✔
601
        aGLHCommit commitCreator: user.
1✔
602
        ^ user
1✔
603
]
1✔
604

1✔
605
{ #category : #'import - branches' }
1✔
606
GitlabModelImporter >> importBranchesOf: aGLHProject [
1✔
607

1✔
608
        | resultBranches branches foundBranches |
1✔
609
        "aGLHProject repository branches removeAll "
1✔
610
        self
1✔
611
                deprecated: 'Use importBranchesOfProject: instead of current one'
1✔
612
                on: '26 September 2025'
1✔
613
                in:
1✔
614
                'Pharo-12.0.0+SNAPSHOT.build.1571.sha.cf5fcd22e66957962c97dffc58b0393b7f368147 (64 Bit)'.
1✔
615
        resultBranches := self repoApi branches getAllFromProject:
1✔
616
                                  aGLHProject id.
1✔
617

1✔
618
        foundBranches := (resultBranches collect: [ :branchesJson |
1✔
619
                                  self parseBranchesResult: branchesJson ])
1✔
620
                                 flattened.
1✔
621

1✔
622
        'import the branches of project ' recordInfo.
1✔
623

1✔
624
        "WARNING: always add branch first into repository, than into model !"
1✔
625
        branches := aGLHProject repository branches
1✔
626
                            addAll: foundBranches
1✔
627
                            unless: self blockOnNameEquality.
1✔
628

1✔
629

1✔
630
        branches := self glhModel
1✔
631
                            addAll: branches
1✔
632
                            unless: self blockForBranchEquality.
1✔
633

1✔
634
        "WARNING : branch must load its HEAD commit (ref) in a second time "
1✔
635
        ^ branches
1✔
636
]
1✔
637

1✔
638
{ #category : #'import - branches' }
1✔
639
GitlabModelImporter >> importBranchesOfProject: aGLHProject [
1✔
640

1✔
641
        | resultBranches branches foundBranches |
1✔
642
        "aGLHProject repository branches removeAll "
1✔
643
        resultBranches := self repoApi branches getAllFromProject:
1✔
644
                                  aGLHProject id.
1✔
645

1✔
646
        foundBranches := (resultBranches collect: [ :branchesJson |
1✔
647
                                  self parseBranchesResult: branchesJson ])
1✔
648
                                 flattened.
1✔
649

1✔
650
        'import the branches of project ' recordInfo.
1✔
651

1✔
652
        "WARNING: always add branch first into repository, than into model !"
1✔
653
        branches := aGLHProject repository branches
1✔
654
                            addAll: foundBranches
1✔
655
                            unless: self blockOnNameEquality.
1✔
656

1✔
657

1✔
658
        branches := self glhModel
1✔
659
                            addAll: branches
1✔
660
                            unless: self blockForBranchEquality.
1✔
661

1✔
662
        "WARNING : branch must load its HEAD commit (ref) in a second time "
1✔
663
        ^ branches
1✔
664
]
1✔
665

1✔
666
{ #category : #'import - commits' }
1✔
667
GitlabModelImporter >> importCommit: aCommitID ofProject: aGLHProject [
1✔
668

1✔
669
        | result parsedResult |
1✔
670
        (self glhModel allWithType: GLHCommit) asOrderedCollection
1✔
671
                detect: [ :commit | commit id = aCommitID ]
1✔
672
                ifFound: [ :commit | ^ commit ].
1✔
673

1✔
674
        result := self repoApi commits
1✔
675
                          get: aCommitID
1✔
676
                          inProject: aGLHProject id.
1✔
677

1✔
678
        parsedResult := self parseCommitResult: result.
1✔
679

1✔
680
        parsedResult := self glhModel
1✔
681
                                add: parsedResult
1✔
682
                                unless: self blockOnIdEquality.
1✔
683
        parsedResult := aGLHProject repository commits
1✔
684
                                add: parsedResult
1✔
685
                                unless: self blockOnIdEquality.
1✔
686

1✔
687
        self withCommitDiffs ifTrue: [ self importDiffOfCommit: parsedResult ].
1✔
688

1✔
689
        ^ parsedResult
1✔
690
]
1✔
691

1✔
692
{ #category : #'import - commits' }
1✔
693
GitlabModelImporter >> importCommitOfProject: anProject withId: anID [
1✔
694

1✔
695
        | commit result |
1✔
696
self
1✔
697
                deprecated: 'Use importCommit:ofProject: instead of current one'
1✔
698
                on: '27 August 2025'
1✔
699
                in: 'MSR 1.3.0 '
1✔
700
                transformWith: '`@rcv importCommitOfProject: `arg1 withId: `arg2' -> '`@rcv importCommit: `arg2 ofProject: `arg1'.
1✔
701
        anID ifNil: [ ^ nil ].
1✔
702

1✔
703
        ('looking for commit ' , anID printString , ' in project : '
1✔
704
         , anProject id printString) recordInfo.
1✔
705

1✔
706
        commit := (self
1✔
707
                           detectEntityType: GLHCommit
1✔
708
                           overAttribut: #id
1✔
709
                           equalTo: anID) ifNil: [
1✔
710
                          result := self repoApi commits
1✔
711
                                            get: anID
1✔
712
                                            inProject: anProject id.
1✔
713
                          commit := (self parseCommitsResult: '[' , result , ']')
1✔
714
                                            first.
1✔
715

1✔
716
                          commit := self glhModel
1✔
717
                                            add: commit
1✔
718
                                            unless: self blockOnIdEquality.
1✔
719
                          commit repository: anProject repository.
1✔
720

1✔
721
                          commit ].
1✔
722

1✔
723
        self withCommitDiffs ifTrue: [ self importDiffOfCommit: commit ].
1✔
724

1✔
725
        ^ commit
1✔
726
]
1✔
727

1✔
728
{ #category : #'import - commits' }
1✔
729
GitlabModelImporter >> importCommits: aGLHProject [
1✔
730
        "limited to the last 20 commits"
1✔
731

1✔
732
        | results parsedResults params |
1✔
733
        self
1✔
734
                deprecated:
1✔
735
                'Use importLatestCommitsOfProject: instead of current one'
1✔
736
                on: '19 September 2025'
1✔
737
                in:
1✔
738
                'Pharo-12.0.0+SNAPSHOT.build.1571.sha.cf5fcd22e66957962c97dffc58b0393b7f368147 (64 Bit)'.
1✔
739
                
1✔
740
        params := { (#with_stats -> 'true') } asDictionary.
1✔
741
        results := self repoApi commits
1✔
742
                           getByPage: 1
1✔
743
                           perPage: 20
1✔
744
                           inProject: aGLHProject id
1✔
745
                           withParams: params.
1✔
746

1✔
747
        parsedResults := self parseCommitsResult: results.
1✔
748
        self glhModel addAll: parsedResults unless: self blockOnIdEquality.
1✔
749

1✔
750
        parsedResults do: [ :commit |
1✔
751
                commit repository: aGLHProject repository ].
1✔
752

1✔
753
        self withCommitDiffs ifTrue: [
1✔
754
                parsedResults do: [ :commit | self importDiffOfCommit: commit ] ].
1✔
755

1✔
756
        ^ parsedResults
1✔
757
]
1✔
758

1✔
759
{ #category : #'import - commits' }
1✔
760
GitlabModelImporter >> importCommitsFollowing: aCommit upToDays: aNumberOfDay [
1✔
761
        "import the 'n' commits of a project starting from an initial 'aCommit' commit. 
1✔
762
        Lazy import does not import the entities inside the model"
1✔
763

1✔
764
        | date |
1✔
765
        date := aCommit created_at asDateAndTime.
1✔
766

1✔
767
        ^ self
1✔
768
                  importCommitsOfBranch: aCommit branch
1✔
769
                  since: date
1✔
770
                  until: date + aNumberOfDay day
1✔
771
]
1✔
772

1✔
773
{ #category : #'import - commits' }
1✔
774
GitlabModelImporter >> importCommitsFromTag: fromTag toTag: toTag [ 
1✔
775
        | results commits project|
1✔
776
                
1✔
777
        (fromTag isNil or: [ toTag isNil ] ) ifTrue: [ ^ OrderedCollection new.  ] .
1✔
778

1✔
779
        project := fromTag repository project.
1✔
780
        results := self repoApi repositories compareInProject: (project id) from: fromTag name to: toTag name.
1✔
781
        
1✔
782
        commits := (NeoJSONReader fromString: results ) at: #commits ifAbsent: ['[]'].
1✔
783
        
1✔
784
        
1✔
785
        commits := self parseCommitsResult: (NeoJSONWriter toString: commits).
1✔
786
         commits := glhModel addAll: commits unless: self blockOnIdEquality.
1✔
787
        commits := project repository commits addAll: commits unless: self blockOnIdEquality.
1✔
788
        
1✔
789
        self chainsCommitsFrom: commits. 
1✔
790
        
1✔
791
        ^ commits. 
1✔
792
        
1✔
793
]
1✔
794

1✔
795
{ #category : #'import - commits' }
1✔
796
GitlabModelImporter >> importCommitsOfBranch: aGLHBranch [
1✔
797

1✔
798
        | commits |
1✔
799
        "        result := self glhApi
1✔
800
                          commitsOfProject: aGLHBranch repository project id
1✔
801
                          forRefName: aGLHBranch name."
1✔
802
        commits := self
1✔
803
                           importCommitsOfBranch: aGLHBranch
1✔
804
                           since: withCommitsSince.
1✔
805

1✔
806
        self chainsCommitsFrom: commits.
1✔
807

1✔
808
        commits do: [ :aCommit |
1✔
809
                aCommit repository: aGLHBranch repository.
1✔
810
                self completeImportedCommit: aCommit ].
1✔
811
        ^ commits
1✔
812
]
1✔
813

1✔
814
{ #category : #'import - commits' }
1✔
815
GitlabModelImporter >> importCommitsOfBranch: aGLHBranch fromCommit: anInitialCommit [
1✔
816

1✔
817
        | commits |
1✔
818
        "        result := self glhApi
1✔
819
                          commitsOfProject: aGLHBranch repository project id
1✔
820
                          forRefName: aGLHBranch name."
1✔
821
        commits := self
1✔
822
                           importCommitsOfBranch: aGLHBranch
1✔
823
                           since: anInitialCommit committed_date.
1✔
824

1✔
825
        commits do: [ :aCommit |
1✔
826
                aCommit repository: aGLHBranch repository.
1✔
827
                self completeImportedCommit: aCommit ].
1✔
828
        ^ commits
1✔
829
]
1✔
830

1✔
831
{ #category : #'import - commits' }
1✔
832
GitlabModelImporter >> importCommitsOfBranch: aGLHBranch since: fromDate [
1✔
833

1✔
834
        ^ self importCommitsOfBranch: aGLHBranch since: fromDate until: nil
1✔
835
]
1✔
836

1✔
837
{ #category : #'import - commits' }
1✔
838
GitlabModelImporter >> importCommitsOfBranch: aGLHBranch since: fromDate until: toDate [
1✔
839

1✔
840
        | params result allCommits |
1✔
841
        params := {
1✔
842
                          (#ref_name -> aGLHBranch name).
1✔
843
                          (#since -> (fromDate
1✔
844
                                    ifNotNil: [ fromDate asDate asDateAndTime asString ]
1✔
845
                                    ifNil: [ '' ])).
1✔
846
                          (#until -> (toDate
1✔
847
                                    ifNotNil: [ toDate asDate asDateAndTime asString ]
1✔
848
                                    ifNil: [ '' ])).
1✔
849
                          (#with_stats -> 'true') } asDictionary.
1✔
850
        result := self repoApi commits
1✔
851
                          getAllInProject: aGLHBranch repository project id
1✔
852
                          withParams: params.
1✔
853

1✔
854
        allCommits := (result collect: [ :commitsJson |
1✔
855
                               self parseCommitsResult: commitsJson ]) flattened.
1✔
856

1✔
857
        aGLHBranch commits addAll: allCommits unless: self blockOnIdEquality.
1✔
858

1✔
859
        self glhModel
1✔
860
                addAll: aGLHBranch commits
1✔
861
                unless: self blockOnIdEquality.
1✔
862

1✔
863
        self chainsCommitsFrom: allCommits.
1✔
864

1✔
865
        ^ allCommits
1✔
866
]
1✔
867

1✔
868
{ #category : #'import - commits' }
1✔
869
GitlabModelImporter >> importCommitsOfBranch: aGLHBranch until: toDate [
1✔
870

1✔
871
        ^ self importCommitsOfBranch: aGLHBranch since: nil until: toDate
1✔
872
]
1✔
873

1✔
874
{ #category : #'import - commits' }
1✔
875
GitlabModelImporter >> importCommitsOfProject: aProject since: fromDate until: toDate [
1✔
876

1✔
877
        | params results allCommits |
1✔
878
        params := {
1✔
879
                          (#since
1✔
880
                           ->
1✔
881
                           (fromDate
1✔
882
                                    ifNotNil: [ fromDate asDate asDateAndTime asString ]
1✔
883
                                    ifNil: [ '' ])).
1✔
884
                          (#until
1✔
885
                           ->
1✔
886
                           (toDate
1✔
887
                                    ifNotNil: [ toDate asDate asDateAndTime asString ]
1✔
888
                                    ifNil: [ '' ])).
1✔
889
                          (#with_stats -> 'true').
1✔
890
                          (#all -> 'true') } asDictionary.
1✔
891
        results := self repoApi commits
1✔
892
                           getAllInProject: aProject id
1✔
893
                           withParams: params.
1✔
894

1✔
895
        allCommits := (results collect: [ :commitsJson |
1✔
896
                               self parseCommitsResult: commitsJson ]) flattened.
1✔
897

1✔
898
        allCommits:= aProject repository commits
1✔
899
                addAll: allCommits
1✔
900
                unless: self blockOnIdEquality.
1✔
901

1✔
902
        ^ self glhModel addAll: allCommits unless: self blockOnIdEquality
1✔
903
]
1✔
904

1✔
905
{ #category : #'import - commits' }
1✔
906
GitlabModelImporter >> importCommitsOfTag: aGLHTag [
1✔
907

1✔
908
        | taggedCommit tags commits date |
1✔
909
        self
1✔
910
                deprecated: 'Use importCommitsFromTag:toTag: instead of current one'
1✔
911
                on: '21 July 2025'
1✔
912
                in:
1✔
913
                'Pharo-12.0.0+SNAPSHOT.build.1571.sha.cf5fcd22e66957962c97dffc58b0393b7f368147 (64 Bit)'.
1✔
914
        
1✔
915
        
1✔
916
        tags := self importTagsForProject: aGLHTag repository project.
1✔
917

1✔
918

1✔
919
        taggedCommit := aGLHTag commit ifNil: [
1✔
920
                                self
1✔
921
                                        importCommit: aGLHTag target
1✔
922
                                        ofProject: aGLHTag repository project ].
1✔
923

1✔
924
        date := (tags isEmptyOrNil and: [ tags size < 2 ])
1✔
925
                        ifTrue: [ aGLHTag created_at ]
1✔
926
                        ifFalse: [ tags second commit committed_date ].
1✔
927

1✔
928
        commits := self
1✔
929
                           importParentCommitsOfCommit: taggedCommit
1✔
930
                           since: tags third created_at.
1✔
931
        commits add: taggedCommit.
1✔
932
        self chainsCommitsFrom: commits.
1✔
933

1✔
934
        ^ commits
1✔
935
]
1✔
936

1✔
937
{ #category : #'import - projects' }
1✔
938
GitlabModelImporter >> importContributedProjectsOfUser: aGLHUser [
1✔
939

1✔
940
        | remaningProjects params results projects projectsIds |
1✔
941
        params := {
1✔
942
                          (#order_by -> 'last_activity_at').
1✔
943
                          (#simple -> 'true') } asDictionary.
1✔
944
        results := self repoApi projects
1✔
945
                           contributedProjectsOfUser: aGLHUser id
1✔
946
                           withParams: params.
1✔
947

1✔
948
        projectsIds := (results collect: [ :projectsJson |
1✔
949
                             (NeoJSONReader fromString: projectsJson) collect: [:projectJson | projectJson at: #id ] ]) flattened.
1✔
950
        
1✔
951
        projects := self importProjects: projectsIds.
1✔
952
        remaningProjects := self importProjects:
1✔
953
                                    ((projects collect: #id) difference:
1✔
954
                                             ((self userCatalogue atId: aGLHUser id) at:
1✔
955
                                                      #contributedProjects)).
1✔
956

1✔
957

1✔
958
        aGLHUser contributedProjects
1✔
959
                addAll: projects , remaningProjects
1✔
960
                unless: self blockOnIdEquality.
1✔
961

1✔
962
        self userCatalogue
1✔
963
                addUser: aGLHUser
1✔
964
                withProjects: (aGLHUser contributedProjects collect: #id).
1✔
965

1✔
966
        ^ projects
1✔
967
]
1✔
968

1✔
969
{ #category : #'import - commits' }
1✔
970
GitlabModelImporter >> importDiffOfCommit: aCommit [
1✔
971

1✔
972
        | result diffsResult |
1✔
973
        aCommit diffs ifNotEmpty: [
1✔
974
                'Diff already importer: ' , aCommit short_id printString recordInfo.
1✔
975
                ^ aCommit diffs ].
1✔
976
        ('Import diff of commit: ' , aCommit short_id printString) recordInfo.
1✔
977

1✔
978
        result := self repoApi commits
1✔
979
                          diffOf: aCommit id
1✔
980
                          inProject: aCommit repository project id
1✔
981
                          uniDiff: true.
1✔
982

1✔
983
        (self isServerError: result) ifTrue: [ ^ {  } ].
1✔
984
        diffsResult := self newParseDiffResult: result.
1✔
985

1✔
986
        aCommit diffs addAll: diffsResult unless: self blockForDiffEquality.
1✔
987
        
1✔
988
        "changes are added into the model during the import"
1✔
989
        aCommit diffs do: [ :diff | self importDiffRangesForDiff: diff ].
1✔
990

1✔
991
        ^ aCommit diffs
1✔
992
]
1✔
993

1✔
994
{ #category : #'import - merge-requests' }
1✔
995
GitlabModelImporter >> importDiffOfMergeRequest: aMergeRequest [
1✔
996

1✔
997
        | result diffsResult |
1✔
998
        aMergeRequest diffs ifNotEmpty: [
1✔
999
                'Diff of already importer: '
1✔
1000
                , aMergeRequest iid printString recordInfo.
1✔
1001
                ^ aMergeRequest diffs ].
1✔
1002
        ('Import diff commits of MR ' , aMergeRequest iid printString)
1✔
1003
                recordInfo.
1✔
1004
        result := self repoApi mergeRequests
1✔
1005
                          diffsOf: aMergeRequest iid
1✔
1006
                          inProject: aMergeRequest project_id.
1✔
1007
        diffsResult := result flatCollect: [ :aResult |
1✔
1008
                               self newParseDiffResult: aResult ].
1✔
1009

1✔
1010

1✔
1011
        aMergeRequest diffs
1✔
1012
                addAll: diffsResult
1✔
1013
                unless: self blockForDiffEquality.
1✔
1014
        self glhModel
1✔
1015
                addAll: aMergeRequest diffs
1✔
1016
                unless: self blockForDiffEquality.
1✔
1017

1✔
1018
        aMergeRequest diffs do: [ :diff | self importDiffRangesForDiff: diff ].
1✔
1019

1✔
1020
        ^ aMergeRequest diffs
1✔
1021
]
1✔
1022

1✔
1023
{ #category : #'import - repositories' }
1✔
1024
GitlabModelImporter >> importDirectoryFiles: aDirectoryFile OfBranch: aBranch [
1✔
1025

1✔
1026
        | result files apiFiles params |
1✔
1027
        params := { 
1✔
1028
                #ref -> aBranch name.
1✔
1029
                #path -> (aDirectoryFile path , '/')
1✔
1030
        } asDictionary.
1✔
1031
        result := self repoApi repositories repositoryTreeOfProject: aBranch repository project id withParams: params.
1✔
1032
                         " treeOfRepository: aBranch repository project id
1✔
1033
                          ofBranch: aBranch name
1✔
1034
                          andPath: aDirectoryFile path , '/'."
1✔
1035
        apiFiles := (result collect: [ :treeJson | self parseFileTreeResult: treeJson ]) flattened.
1✔
1036
        files := apiFiles collect: [ :apiFile |
1✔
1037
                         self convertApiFileAsFile: apiFile ].
1✔
1038
        
1✔
1039
        files do: [ :file |
1✔
1040
                self glhModel add: file.
1✔
1041
                aDirectoryFile addFile: file ].
1✔
1042
        
1✔
1043
        files
1✔
1044
                select: [ :file | file isKindOf: GLHFileDirectory ]
1✔
1045
                thenCollect: [ :file |
1✔
1046
                self importDirectoryFiles: file OfBranch: aBranch ]
1✔
1047
]
1✔
1048

1✔
1049
{ #category : #'import - file' }
1✔
1050
GitlabModelImporter >> importFileWithPath: aPath ofProject: aGLHProject inBranch: aBranch [ 
1✔
1051
        self flag: 'imported file need to be store inside the model'.
1✔
1052
        ^ self repoApi repositories getRawFile: aPath ofProject: aGLHProject id withParams: {#ref -> aBranch name} asDictionary .
1✔
1053
]
1✔
1054

1✔
1055
{ #category : #'import - repositories' }
1✔
1056
GitlabModelImporter >> importFilesOfBranch: aBranch [
1✔
1057

1✔
1058
        | result files apiFiles params |
1✔
1059
        params := { 
1✔
1060
                #ref -> aBranch name.
1✔
1061
        } asDictionary.
1✔
1062
        
1✔
1063
        result := self repoApi repositories repositoryTreeOfProject: aBranch repository project id withParams: params.
1✔
1064
        
1✔
1065
                          "treeOfRepository: aBranch repository project id
1✔
1066
                          ofBranch: aBranch name
1✔
1067
                          andPath: nil."
1✔
1068
        apiFiles := (result collect: [ :filesJson | self parseFileTreeResult: filesJson  ]) flattened.
1✔
1069
        files := apiFiles collect: [ :apiFile | 
1✔
1070
                         self convertApiFileAsFile: apiFile ].
1✔
1071
        files do: [ :file | 
1✔
1072
                self glhModel add: file.
1✔
1073
                aBranch addFile: file ].
1✔
1074
        files
1✔
1075
                select: [ :file | file isKindOf: GLHFileDirectory ]
1✔
1076
                thenCollect: [ :file | 
1✔
1077
                self importDirectoryFiles: file OfBranch: aBranch ].
1✔
1078
        
1✔
1079
   ^ files
1✔
1080
]
1✔
1081

1✔
1082
{ #category : #'import - groups' }
1✔
1083
GitlabModelImporter >> importGroup: aGroupID [
1✔
1084

1✔
1085
        | result groupResult |
1✔
1086
        ('Import group: ' , aGroupID printString) recordInfo.
1✔
1087

1✔
1088
        result := self repoApi groups get: aGroupID.
1✔
1089
        
1✔
1090
        "group: aGroupID."
1✔
1091
        groupResult := self parseGroupResult: result.
1✔
1092
        groupResult := self addGroupResultToModel: groupResult.
1✔
1093

1✔
1094
        groupResult projects do: [ :project |
1✔
1095
                self completeImportedProject: project ].
1✔
1096

1✔
1097
        (self subGroupsOf: aGroupID) do: [ :subGroup |
1✔
1098
                
1✔
1099
                groupResult subGroups
1✔
1100
                        add: (self importGroup: subGroup id)
1✔
1101
                        unless: self blockOnIdEquality ].
1✔
1102
        ^ groupResult
1✔
1103
]
1✔
1104

1✔
1105
{ #category : #'import - jobs' }
1✔
1106
GitlabModelImporter >> importJobsOf: aPipeline [
1✔
1107

1✔
1108
        
1✔
1109
        self
1✔
1110
                deprecated: 'Use importJobsOfPipeline: instead of current one'
1✔
1111
                on: '26 September 2025'
1✔
1112
                in:
1✔
1113
                'Pharo-12.0.0+SNAPSHOT.build.1571.sha.cf5fcd22e66957962c97dffc58b0393b7f368147 (64 Bit)'.
1✔
1114
        ^ self importJobsOfPipeline: aPipeline.
1✔
1115
]
1✔
1116

1✔
1117
{ #category : #'import - jobs' }
1✔
1118
GitlabModelImporter >> importJobsOfPipeline: aPipeline [
1✔
1119

1✔
1120
        | jobs results |
1✔
1121
        results := self repoApi jobs
1✔
1122
                           getAllForPipeline: aPipeline id
1✔
1123
                           inProject: aPipeline project id.
1✔
1124
        "jobsOfProject: aPipeline project id
1✔
1125
                          ofPipelines: aPipeline id."
1✔
1126
        jobs := (results collect: [ :jobsJson |
1✔
1127
                         self parseJobsResult: jobsJson ]) flattened.
1✔
1128

1✔
1129

1✔
1130
        jobs := self glhModel addAll: jobs unless: self blockOnIdEquality.
1✔
1131
        jobs := aPipeline jobs addAll: jobs unless: self blockOnIdEquality.
1✔
1132

1✔
1133

1✔
1134
        jobs do: [ :job | self completeImportedJob: job ].
1✔
1135

1✔
1136
        ^ jobs
1✔
1137
]
1✔
1138

1✔
1139
{ #category : #'import - commits' }
1✔
1140
GitlabModelImporter >> importLatestCommitsOfProject: aGLHProject [
1✔
1141
        "limited to the last 50 commits"
1✔
1142

1✔
1143
        | results parsedResults params |
1✔
1144
        params := { 
1✔
1145
                #with_stats -> 'true'.
1✔
1146
                #all -> true
1✔
1147
         } asDictionary.
1✔
1148
        results := self repoApi commits getByPage: 1 perPage: 50 inProject: aGLHProject id withParams: params.
1✔
1149

1✔
1150
        parsedResults := self parseCommitsResult: results.
1✔
1151
        parsedResults := self glhModel
1✔
1152
                                 addAll: parsedResults
1✔
1153
                                 unless: self blockOnIdEquality.
1✔
1154

1✔
1155
        aGLHProject repository commits
1✔
1156
                addAll: parsedResults
1✔
1157
                unless: self blockOnIdEquality.
1✔
1158

1✔
1159
        self withCommitDiffs ifTrue: [
1✔
1160
                parsedResults do: [ :commit | self importDiffOfCommit: commit ] ].
1✔
1161

1✔
1162
        ^ parsedResults
1✔
1163
]
1✔
1164

1✔
1165
{ #category : #'import - merge-requests' }
1✔
1166
GitlabModelImporter >> importLatestMergeRequestsOfProject: aGLHProject [ 
1✔
1167
        
1✔
1168
        |results parsedResults|
1✔
1169
        results := self repoApi mergeRequests getByPage: 1 perPage: 20  inProject: aGLHProject id. 
1✔
1170
        parsedResults := self parseMergeRequestsResult: results. 
1✔
1171
        
1✔
1172
        parsedResults := glhModel addAll: parsedResults unless: self blockOnIdEquality.
1✔
1173
        parsedResults := aGLHProject mergeRequests addAll: parsedResults unless: self blockOnIdEquality.
1✔
1174
        ^ parsedResults.
1✔
1175
]
1✔
1176

1✔
1177
{ #category : #'import - pipelines' }
1✔
1178
GitlabModelImporter >> importLatestPipelinesOfProject: aGLHProject [ 
1✔
1179
        (self pipelinesOf: aGLHProject id withLimit:20) do: [ :pipeline |
1✔
1180
                |pip|
1✔
1181
                pip := self glhModel add: pipeline unless: self blockOnIdEquality .
1✔
1182
                pip := aGLHProject pipelines add: pip unless: self blockOnIdEquality.
1✔
1183
                self completeImportedPipeline: pip. 
1✔
1184
                ].
1✔
1185
        
1✔
1186
        ^ aGLHProject pipelines 
1✔
1187
]
1✔
1188

1✔
1189
{ #category : #'import - releases' }
1✔
1190
GitlabModelImporter >> importLatestReleaseOfProject: aGLHProject [ 
1✔
1191
        
1✔
1192
        |result foundRelease|
1✔
1193
        result := repoApi releases getLatestOfProject: aGLHProject id.
1✔
1194
        foundRelease := self parseReleaseResult: result. 
1✔
1195

1✔
1196
        foundRelease := glhModel add: foundRelease unless: self blockOnNameEquality.
1✔
1197
        foundRelease := aGLHProject releases add: foundRelease unless: self blockOnNameEquality.
1✔
1198

1✔
1199
        foundRelease author: (self importUser: foundRelease author id). 
1✔
1200
        
1✔
1201
        ^ foundRelease.
1✔
1202
]
1✔
1203

1✔
1204
{ #category : #'import - commits' }
1✔
1205
GitlabModelImporter >> importMergeRequestCommits: aGLPHEMergeRequest [
1✔
1206

1✔
1207
        | commits result |
1✔
1208
        aGLPHEMergeRequest commits ifNotNil: [ ^ aGLPHEMergeRequest commits ].
1✔
1209
        
1✔
1210
        result := self repoApi mergeRequests commitsOf: aGLPHEMergeRequest iid inProject: aGLPHEMergeRequest project id.
1✔
1211
        
1✔
1212
        commits := (result collect: [ :commitsJson | self parseCommitsResult: commitsJson ]) flattened.
1✔
1213
        commits := commits collect: [ :commit | self importCommit: commit id ofProject: aGLPHEMergeRequest project ].
1✔
1214
        aGLPHEMergeRequest commits: commits.
1✔
1215

1✔
1216

1✔
1217
        ^ commits
1✔
1218
]
1✔
1219

1✔
1220
{ #category : #'import - commits' }
1✔
1221
GitlabModelImporter >> importMergeRequestMergeCommits: aGLPHEMergeRequest [
1✔
1222

1✔
1223
        | foundCommits |
1✔
1224
        foundCommits := OrderedCollection new.
1✔
1225

1✔
1226
        ('Import commit sha of MR:  ' , aGLPHEMergeRequest iid printString)
1✔
1227
                recordInfo.
1✔
1228
        "the founds commits are added to the model during their respective import"
1✔
1229
        aGLPHEMergeRequest mergeRequestCommit: ((self
1✔
1230
                          importCommitOfProject: aGLPHEMergeRequest project
1✔
1231
                          withId: aGLPHEMergeRequest sha) ifNotNil: [ :commit |
1✔
1232
                         foundCommits add: commit ]).
1✔
1233

1✔
1234
        ('Import commit merge_commit_sha of MR:  '
1✔
1235
         , aGLPHEMergeRequest iid printString) recordInfo.
1✔
1236
        aGLPHEMergeRequest mergedCommit: ((self
1✔
1237
                          importCommitOfProject: aGLPHEMergeRequest project
1✔
1238
                          withId: aGLPHEMergeRequest merge_commit_sha) ifNotNil: [ :commit |
1✔
1239
                         foundCommits add: commit ]).
1✔
1240

1✔
1241
        ('Import commit squash_commit_sha of MR:  '
1✔
1242
         , aGLPHEMergeRequest iid printString) recordInfo.
1✔
1243
        aGLPHEMergeRequest squashCommit: ((self
1✔
1244
                          importCommitOfProject: aGLPHEMergeRequest project
1✔
1245
                          withId: aGLPHEMergeRequest squash_commit_sha) ifNotNil: [ :commit |
1✔
1246
                         foundCommits add: commit ]).
1✔
1247

1✔
1248

1✔
1249
        self chainsCommitsFrom: foundCommits.
1✔
1250
        ^ foundCommits
1✔
1251
]
1✔
1252

1✔
1253
{ #category : #'import - pipelines' }
1✔
1254
GitlabModelImporter >> importMergeRequestPipelines: aGLHMergeRequest [
1✔
1255
        "default limit to one page with last 100 pipelines"
1✔
1256

1✔
1257
        | results parseResults |
1✔
1258
        self
1✔
1259
                deprecated:
1✔
1260
                'Use importPipelinesOfMergeRequest: instead of current one'
1✔
1261
                on: '23 September 2025'
1✔
1262
                in:
1✔
1263
                'Pharo-12.0.0+SNAPSHOT.build.1571.sha.cf5fcd22e66957962c97dffc58b0393b7f368147 (64 Bit)'.
1✔
1264

1✔
1265
        ^ self importPipelinesOfMergeRequest: aGLHMergeRequest. 
1✔
1266
]
1✔
1267

1✔
1268
{ #category : #'import - merge-requests' }
1✔
1269
GitlabModelImporter >> importMergeRequestsOfProject: aGLHProject [
1✔
1270

1✔
1271
        | results parsedResults mrs |
1✔
1272
        ('Import merge request of Project: ' , aGLHProject id printString)
1✔
1273
                recordInfo.
1✔
1274

1✔
1275
        results := self repoApi mergeRequests getAllOfProject: aGLHProject id.
1✔
1276
        parsedResults := (results collect: [ :projectsJson | self parseMergeRequestsResult: projectsJson ]) flattened. 
1✔
1277

1✔
1278
        aGLHProject mergeRequests
1✔
1279
                addAll: parsedResults
1✔
1280
                unless: self blockOnIdEquality.
1✔
1281

1✔
1282
        mrs := self glhModel
1✔
1283
                       addAll: aGLHProject mergeRequests
1✔
1284
                       unless: self blockOnIdEquality.
1✔
1285

1✔
1286

1✔
1287
        "gets it related commits"
1✔
1288
        aGLHProject mergeRequests do: [ :mr |
1✔
1289
                self importMergeRequestMergeCommits: mr ].
1✔
1290

1✔
1291

1✔
1292
        self withCommitDiffs ifTrue: [
1✔
1293
                aGLHProject mergeRequests do: [ :mr |
1✔
1294
                        self importDiffOfMergeRequest: mr ] ].
1✔
1295

1✔
1296
        ^ mrs
1✔
1297
]
1✔
1298

1✔
1299
{ #category : #'import - merge-requests' }
1✔
1300
GitlabModelImporter >> importMergeRequestsOfProject: aGLHProject since: fromDate until: toDate [
1✔
1301

1✔
1302
        | params result mergeRequests |
1✔
1303
        ('import MR of Project ' , aGLHProject name) recordInfo.
1✔
1304
        params := {
1✔
1305
                          (#created_after
1✔
1306
                           ->
1✔
1307
                           (fromDate
1✔
1308
                                    ifNotNil: [ fromDate asDateAndTime asString ]
1✔
1309
                                    ifNil: [ '' ])).
1✔
1310
                          (#created_before
1✔
1311
                           ->
1✔
1312
                           (toDate
1✔
1313
                                    ifNotNil: [ toDate asDateAndTime asString ]
1✔
1314
                                    ifNil: [ '' ])).
1✔
1315
                          (#scope -> 'all') } asDictionary.
1✔
1316

1✔
1317
        result := self repoApi mergeRequests
1✔
1318
                          getAllOfProject: aGLHProject id
1✔
1319
                          withParams: params.
1✔
1320
        mergeRequests := (result collect: [ :mergeRequestsJson |
1✔
1321
                                  self parseMergeRequestsResult: mergeRequestsJson ])
1✔
1322
                                 flattened.
1✔
1323

1✔
1324
        aGLHProject mergeRequests
1✔
1325
                addAll: mergeRequests
1✔
1326
                unless: self blockOnIdEquality.
1✔
1327

1✔
1328
        "gets it related commits"
1✔
1329
        aGLHProject mergeRequests do: [ :mr |
1✔
1330
                self importMergeRequestMergeCommits: mr ].
1✔
1331

1✔
1332
        self withCommitDiffs ifTrue: [
1✔
1333
                aGLHProject mergeRequests do: [ :mr |
1✔
1334
                        self importDiffOfMergeRequest: mr ] ].
1✔
1335

1✔
1336
        self glhModel
1✔
1337
                addAll: mergeRequests
1✔
1338
                unless: (self blockEqualityOn: #iid).
1✔
1339

1✔
1340
        ^ mergeRequests
1✔
1341
]
1✔
1342

1✔
1343
{ #category : #'import - merge-requests' }
1✔
1344
GitlabModelImporter >> importMergeResquestApprovals: aGLPHEMergeRequest [
1✔
1345

1✔
1346
        | results parsedResult |
1✔
1347
        (String streamContents: [ :str |
1✔
1348
                 str << 'Check approvals of '.
1✔
1349
                 aGLPHEMergeRequest printOn: str ]) recordInfo.
1✔
1350
        results := self repoApi mergeRequests approvalsOf: aGLPHEMergeRequest iid inProject: aGLPHEMergeRequest project id.
1✔
1351

1✔
1352
        parsedResult := generalReader
1✔
1353
                                on: results readStream;
1✔
1354
                                next.
1✔
1355

1✔
1356
        (parsedResult at: #approved_by) do: [ :approvedUser |
1✔
1357
                aGLPHEMergeRequest addApproved_by:
1✔
1358
                        (self importUser: ((approvedUser at: #user) at: #id)) ].
1✔
1359
        aGLPHEMergeRequest approved: (parsedResult at: #approved).
1✔
1360
        ^ aGLPHEMergeRequest
1✔
1361
]
1✔
1362

1✔
1363
{ #category : #'import - merge-requests' }
1✔
1364
GitlabModelImporter >> importMergeResquestAuthor: aGLPHEMergeRequest [
1✔
1365

1✔
1366
        | authorID |
1✔
1367
        aGLPHEMergeRequest author ifNotNil: [ ^ aGLPHEMergeRequest author ].
1✔
1368
        authorID := aGLPHEMergeRequest cacheAt: #authorID ifAbsent: [
1✔
1369
                            | result |
1✔
1370
                            result := self repoApi mergeRequests
1✔
1371
                                              get: aGLPHEMergeRequest iid
1✔
1372
                                              inProject: aGLPHEMergeRequest project_id.
1✔
1373

1✔
1374
                            (generalReader
1✔
1375
                                     on: result readStream;
1✔
1376
                                     next) at: #author at: #id ].
1✔
1377
        ^aGLPHEMergeRequest author: (self importUser: authorID)
1✔
1378
]
1✔
1379

1✔
1380
{ #category : #'import - merge-requests' }
1✔
1381
GitlabModelImporter >> importMergeResquestMerger: aGLPHEMergeRequest [
1✔
1382

1✔
1383
        | authorID |
1✔
1384
        aGLPHEMergeRequest merge_user ifNotNil: [
1✔
1385
                ^ aGLPHEMergeRequest merge_user ].
1✔
1386
        authorID := aGLPHEMergeRequest cacheAt: #mergeUserID ifAbsent: [
1✔
1387
                            | result |
1✔
1388
                            result := self repoApi mergeRequests
1✔
1389
                                              get: aGLPHEMergeRequest iid
1✔
1390
                                              inProject: aGLPHEMergeRequest project_id.
1✔
1391
                            (generalReader
1✔
1392
                                     on: result readStream;
1✔
1393
                                     next)
1✔
1394
                                    at: #merge_user
1✔
1395
                                    ifPresent: [ :mergeUser |
1✔
1396
                                    mergeUser ifNotNil: [ :mruser | mruser at: #id ] ] ].
1✔
1397
        ^aGLPHEMergeRequest merge_user: (self importUser: authorID)
1✔
1398
]
1✔
1399

1✔
1400
{ #category : #'import - notes' }
1✔
1401
GitlabModelImporter >> importNotesOfMergeRequest: mergeRequest [
1✔
1402
        | results notes |
1✔
1403
        
1✔
1404
        results := self repoApi notes allInMergeRequest: mergeRequest iid ofProject: mergeRequest project id.
1✔
1405
        
1✔
1406
        notes := results collect: [ :note | 
1✔
1407
                self parseNoteJson: note ].
1✔
1408
        "notes := self parseNoteJson: results."
1✔
1409
        notes do: [ :tabNotes | tabNotes do: [ :note |
1✔
1410
                        note author: (self importUser: (note author at: #id)).
1✔
1411
                        note name: note id asString]. ].
1✔
1412
        notes := notes flattened.
1✔
1413
        notes := self glhModel addAll: notes unless: self blockOnIdEquality. 
1✔
1414
        notes := mergeRequest note addAll: notes unless: self blockOnIdEquality. 
1✔
1415
        ^notes
1✔
1416
        
1✔
1417
]
1✔
1418

1✔
1419
{ #category : #'import - commits' }
1✔
1420
GitlabModelImporter >> importParentCommitsOfCommit: aGLHCommit since: aDate [
1✔
1421

1✔
1422
        | parentsIds commits |
1✔
1423
        commits := Set new.
1✔
1424
        aGLHCommit created_at asDateAndTime < aDate asDateAndTime ifTrue: [
1✔
1425
                 
1✔
1426
                ^ commits
1✔
1427
                          add: aGLHCommit;
1✔
1428
                          yourself ].
1✔
1429

1✔
1430
        parentsIds := aGLHCommit parent_ids.
1✔
1431

1✔
1432
        commits addAll: (parentsIds collect: [ :id |
1✔
1433
                         self
1✔
1434
                                 importCommit: id ofProject: aGLHCommit repository project  ]).
1✔
1435

1✔
1436
        
1✔
1437
        commits addAll: (commits collect: [ :parentCommit |
1✔
1438
                   self importParentCommitsOfCommit: parentCommit since: aDate ]).
1✔
1439

1✔
1440
        ^ commits flattened asSet. 
1✔
1441
]
1✔
1442

1✔
1443
{ #category : #'import - pipelines' }
1✔
1444
GitlabModelImporter >> importPipeline: pipelineId OfProject: aGLHProject [
1✔
1445

1✔
1446
        
1✔
1447
        | result pipeline|
1✔
1448
        
1✔
1449
        aGLHProject pipelines detect: [ :pip | pip id = pipelineId ] ifOne: [ :pip| ^pip ].
1✔
1450
        
1✔
1451
        ('Search pipelines of: ' , aGLHProject id printString) recordInfo.
1✔
1452
        result := self repoApi pipelines get: pipelineId inProject: aGLHProject id.
1✔
1453
        
1✔
1454
        pipeline :=  self parsePipelineResult: result.
1✔
1455

1✔
1456
        pipeline := self glhModel add: pipeline unless: self blockOnIdEquality .
1✔
1457
        pipeline := aGLHProject pipelines add: pipeline unless: self blockOnIdEquality.
1✔
1458
        
1✔
1459
        ^ self completeImportedPipeline: pipeline. 
1✔
1460
]
1✔
1461

1✔
1462
{ #category : #'import - pipelines' }
1✔
1463
GitlabModelImporter >> importPipelinesOfMergeRequest: aGLHMergeRequest [
1✔
1464
        "default limit to one page with last 100 pipelines"
1✔
1465

1✔
1466
        | results parseResults |
1✔
1467
        results := self repoApi pipelines
1✔
1468
                           getByPage: 1
1✔
1469
                           perPage: 100
1✔
1470
                           inProject: aGLHMergeRequest project id
1✔
1471
                           forMergerRequestIid: aGLHMergeRequest iid.
1✔
1472

1✔
1473
        parseResults := self parsePipelinesResult: results.
1✔
1474

1✔
1475
        parseResults do: [ :pipeline |
1✔
1476
                pipeline project: aGLHMergeRequest project.
1✔
1477
                ].
1✔
1478

1✔
1479
        parseResults := glhModel
1✔
1480
                                addAll: parseResults
1✔
1481
                                unless: self blockOnIdEquality.
1✔
1482
        parseResults := aGLHMergeRequest pipelines
1✔
1483
                                addAll: parseResults
1✔
1484
                                unless: self blockOnIdEquality.
1✔
1485
                
1✔
1486
                
1✔
1487
        ^ parseResults collect: [ :pip | self completeImportedPipeline: pip ]
1✔
1488
]
1✔
1489

1✔
1490
{ #category : #'import - pipelines' }
1✔
1491
GitlabModelImporter >> importPipelinesOfProject: aGLHProject [
1✔
1492

1✔
1493
        self
1✔
1494
                deprecated:
1✔
1495
                'Use importAllPipelinesOfProject: instead of current one'
1✔
1496
                on: '23 September 2025'
1✔
1497
                in:
1✔
1498
                'Pharo-12.0.0+SNAPSHOT.build.1571.sha.cf5fcd22e66957962c97dffc58b0393b7f368147 (64 Bit)'.
1✔
1499

1✔
1500
        self flag:
1✔
1501
                'WARNING: this import ALL the pipelines at ones. Prefered ImportLatestPipleinesOfProject: for faster performance (if possible)'.
1✔
1502
        ^ self importAllPipelinesOfProject: aGLHProject
1✔
1503
]
1✔
1504

1✔
1505
{ #category : #'import - pipelines' }
1✔
1506
GitlabModelImporter >> importPipelinesOfProject: aGLHProject after: after andBefore: before [
1✔
1507
        ^ (self pipelinesOf: aGLHProject id after: after andBefore: before) collect: [ :pipeline |
1✔
1508
                |pip|
1✔
1509
                pip := self glhModel add: pipeline unless: self blockOnIdEquality .
1✔
1510
                pip := aGLHProject pipelines add: pip unless: self blockOnIdEquality.
1✔
1511
                
1✔
1512
                ].
1✔
1513
        
1✔
1514
]
1✔
1515

1✔
1516
{ #category : #'import - pipelines' }
1✔
1517
GitlabModelImporter >> importPipelinesOfProject: aGLHProject after: after andBefore: before onBranch: aBranch [
1✔
1518
        | result parsedResults|
1✔
1519
        ('Search pipelines of: ' , aGLHProject id printString) recordInfo.
1✔
1520
        
1✔
1521
        result := self repoApi pipelines getAllInProject: aGLHProject id 
1✔
1522
                                                                                                withParams: {        #updated_before -> before.
1✔
1523
                                                                                                                                        #updated_after -> after.
1✔
1524
                                                                                                                                        #ref -> aBranch name} asDictionary .
1✔
1525
        result isString ifTrue: [ ^ self parsePipelinesResult: result ].
1✔
1526

1✔
1527
        parsedResults := (result collect: [ :pipelinesJson |
1✔
1528
                           self parsePipelinesResult: pipelinesJson ]) flattened.
1✔
1529
        
1✔
1530

1✔
1531
        ^ parsedResults collect: [ :pipeline |
1✔
1532
                |pip|
1✔
1533
                pip := self glhModel add: pipeline unless: self blockOnIdEquality .
1✔
1534
                aGLHProject pipelines add: pip unless: self blockOnIdEquality.
1✔
1535
                ].
1✔
1536
        
1✔
1537
]
1✔
1538

1✔
1539
{ #category : #'import - projects' }
1✔
1540
GitlabModelImporter >> importProject: aProjectID [
1✔
1541

1✔
1542
        | result projectResult |
1✔
1543
        ('Import project with id:  ' , aProjectID printString) recordInfo.
1✔
1544

1✔
1545
        (glhModel allWithType: GLHProject)
1✔
1546
                detect: [ :project | project id = aProjectID ]
1✔
1547
                ifFound: [ :project | ^ project ].
1✔
1548

1✔
1549
        result := self repoApi projects get: aProjectID.
1✔
1550
        projectResult := self parseProjectResult: result.
1✔
1551

1✔
1552
        ^ self completeImportedProject: projectResult
1✔
1553
]
1✔
1554

1✔
1555
{ #category : #'import - projects' }
1✔
1556
GitlabModelImporter >> importProjects [
1✔
1557

1✔
1558
        | result projects |
1✔
1559
        ('import all Projects') recordInfo.
1✔
1560

1✔
1561

1✔
1562
        result := self repoApi projects all.
1✔
1563
        projects := (result collect: [ :projectsJson | self parseArrayOfProject: projectsJson ]) flattened.
1✔
1564
        
1✔
1565
        self glhModel addAll: projects unless: self blockOnIdEquality.
1✔
1566

1✔
1567
        ^ projects
1✔
1568
]
1✔
1569

1✔
1570
{ #category : #'import - projects' }
1✔
1571
GitlabModelImporter >> importProjectsSince: since [
1✔
1572
        "heavy import of all projects"
1✔
1573

1✔
1574
        "copy import from commits"
1✔
1575

1✔
1576
        | newlyFoundProjects page foundProject amount |
1✔
1577
        ('import all Projects since: ' , since printString) recordInfo.
1✔
1578

1✔
1579
        "number of projects per page"
1✔
1580
        amount := 100.
1✔
1581
        page := 0.
1✔
1582
        foundProject := OrderedCollection new.
1✔
1583
        newlyFoundProjects := { true }.
1✔
1584
        [ newlyFoundProjects isNotEmpty ] whileTrue: [
1✔
1585
                | results |
1✔
1586
                page := page + 1.
1✔
1587
                ('import projects page #' , page printString) recordInfo.
1✔
1588

1✔
1589
                results := self repoApi projects allWithParams: {#since -> since} asDictionary .
1✔
1590

1✔
1591
                newlyFoundProjects := self glhModel
1✔
1592
                                              addAll: (self parseArrayOfProject: results)
1✔
1593
                                              unless: self blockOnIdEquality.
1✔
1594
                foundProject addAll: newlyFoundProjects ].
1✔
1595
]
1✔
1596

1✔
1597
{ #category : #'import - commits' }
1✔
1598
GitlabModelImporter >> importSZZFromCommit: aCommit [
1✔
1599

1✔
1600
        | diffRanges diffs szzCommits |
1✔
1601
        szzCommits := Set new.
1✔
1602
        diffs := self importDiffOfCommit: aCommit.
1✔
1603
        diffRanges := diffs flatCollect: #diffRanges.
1✔
1604
        diffRanges do: [ :range |
1✔
1605
                | blames |
1✔
1606
                blames := NeoJSONReader fromString: (self repoApi repositories
1✔
1607
                                           getBlameOf: range diff new_path
1✔
1608
                                           inRef: aCommit id
1✔
1609
                                           start: range start
1✔
1610
                                           end: range end
1✔
1611
                                           ofProject: aCommit repository project id).
1✔
1612
                blames collect: [ :blame |
1✔
1613
                        blame isDictionary ifTrue: [
1✔
1614
                                szzCommits add: (self
1✔
1615
                                                 importCommit: (blame at: #commit at: #id)
1✔
1616
                                                 ofProject: aCommit repository project) ] ] ].
1✔
1617
        ^ szzCommits
1✔
1618
]
1✔
1619

1✔
1620
{ #category : #'import - tags' }
1✔
1621
GitlabModelImporter >> importTagsForProject: aProject [ 
1✔
1622
        |results tags |
1✔
1623
        results  := repoApi tags getAllOfProject: aProject id.
1✔
1624
        "get a group of tags"
1✔
1625
        tags := results flatCollect: [ :result |
1✔
1626
                        self parseTagsResult: result. 
1✔
1627
                 ].
1✔
1628

1✔
1629
        "add the tags inside the model"
1✔
1630
        tags := glhModel addAll: tags unless: self blockOnNameEquality.
1✔
1631
        tags := aProject repository tags addAll: tags unless: self blockOnNameEquality.
1✔
1632
        
1✔
1633
        "update tag's commit if already imported"
1✔
1634
        tags do: [ :tag |
1✔
1635
                tag commit: (self importCommit: tag commit id ofProject: aProject).
1✔
1636
                 ].
1✔
1637
        
1✔
1638
        "update tag's release if already imported"
1✔
1639
        tags do: [ :tag |
1✔
1640
                |release|
1✔
1641
                tag release ifNotNil: [ 
1✔
1642
                        release := glhModel add: tag release unless: (self blockEqualityOn: #tag_name).
1✔
1643
                        release := aProject releases add: tag release unless: (self blockEqualityOn: #tag_name).
1✔
1644
                        tag release: release. 
1✔
1645
                         ].
1✔
1646
                 ].
1✔
1647
        
1✔
1648
        ^ tags
1✔
1649
]
1✔
1650

1✔
1651
{ #category : #'import - users' }
1✔
1652
GitlabModelImporter >> importUser: aUserID [
1✔
1653

1✔
1654
        | result userResult |
1✔
1655
        (self glhModel allWithType: GLHUser)
1✔
1656
                detect: [ :user | user id = aUserID ]
1✔
1657
                ifFound: [ :user | ^ user ].
1✔
1658
        ('Import user: ' , aUserID printString) recordInfo.
1✔
1659
        
1✔
1660
        result := self repoApi users get: aUserID.
1✔
1661
        userResult := self parseUserResult: result.
1✔
1662
        
1✔
1663
        userResult := self glhModel add: userResult unless: self blockOnIdEquality.
1✔
1664
        userCatalogue addUser: userResult.
1✔
1665
        ^ userResult 
1✔
1666
]
1✔
1667

1✔
1668
{ #category : #'import - users' }
1✔
1669
GitlabModelImporter >> importUserByUsername: anUsername [
1✔
1670

1✔
1671
        | dicUsername resultUser |
1✔
1672
        dicUsername := ((self glhModel allWithType: GLHUser) collect: [ :user |
1✔
1673
                                user username -> user ]) asSet asDictionary.
1✔
1674

1✔
1675
        dicUsername addAll: self userCatalogue collectUsernames.
1✔
1676

1✔
1677

1✔
1678
        resultUser := dicUsername
1✔
1679
                              at: anUsername
1✔
1680
                              ifAbsent: [ "thus we have to import this new user"
1✔
1681
                                      | result userId searchResult params |
1✔
1682
                                      ('Import user with username: '
1✔
1683
                                       , anUsername printString) recordInfo.
1✔
1684
                                      params := { (#search -> anUsername) } asDictionary.
1✔
1685
                                      result := self repoApi users allWithParams: params.
1✔
1686
                                                        
1✔
1687
                                                         "when result is an error"
1✔
1688
                                                         (result isString) ifTrue: [ result := { result } ].
1✔
1689
                                                        
1✔
1690
                                      searchResult := result ifEmpty: [ result ] ifNotEmpty: [(result collect: [ :usersJson |
1✔
1691
                                                               NeoJSONReader fromString: usersJson ]) first].
1✔
1692
                                                         
1✔
1693
                                      (searchResult class = Dictionary and: [
1✔
1694
                                               (searchResult at: #message) includesSubstring:
1✔
1695
                                                       '403 Forbidden' ])
1✔
1696
                                              ifTrue: [ "if the result is an 403 error we fake a new user"
1✔
1697
                                                      self glhModel
1✔
1698
                                                              add: (GLHUser new
1✔
1699
                                                                               username: anUsername;
1✔
1700
                                                                               name: anUsername;
1✔
1701
                                                                               yourself)
1✔
1702
                                                              unless: [ :nu :ou | nu username = ou username ] ]
1✔
1703
                                              ifFalse: [
1✔
1704
                                                      searchResult
1✔
1705
                                                              ifEmpty: [ "results can be empty thus we force a new user with the info we have "
1✔
1706
                                                                      self glhModel
1✔
1707
                                                                              add: (GLHUser new
1✔
1708
                                                                                               username: anUsername;
1✔
1709
                                                                                               name: anUsername;
1✔
1710
                                                                                               yourself)
1✔
1711
                                                                              unless: [ :nu :ou | nu username = ou username ] ]
1✔
1712
                                                              ifNotEmpty: [ "because we may already have the researched user, we look by ID in the model"
1✔
1713
                                                                      userId := searchResult first at: #id.
1✔
1714
                                                                      (self glhModel allWithType: GLHUser)
1✔
1715
                                                                              detect: [ :user | user id = userId ]
1✔
1716
                                                                              ifNone: [ self importUser: userId ] ] ] ].
1✔
1717

1✔
1718
        self userCatalogue addUser: resultUser withName: anUsername.
1✔
1719

1✔
1720
        ^ resultUser
1✔
1721
]
1✔
1722

1✔
1723
{ #category : #initialization }
1✔
1724
GitlabModelImporter >> initReader [
1✔
1725
        
1✔
1726
        "add specific reader for this importer here"
1✔
1727
        super initReader
1✔
1728
]
1✔
1729

1✔
1730
{ #category : #initialization }
1✔
1731
GitlabModelImporter >> initialize [
1✔
1732

1✔
1733
        super initialize.
1✔
1734
        withCommitDiffs := true.
1✔
1735
        withInitialCommits := false.
1✔
1736
        withInitialMergeRequest := false.
1✔
1737

1✔
1738
        self withCommitsSince: 1 week.
1✔
1739

1✔
1740
        
1✔
1741
]
1✔
1742

1✔
1743
{ #category : #private }
1✔
1744
GitlabModelImporter >> isServerError: aString [
1✔
1745
        ^ aString = '{"message":"500 Internal Server Error"}'
1✔
1746
]
1✔
1747

1✔
1748
{ #category : #'import - projects' }
1✔
1749
GitlabModelImporter >> loadAllProjectsFromRepositorySoftware [
1✔
1750
        "heavy import that load all the active project inside the model. Only import the project entities"
1✔
1751
        |projects|
1✔
1752
        
1✔
1753
        projects := self repoApi projects. 
1✔
1754
]
1✔
1755

1✔
1756
{ #category : #'private - parsing' }
1✔
1757
GitlabModelImporter >> newParseCommitResult: result [
1✔
1758

1✔
1759
        generalReader  on: result readStream.
1✔
1760

1✔
1761
        ^ generalReader nextAs: GLHCommit
1✔
1762
]
1✔
1763

1✔
1764
{ #category : #'private - parsing' }
1✔
1765
GitlabModelImporter >> newParseDiffResult: result [
1✔
1766

1✔
1767
        generalReader on: result readStream.
1✔
1768
        ^ generalReader nextAs: #ArrayOfDiff
1✔
1769
]
1✔
1770

1✔
1771
{ #category : #'private - parsing' }
1✔
1772
GitlabModelImporter >> parseArrayOfProject: arrayOfProjects [
1✔
1773

1✔
1774
        | reader |
1✔
1775
        reader := generalReader on: arrayOfProjects readStream.
1✔
1776
        
1✔
1777
        ^ reader nextAs: #ArrayOfProject
1✔
1778
]
1✔
1779

1✔
1780
{ #category : #'private - parsing' }
1✔
1781
GitlabModelImporter >> parseBranchesResult: result [
1✔
1782

1✔
1783
        | reader |
1✔
1784
        reader := generalReader on: result readStream.
1✔
1785

1✔
1786
        ^ reader nextAs: #ArrayOfBranch
1✔
1787
]
1✔
1788

1✔
1789
{ #category : #'private - parsing' }
1✔
1790
GitlabModelImporter >> parseBranchesResult: result ofProject: aGLHProject [
1✔
1791

1✔
1792
        | reader |
1✔
1793
        self flag: 'WARNING: do not use the importer inside a parsing process. do it after using a object cached on the sub elemnt id'.
1✔
1794
        self
1✔
1795
                deprecated: 'Use parseBranchesResult: instead of current one'
1✔
1796
                on: '23 September 2025'
1✔
1797
                in:
1✔
1798
                'Pharo-12.0.0+SNAPSHOT.build.1571.sha.cf5fcd22e66957962c97dffc58b0393b7f368147 (64 Bit)'.
1✔
1799

1✔
1800

1✔
1801
        reader := NeoJSONReader on: result readStream.
1✔
1802
        reader mapInstVarsFor: GLHBranch.
1✔
1803

1✔
1804
        reader for: GLHBranch do: [ :mapping |
1✔
1805
                mapping
1✔
1806
                        mapProperty: #commit
1✔
1807
                        getter: [  ]
1✔
1808
                        setter: [ :branch :rawCommit |
1✔
1809
                                branch sha: (rawCommit at: #id)
1✔
1810
                                "commit := self
1✔
1811
                                                  importCommit: (rawCommit at: #id)
1✔
1812
                                                  ofProject: aGLHProject.
1✔
1813
                                branch commits add: commit unless: self blockOnIdEquality " ] ].
1✔
1814

1✔
1815
        reader
1✔
1816
                for: #ArrayOfBranch
1✔
1817
                customDo: [ :customMappting |
1✔
1818
                customMappting listOfElementSchema: GLHBranch ].
1✔
1819

1✔
1820
        ^ reader nextAs: #ArrayOfBranch
1✔
1821
]
1✔
1822

1✔
1823
{ #category : #'private - parsing' }
1✔
1824
GitlabModelImporter >> parseCommitResult: result [
1✔
1825

1✔
1826
        | reader |
1✔
1827
        reader := generalReader on: result readStream.
1✔
1828

1✔
1829
        ^ reader nextAs: GLHCommit
1✔
1830
]
1✔
1831

1✔
1832
{ #category : #'private - parsing' }
1✔
1833
GitlabModelImporter >> parseCommitsResult: result [
1✔
1834

1✔
1835
        | reader |
1✔
1836
        reader := generalReader on: result readStream.
1✔
1837

1✔
1838
        ^ reader nextAs: #ArrayOfCommit
1✔
1839
]
1✔
1840

1✔
1841
{ #category : #private }
1✔
1842
GitlabModelImporter >> parseDiffResult: result [
1✔
1843

1✔
1844
        | reader |
1✔
1845
        self
1✔
1846
                deprecated: 'Use #newParseDiffResult: instead'
1✔
1847
                on: '28 June 2024'
1✔
1848
                in:
1✔
1849
                'Pharo-11.0.0+build.726.sha.aece1b5473acf3830a0e082c1bc3a15d4ff3522b (64 Bit)'.
1✔
1850
        reader := NeoJSONReader on: result readStream.
1✔
1851
        reader for: GLHDiff do: [ :mapping |
1✔
1852
                mapping mapInstVars:
1✔
1853
                        #( deleted_file new_file new_path old_path renamed_file ).
1✔
1854
                mapping mapInstVar: #diffString to: #diff ].
1✔
1855

1✔
1856
        reader
1✔
1857
                for: #ArrayOfDiffs
1✔
1858
                customDo: [ :customMappting |
1✔
1859
                customMappting listOfElementSchema: GLHDiff ].
1✔
1860
        ^ reader nextAs: #ArrayOfDiffs
1✔
1861
]
1✔
1862

1✔
1863
{ #category : #'private - parsing' }
1✔
1864
GitlabModelImporter >> parseFileTreeResult: aResult [
1✔
1865

1✔
1866
        | reader |
1✔
1867
        reader := NeoJSONReader on: aResult readStream.
1✔
1868
        reader mapInstVarsFor: GLHApiFile.
1✔
1869
        reader
1✔
1870
                for: #ArrayOfFile
1✔
1871
                customDo: [ :customMappting | 
1✔
1872
                customMappting listOfElementSchema: GLHApiFile ].
1✔
1873
        ^ reader nextAs: #ArrayOfFile
1✔
1874
]
1✔
1875

1✔
1876
{ #category : #'private - parsing' }
1✔
1877
GitlabModelImporter >> parseGroupResult: aResult [
1✔
1878

1✔
1879
        | reader |
1✔
1880
        reader := generalReader on: aResult readStream.
1✔
1881

1✔
1882
        ^ reader nextAs: GLHGroup
1✔
1883
]
1✔
1884

1✔
1885
{ #category : #'private - parsing' }
1✔
1886
GitlabModelImporter >> parseJobsResult: result [ 
1✔
1887
        | reader |
1✔
1888
        reader := generalReader on: result readStream.
1✔
1889

1✔
1890
        ^ reader nextAs: #ArrayOfJob
1✔
1891
]
1✔
1892

1✔
1893
{ #category : #'private - parsing' }
1✔
1894
GitlabModelImporter >> parseJobsResult: result ofProject: aProject [
1✔
1895

1✔
1896
        | reader |
1✔
1897
        self
1✔
1898
                deprecated: 'Use parseJobsResult: instead of current one'
1✔
1899
                on: '23 September 2025'
1✔
1900
                in:
1✔
1901
                'Pharo-12.0.0+SNAPSHOT.build.1571.sha.cf5fcd22e66957962c97dffc58b0393b7f368147 (64 Bit)'.
1✔
1902
                
1✔
1903
        reader := generalReader on: result readStream.
1✔
1904
        reader for: GLHJob do: [ :mapping |
1✔
1905
                mapping
1✔
1906
                        mapProperty: #commit
1✔
1907
                        getter: [ :object | #ignore ]
1✔
1908
                        setter: [ :object :value |
1✔
1909
                                value ifNotNil: [
1✔
1910
                                        object commit:
1✔
1911
                                                (self importCommit: (value at: #id) ofProject: aProject) ] ] ].
1✔
1912

1✔
1913

1✔
1914
        ^ reader nextAs: #ArrayOfJob
1✔
1915
]
1✔
1916

1✔
1917
{ #category : #'private - parsing' }
1✔
1918
GitlabModelImporter >> parseMergeRequestsResult: result [
1✔
1919

1✔
1920
        generalReader on: result readStream.
1✔
1921
        ^ generalReader nextAs: #ArrayOfMergeRequest
1✔
1922
]
1✔
1923

1✔
1924
{ #category : #'private - parsing' }
1✔
1925
GitlabModelImporter >> parseNoteJson: results [
1✔
1926

1✔
1927
        | reader |
1✔
1928
        "Créer un lecteur JSON"
1✔
1929
        reader := generalReader on: results readStream.
1✔
1930

1✔
1931
        "Corriger la conversion des dates"
1✔
1932
        "reader for: DateAndTime customDo: [ :mapping |
1✔
1933
                mapping decoder: [ :string |
1✔
1934
                        DateAndTime readFrom: string readStream ] ]."
1✔
1935

1✔
1936
        
1✔
1937
        ^ reader nextAs: #ArrayOfNote
1✔
1938
]
1✔
1939

1✔
1940
{ #category : #'private - parsing' }
1✔
1941
GitlabModelImporter >> parsePipelineResult: result [
1✔
1942

1✔
1943
        | reader |
1✔
1944
        
1✔
1945
        (result includesSubstring: '{"message":"40' )ifTrue: [ ^ {  } ].
1✔
1946
        
1✔
1947
        reader := generalReader on: result readStream.
1✔
1948
        
1✔
1949
        ^ reader nextAs: GLHPipeline
1✔
1950
]
1✔
1951

1✔
1952
{ #category : #'private - parsing' }
1✔
1953
GitlabModelImporter >> parsePipelinesResult: result [
1✔
1954

1✔
1955
        | reader |
1✔
1956
        (result includesSubstring: '{"message":"40') ifTrue: [ ^ {  } ].
1✔
1957

1✔
1958
        reader := generalReader on: result readStream.
1✔
1959

1✔
1960
        ^ reader nextAs: #ArrayOfPipeline
1✔
1961
]
1✔
1962

1✔
1963
{ #category : #'private - parsing' }
1✔
1964
GitlabModelImporter >> parseProjectResult: aResult [
1✔
1965

1✔
1966
        | reader |
1✔
1967
        reader := generalReader on: aResult readStream.
1✔
1968

1✔
1969
        ^ reader nextAs: GLHProject
1✔
1970
]
1✔
1971

1✔
1972
{ #category : #'private - parsing' }
1✔
1973
GitlabModelImporter >> parseReleaseResult: result [
1✔
1974
        |reader|
1✔
1975
        reader := generalReader on: result readStream.
1✔
1976
        
1✔
1977
        ^ reader nextAs: GLHRelease 
1✔
1978
]
1✔
1979

1✔
1980
{ #category : #'private - parsing' }
1✔
1981
GitlabModelImporter >> parseReleasesResult: result [
1✔
1982

1✔
1983
        | reader |
1✔
1984
        reader := generalReader on: result readStream.
1✔
1985

1✔
1986
        ^ reader nextAs: #ArrayOfRelease
1✔
1987
]
1✔
1988

1✔
1989
{ #category : #'private - parsing' }
1✔
1990
GitlabModelImporter >> parseSubGroupResult: aResult [
1✔
1991

1✔
1992
        | reader |
1✔
1993
        reader := generalReader on: aResult readStream.
1✔
1994
        
1✔
1995
        ^ reader nextAs: #ArrayOfGroup
1✔
1996
]
1✔
1997

1✔
1998
{ #category : #'private - parsing' }
1✔
1999
GitlabModelImporter >> parseTagsResult: result [
1✔
2000
        |reader|
1✔
2001
        reader := generalReader on: result readStream.
1✔
2002
        
1✔
2003
        ^ reader nextAs: #ArrayOfTags
1✔
2004
]
1✔
2005

1✔
2006
{ #category : #'private - parsing' }
1✔
2007
GitlabModelImporter >> parseUserResult: result [
1✔
2008

1✔
2009
        | reader |
1✔
2010
        
1✔
2011
        reader := generalReader on: result readStream.
1✔
2012
        
1✔
2013
        ^ reader nextAs: GLHUser
1✔
2014

1✔
2015
        
1✔
2016

1✔
2017
]
1✔
2018

1✔
2019
{ #category : #'private - parsing' }
1✔
2020
GitlabModelImporter >> parseUsersResult: result [
1✔
2021

1✔
2022
        | reader |
1✔
2023
        
1✔
2024
        reader := generalReader on: result readStream.
1✔
2025
        
1✔
2026
        ^ reader nextAs: #ArrayOfUser
1✔
2027
        
1✔
2028
]
1✔
2029

1✔
2030
{ #category : #'import - projects' }
1✔
2031
GitlabModelImporter >> partiallyImportProject: aProjectID [
1✔
2032

1✔
2033
        | result projectResult |
1✔
2034
        ('Import project with id:  ' , aProjectID printString) recordInfo.
1✔
2035

1✔
2036
        (glhModel allWithType: GLHProject)
1✔
2037
                detect: [ :project | project id = aProjectID ]
1✔
2038
                ifFound: [ :project | ^ project ].
1✔
2039

1✔
2040
        result := self repoApi projects get: aProjectID.
1✔
2041
        projectResult := self parseProjectResult: result.
1✔
2042

1✔
2043
        projectResult repository: GLHRepository new.
1✔
2044
        self glhModel add: projectResult repository.
1✔
2045
        self completeImportsOfRepository: projectResult repository.
1✔
2046

1✔
2047
        ^ projectResult
1✔
2048
]
1✔
2049

1✔
2050
{ #category : #'import - pipelines' }
1✔
2051
GitlabModelImporter >> pipelinesOf: aProjectID after: after andBefore: before [
1✔
2052

1✔
2053
        | result |
1✔
2054
        ('Search pipelines of: ' , aProjectID printString) recordInfo.
1✔
2055
        
1✔
2056
        result := self repoApi pipelines getAllInProject: aProjectID 
1✔
2057
                                                                                                withParams: {        #updated_before -> before.
1✔
2058
                                                                                                                                        #updated_after -> after} asDictionary .
1✔
2059
        result isString ifTrue: [ ^ self parsePipelinesResult: result ].
1✔
2060

1✔
2061
        ^ (result collect: [ :pipelinesJson |
1✔
2062
                           self parsePipelinesResult: pipelinesJson ]) flattened
1✔
2063
]
1✔
2064

1✔
2065
{ #category : #'import - pipelines' }
1✔
2066
GitlabModelImporter >> pipelinesOf: aProjectID withLimit: aLimit [
1✔
2067

1✔
2068
        | result |
1✔
2069
        ('Search pipelines of: ' , aProjectID printString) recordInfo.
1✔
2070
        result := self repoApi pipelines getByPage: 1 perPage: aLimit inProject: aProjectID.
1✔
2071
        result isString ifTrue: [ ^ self parsePipelinesResult: result ].
1✔
2072

1✔
2073
        ^ (result collect: [ :pipelinesJson |
1✔
2074
                           self parsePipelinesResult: pipelinesJson ]) flattened
1✔
2075
]
1✔
2076

1✔
2077
{ #category : #accessing }
1✔
2078
GitlabModelImporter >> repoApi: anObject [
1✔
2079
        super repoApi: anObject.
1✔
2080
        self repoApi output: 'json'
1✔
2081
]
1✔
2082

1✔
2083
{ #category : #'search - merge request' }
1✔
2084
GitlabModelImporter >> searchMergeRequestMentionning: aString [ 
1✔
2085
        |mergeRequests results|
1✔
2086
        results := repoApi mergeRequests search: aString.
1✔
2087
        mergeRequests := self parseMergeRequestsResult: results.
1✔
2088
        mergeRequests :=        mergeRequests collect: [ :mr |
1✔
2089
                mr project: (self importProject: mr project_id).
1✔
2090
                mr
1✔
2091
                 ].
1✔
2092
        
1✔
2093
        ^ glhModel addAll: mergeRequests unless: self blockOnIdEquality. 
1✔
2094
]
1✔
2095

1✔
2096
{ #category : #private }
1✔
2097
GitlabModelImporter >> selectEntityType: aType overAttribut: aSelector equalTo: value [
1✔
2098

1✔
2099
        ^ (self glhModel allWithType: aType)
1✔
2100
                select: [ :entity | (entity perform: aSelector) = value ]
1✔
2101
]
1✔
2102

1✔
2103
{ #category : #'import - groups' }
1✔
2104
GitlabModelImporter >> subGroupsOf: aGroupID [
1✔
2105

1✔
2106
        | results subgroups |
1✔
2107
        ('Search subgroup of: ' , aGroupID printString) recordInfo.
1✔
2108
        results := self repoApi groups subgroupsOf: aGroupID.
1✔
2109
        subgroups := (results collect: [ :subgroupsJson | self parseSubGroupResult: subgroupsJson ]) flattened.
1✔
2110
        
1✔
2111
        ^ subgroups
1✔
2112
]
1✔
2113

1✔
2114
{ #category : #accessing }
1✔
2115
GitlabModelImporter >> withInitialCommits: boolean [
1✔
2116
        withInitialCommits := boolean 
1✔
2117
]
1✔
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

© 2026 Coveralls, Inc