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

moosetechnology / GitProjectHealth / 17940792567

23 Sep 2025 08:54AM UTC coverage: 72.789% (-0.6%) from 73.342%
17940792567

Pull #233

github

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

408 of 676 new or added lines in 18 files covered. (60.36%)

57 existing lines in 6 files now uncovered.

18768 of 25784 relevant lines covered (72.79%)

0.73 hits per line

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

90.88
/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.
×
94
        self importRepository: 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 - pipelines' }
124
GitlabModelImporter >> completeImportedPipeline: aGLHPipeline [ 
×
125
        |result parsedResult|
×
126
        
×
127
        aGLHPipeline duration ifNotNil: [ ^ aGLHPipeline ].
×
128
        
×
129
        result := self repoApi pipelines get: aGLHPipeline id inProject: aGLHPipeline project id. 
×
130
        parsedResult := self parsePipelineResult: result. 
×
131
        
×
132
        "aGLHPipeline methods".
×
133
        { #'created_at:' . #'status:' . #'finished_at:' . #'duration:' . #'started_at:' . #'updated_at:' . #'ref:' } do: [ :m |
×
134
                aGLHPipeline perform: m asSymbol with: (parsedResult perform: (m withoutSuffix: ':') asSymbol )
×
135
                 ].
×
136
        
×
137
        parsedResult cacheAt: #userID ifPresent: [:id |
×
138
                aGLHPipeline user: (self importUser: id). 
×
139
                ].
×
140
        
×
141
        ^ aGLHPipeline. 
×
142
]
×
143

144
{ #category : #'import - pipelines' }
145
GitlabModelImporter >> completeImportedPipelines: aCollectionOfGLHPipeline [
×
146
        ^ aCollectionOfGLHPipeline collect: [ :pipeline | self completeImportedPipeline: pipeline ].  
×
147
]
×
148

149
{ #category : #'import - projects' }
150
GitlabModelImporter >> completeImportedProject: aGLHProject [
1✔
151

1✔
152
        | importedProject |
1✔
153
        ('Complete import of project: ' , aGLHProject id printString)
1✔
154
                recordInfo.
1✔
155
        aGLHProject repository ifNotNil: [ ^ aGLHProject ].
1✔
156

1✔
157
        importedProject := self glhModel
1✔
158
                                   add: aGLHProject
1✔
159
                                   unless: self blockOnIdEquality.
1✔
160

1✔
161
        self importLatestPipelinesOfProject: importedProject.
1✔
162

1✔
163
        "aGLHProject creator: (self importUser: aGLHProject creator_id)."
1✔
164

1✔
165
        (self importUser: importedProject creator_id) addCreatedProject:
1✔
166
                importedProject.
1✔
167

1✔
168
        
1✔
169
        importedProject repository: GLHRepository new.
1✔
170
        self glhModel add: importedProject repository.
1✔
171
        self importRepository: importedProject repository.
1✔
172
        
1✔
173

1✔
174
        withInitialMergeRequest ifTrue: [
1✔
175
                self
1✔
176
                        importMergeRequestsOfProject: importedProject
1✔
177
                        since: DateAndTime today
1✔
178
                        until: DateAndTime now ].
1✔
179

1✔
180
        ^ importedProject
1✔
181
        
1✔
182

1✔
183
]
1✔
184

185
{ #category : #'private - configure reader' }
186
GitlabModelImporter >> configureReaderForBranch: reader [
1✔
187

1✔
188
        super configureReaderForBranch: reader.
1✔
189
        
1✔
190
                reader for: GLHBranch do: [ :mapping |
1✔
191
                mapping
1✔
192
                        mapProperty: #commit
1✔
193
                        getter: [  ]
1✔
194
                        setter: [ :branch :rawCommit | branch sha: (rawCommit at: #id) ] ].
1✔
195
]
1✔
196

197
{ #category : #'private - configure reader' }
198
GitlabModelImporter >> configureReaderForCommit: reader [
1✔
199

1✔
200
        super configureReaderForCommit: reader.
1✔
201
        
1✔
202
        reader for: GLHCommit do: [ :mapping |
1✔
203
                mapping mapInstVars:
1✔
204
                        #( id short_id title author_name author_email committer_name
1✔
205
                           committer_email message web_url ).
1✔
206
                (mapping mapInstVar: #authored_date) valueSchema: DateAndTime.
1✔
207
                (mapping mapInstVar: #committed_date) valueSchema: DateAndTime.
1✔
208
                (mapping mapInstVar: #created_at) valueSchema: DateAndTime.
1✔
209
                (mapping mapInstVar: #parent_ids) valueSchema: #ArrayOfIds.
1✔
210
                mapping
1✔
211
                        mapProperty: 'stats'
1✔
212
                        getter: [ :el | "Not used" ]
1✔
213
                        setter: [ :commit :value |
1✔
214
                                commit deletions: (value at: #deletions).
1✔
215
                                commit additions: (value at: #additions) ] ].
1✔
216

1✔
217
        reader for: DateAndTime customDo: [ :mapping |
1✔
218
                mapping decoder: [ :string | DateAndTime fromString: string ] ].
1✔
219

1✔
220
        reader
1✔
221
                for: #ArrayOfIds
1✔
222
                customDo: [ :mapping | mapping decoder: [ :string | string ] ].
1✔
223

1✔
224

1✔
225
]
1✔
226

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

1✔
230
        super configureReaderForDiff: reader.
1✔
231
        reader
1✔
232
                for: GLHDiff
1✔
233
                do: [ :mapping | 
1✔
234
                        "mapping mapInstVars:
1✔
235
                        #( deleted_file new_file new_path old_path renamed_file )."
1✔
236
                        mapping mapInstVar: #diffString to: #diff ].
1✔
237

1✔
238
        ^ reader
1✔
239
]
1✔
240

241
{ #category : #'private - configure reader' }
242
GitlabModelImporter >> configureReaderForGroup: reader [
1✔
243

1✔
244
        reader for: GLHGroup do: [ :mapping |
1✔
245
                mapping mapInstVars.
1✔
246
                (mapping mapInstVar: #projects) valueSchema: #ArrayOfProjects ].
1✔
247
        reader mapInstVarsFor: GLHProject.
1✔
248
        reader
1✔
249
                for: #ArrayOfProjects
1✔
250
                customDo: [ :customMappting |
1✔
251
                customMappting listOfElementSchema: GLHProject ].
1✔
252
        reader
1✔
253
                for: #ArrayOfGroups
1✔
254
                customDo: [ :customMappting |
1✔
255
                customMappting listOfElementSchema: GLHGroup ]
1✔
256
]
1✔
257

258
{ #category : #'private - configure reader' }
259
GitlabModelImporter >> configureReaderForMergeRequest: reader [
1✔
260
        "declare quil y a un array a mapper"
1✔
261

1✔
262
        reader for: #ArrayOfMergeRequest customDo: [ :customMappting |
1✔
263
                customMappting listOfElementSchema: GLHMergeRequest ].
1✔
264

1✔
265
        "declare la liste des properties"
1✔
266
        reader for: GLHMergeRequest do: [ :mapping |
1✔
267
                mapping mapInstVars:
1✔
268
                        #( blocking_discussions_resolved changes_count description
1✔
269
                           detailed_merge_status discussion_locked downvotes draft first_deployed_to_production_at
1✔
270
                           force_remove_source_branch has_conflicts id iid labels latest_build_finished_at
1✔
271
                           latest_build_started_at merge_commit_sha merge_status
1✔
272
                           merge_when_pipeline_succeeds merged_at milestone project_id
1✔
273
                           reference references_full references_relative
1✔
274
                           references_short sha should_remove_source_branch
1✔
275
                           source_branch source_project_id squash squash_commit_sha
1✔
276
                           squash_on_merge state subscribed target_branch target_project_id
1✔
277
                           task_completion_status_completed_count
1✔
278
                           task_completion_status_count time_stats_human_time_estimate
1✔
279
                           time_stats_human_total_time_spent
1✔
280
                           time_stats_time_estimate time_stats_total_time_spent
1✔
281
                           title updated_at upvotes user_notes_count web_url work_in_progress ).
1✔
282
                (mapping mapInstVar: #created_at) valueSchema: DateAndTime.
1✔
283
                (mapping mapInstVar: #updated_at) valueSchema: DateAndTime.
1✔
284
                (mapping mapInstVar: #merged_at) valueSchema: DateAndTime.
1✔
285
                (mapping mapInstVar: #closed_at) valueSchema: DateAndTime.
1✔
286
                "(mapping mapInstVar: #assignee) valueSchema: GLHUser."
1✔
287
                mapping
1✔
288
                        mapProperty: #author
1✔
289
                        getter: [  ]
1✔
290
                        setter: [ :object :value |
1✔
291
                        object cacheAt: #authorID put: (value at: #id) ].
1✔
292
                mapping
1✔
293
                        mapProperty: #merge_user
1✔
294
                        getter: [  ]
1✔
295
                        setter: [ :object :value | 
1✔
296
                                value ifNotNil: [
1✔
297
                                        object cacheAt: #mergeUserID put: (value at: #id) ] ] ].
1✔
298

1✔
299
        "(mapping mapInstVar: #closed_by) valueSchema: GLHUser.
1✔
300
        (mapping mapInstVar: #mergeCommit) valueSchema: GLHCommit."
1✔
301
        "indique ce que doit faire le reader lorsqu'il parse une DateAndTime object"
1✔
302
        reader for: DateAndTime customDo: [ :mapping |
1✔
303
                mapping decoder: [ :string |
1✔
304
                        string ifNil: [ nil ] ifNotNil: [ DateAndTime fromString: string ] ] ]
1✔
305
]
1✔
306

307
{ #category : #'private - configure reader' }
308
GitlabModelImporter >> configureReaderForPipeline: reader [
1✔
309

1✔
310
        reader mapInstVarsFor: GLHPipeline.
1✔
311
        
1✔
312
        reader for: GLHPipeline do: [ :mapping |
1✔
313

1✔
314
                mapping
1✔
315
                        mapProperty: #created_at
1✔
316
                        getter: [ :object | #ignore ]
1✔
317
                        setter: [ :object :value |
1✔
318
                        object created_at: (value ifNotNil: [DateAndTime fromString: value]).
1✔
319
                        object runDate: (value ifNotNil: [DateAndTime fromString: value]) ].
1✔
320
                
1✔
321
                mapping
1✔
322
                        mapProperty: #updated_at
1✔
323
                        getter: [ :object | #ignore ]
1✔
324
                        setter: [ :object :value |
1✔
325
                        object updated_at: (value ifNotNil: [DateAndTime fromString: value]).
1✔
326
                        ].
1✔
327
                
1✔
328
                mapping
1✔
329
                        mapProperty: #finished_at
1✔
330
                        getter: [ :object | #ignore ]
1✔
331
                        setter: [ :object :value |
1✔
332
                                object finished_at: (value ifNotNil: [DateAndTime fromString: value]).
1✔
333
                        ].
1✔
334
                
1✔
335
                mapping
1✔
336
                        mapProperty: #started_at  
1✔
337
                        getter: [ :object | #ignore ]
1✔
338
                        setter: [ :object :value |
1✔
339
                        object started_at: (value ifNotNil: [DateAndTime fromString: value]).
1✔
340
                        ].
1✔
341
                
1✔
342
                mapping
1✔
343
                        mapProperty: #source
1✔
344
                        getter: [ :object | #ignore ]
1✔
345
                        setter: [ :object :value |
1✔
346
                        object sourceEvent: value.
1✔
347
                        ].
1✔
348
                
1✔
349
                mapping
1✔
350
                        mapProperty: #duration
1✔
351
                        getter: [ :object | #ignore ]
1✔
352
                        setter: [ :object :value |
1✔
353
                        object duration: (value ifNotNil: [value asDuration]) .
1✔
354
                        ].
1✔
355
                
1✔
356
                mapping
1✔
357
                        mapProperty: #user
1✔
358
                        getter: [ :object | #ignore ]
1✔
359
                        setter: [ :object :value |
1✔
360
                        value ifNotNil: [object cacheAt: #userID put: (value at: #id)].
1✔
361
                        ].
1✔
362
                
1✔
363
                 ].
1✔
364
        
1✔
365
        reader
1✔
366
                for: #ArrayOfPipelines
1✔
367
                customDo: [ :customMappting |
1✔
368
                customMappting listOfElementSchema: GLHPipeline ].
1✔
369
]
1✔
370

371
{ #category : #'private - configure reader' }
372
GitlabModelImporter >> configureReaderForRelease: reader [
1✔
373

1✔
374
        reader mapInstVarsFor: GLHRelease .
1✔
375
        
1✔
376
        
1✔
377
        reader for: GLHRelease do: [ :mapping |
1✔
378
                        
1✔
379
                (mapping mapInstVar: #author) valueSchema: GLHUser .
1✔
380
                 ].
1✔
381
        
1✔
382
        
1✔
383
        reader
1✔
384
                for: #ArrayOfReleases
1✔
385
                customDo: [ :customMappting |
1✔
386
                customMappting listOfElementSchema: GLHRelease ].
1✔
387
]
1✔
388

389
{ #category : #'private - configure reader' }
390
GitlabModelImporter >> configureReaderForTag: reader [
1✔
391

1✔
392
        reader mapInstVarsFor: GLHTag .
1✔
393
        
1✔
394
        reader for: GLHTag do: [ :mapping |
1✔
395
                
1✔
396
                (mapping mapInstVar: #commit) valueSchema: GLHCommit .
1✔
397
"                (mapping mapInstVar: #release) valueSchema: GLHRelease ."
1✔
398
                (mapping mapInstVar: #created_at) valueSchema: DateAndTime .
1✔
399
                
1✔
400
                mapping
1✔
401
                        mapProperty: #release
1✔
402
                        getter: [ :object | #ignore ]
1✔
403
                        setter: [ :object :value |
1✔
404
                        object release: (value ifNotNil: [ GLHRelease new description: (value at:#description); tag_name: (value at: #tag_name); yourself ]).
1✔
405
                        ].
1✔
406
                 ].
1✔
407
        
1✔
408
        reader
1✔
409
                for: #ArrayOfTags
1✔
410
                customDo: [ :customMappting |
1✔
411
                customMappting listOfElementSchema: GLHTag ].
1✔
412
]
1✔
413

1✔
414
{ #category : #'private - configure reader' }
1✔
415
GitlabModelImporter >> configureReaderForUser: reader [
1✔
416

1✔
417
        reader mapInstVarsFor: GLHUser.
1✔
418

1✔
419
        reader
1✔
420
                for: #ArrayOfUser
1✔
421
                customDo: [ :customMappting |
1✔
422
                customMappting listOfElementSchema: GLHUser ].
1✔
423

1✔
424
]
1✔
425

1✔
426
{ #category : #private }
1✔
427
GitlabModelImporter >> convertApiFileAsFile: aAPIFile [
1✔
428

1✔
429
        aAPIFile type = 'tree' ifTrue: [ 
1✔
430
                ^ GLHFileDirectory new
1✔
431
                          name: aAPIFile name;
1✔
432
                          yourself ].
1✔
433
        ^ GLHFileBlob new
1✔
434
                  name: aAPIFile name;
1✔
435
                  yourself
1✔
436
]
1✔
437

1✔
438
{ #category : #private }
1✔
439
GitlabModelImporter >> detectEntityType: aType overAttribut: aSelector equalTo: value [
1✔
440

1✔
441
        ^ (self glhModel allWithType: aType) detect: [ :entity |
1✔
442
                  (entity perform: aSelector) = value ] ifNone: [ nil ]. 
1✔
443
]
1✔
444

1✔
445
{ #category : #accessing }
1✔
446
GitlabModelImporter >> glhApi [
1✔
447

1✔
448
        self
1✔
449
                deprecated: 'Use #repoApi instead'
1✔
450
                on: '7 October 2024'
1✔
451
                in:
1✔
452
                'Pharo-11.0.0+build.726.sha.aece1b5473acf3830a0e082c1bc3a15d4ff3522b (64 Bit)'.
1✔
453

1✔
454
        ^ repoApi
1✔
455
]
1✔
456

1✔
457
{ #category : #accessing }
1✔
458
GitlabModelImporter >> glhApi: anObject [
1✔
459

1✔
460
        self
1✔
461
                deprecated: 'Use #repoApi: instead'
1✔
462
                on: '7 October 2024'
1✔
463
                in:
1✔
464
                'Pharo-11.0.0+build.726.sha.aece1b5473acf3830a0e082c1bc3a15d4ff3522b (64 Bit)'.
1✔
465

1✔
466
        repoApi := anObject
1✔
467
]
1✔
468

1✔
469
{ #category : #accessing }
1✔
470
GitlabModelImporter >> glhModel [
1✔
471

1✔
472
        ^ glhModel
1✔
473
]
1✔
474

1✔
475
{ #category : #accessing }
1✔
476
GitlabModelImporter >> glhModel: anObject [
1✔
477

1✔
478
        glhModel := anObject
1✔
479
]
1✔
480

1✔
481
{ #category : #'import - users' }
1✔
482
GitlabModelImporter >> importActiveHumanUsers [
1✔
483

1✔
484
        | params result users |
1✔
485
        params := { 
1✔
486
                #humans -> 'true'.
1✔
487
                #active -> 'true'.
1✔
488
                #without_project_bots -> 'true'
1✔
489
        } asDictionary.
1✔
490
        result := self repoApi users allWithParams: params.
1✔
491
        users := (result collect: [ :usersJson | self parseUsersResult: usersJson ]) flattened.
1✔
492
        
1✔
493
        self glhModel
1✔
494
                                 addAll: users
1✔
495
                                 unless: self blockOnIdEquality.
1✔
496

1✔
497
        ^ users
1✔
498
]
1✔
499

1✔
500
{ #category : #'import - groups' }
1✔
501
GitlabModelImporter >> importAllGroups [
1✔
502

1✔
503
        | params results groups |
1✔
504
        
1✔
505
        params := { 
1✔
506
                        #top_level_only -> 'true'
1✔
507
        } asDictionary.
1✔
508
        results := self repoApi groups getAllWithParams: params.
1✔
509
        
1✔
510
        groups := (results collect: [ :groupsJson | generalReader
1✔
511
                                            on: groupsJson readStream;
1✔
512
                                            nextAs: #ArrayOfGroups. ]) flattened.
1✔
513
        ^ groups
1✔
514
]
1✔
515

1✔
516
{ #category : #'import - pipelines' }
1✔
517
GitlabModelImporter >> importAllPipelinesOfProject: aGLHProject [
1✔
518
        
1✔
519
        (self allPipelinesOf: aGLHProject id) do: [ :pipeline |
1✔
520
                | pip |
1✔
521
                pip := self glhModel add: pipeline unless: self blockOnIdEquality.
1✔
522
                pip := aGLHProject pipelines add: pip unless: self blockOnIdEquality.
1✔
523
                self completeImportedPipeline: pip ].
1✔
524

1✔
525
        ^ aGLHProject pipelines
1✔
526
]
1✔
527

1✔
528
{ #category : #'import - commits' }
1✔
529
GitlabModelImporter >> importAndLoadLatestsCommitsOfProject: aGLHProject [
1✔
530

1✔
531
        | commits completedProject |
1✔
532
        completedProject := self completeImportedProject: aGLHProject.
1✔
533
        commits := self importLatestCommitsOfProject: completedProject.
1✔
534
        commits do: [ :commit | self completeImportedCommit: commit ].
1✔
535
        self chainsCommitsFrom: commits.
1✔
536
        ^ commits
1✔
537
]
1✔
538

1✔
539
{ #category : #'import - users' }
1✔
540
GitlabModelImporter >> importAuthorOfCommit: aGLHCommit [
1✔
541

1✔
542
        | user |
1✔
543
                self
1✔
544
                deprecated: 'Use importCreatorOfCommit: instead of current one'
1✔
545
                on: '19 September 2025'
1✔
546
                in:
1✔
547
                'Pharo-12.0.0+SNAPSHOT.build.1571.sha.cf5fcd22e66957962c97dffc58b0393b7f368147 (64 Bit)'.
1✔
548

1✔
549
        
1✔
550
        user := self importUserByUsername: aGLHCommit author_name.
1✔
551
        aGLHCommit commitCreator: user.
1✔
552
        ^ user
1✔
553
]
1✔
554

1✔
555
{ #category : #'import - branches' }
1✔
556
GitlabModelImporter >> importBranchesOf: aGLHProject [
1✔
557

1✔
558
        | resultBranches branches foundBranches |
1✔
559
        "aGLHProject repository branches removeAll "
1✔
560
        resultBranches := self repoApi branches getAllFromProject:
1✔
561
                                  aGLHProject id.
1✔
562
        
1✔
563
        foundBranches := (resultBranches collect: [ :branchesJson |
1✔
564
                                  self
1✔
565
                                          parseBranchesResult: branchesJson
1✔
566
                                          ofProject: aGLHProject ]) flattened.
1✔
567

1✔
568
        'import the branches of project ' recordInfo.
1✔
569

1✔
570
        "WARNING: always add branch first into repository, than into model !"
1✔
571
        branches := aGLHProject repository branches
1✔
572
                            addAll: foundBranches
1✔
573
                            unless: self blockOnNameEquality.
1✔
574

1✔
575

1✔
576
        branches := self glhModel
1✔
577
                            addAll: branches
1✔
578
                            unless: self blockForBranchEquality.
1✔
579

1✔
580
        "WARNING : branch must load its HEAD commit (ref) in a second time "
1✔
581
        ^ branches
1✔
582
]
1✔
583

1✔
584
{ #category : #'import - commits' }
1✔
585
GitlabModelImporter >> importCommit: aCommitID ofProject: aGLHProject [
1✔
586

1✔
587
        | result parsedResult |
1✔
588
        (self glhModel allWithType: GLHCommit) asOrderedCollection
1✔
589
                detect: [ :commit | commit id = aCommitID ]
1✔
590
                ifFound: [ :commit | ^ commit ].
1✔
591

1✔
592
        result := self repoApi commits
1✔
593
                          get: aCommitID
1✔
594
                          inProject: aGLHProject id.
1✔
595

1✔
596
        parsedResult := self parseCommitResult: result.
1✔
597

1✔
598
        parsedResult := self glhModel
1✔
599
                                add: parsedResult
1✔
600
                                unless: self blockOnIdEquality.
1✔
601
        parsedResult := aGLHProject repository commits
1✔
602
                                add: parsedResult
1✔
603
                                unless: self blockOnIdEquality.
1✔
604

1✔
605
        self withCommitDiffs ifTrue: [ self importDiffOfCommit: parsedResult ].
1✔
606

1✔
607
        ^ parsedResult
1✔
608
]
1✔
609

1✔
610
{ #category : #'import - commits' }
1✔
611
GitlabModelImporter >> importCommitOfProject: anProject withId: anID [
1✔
612

1✔
613
        | commit result |
1✔
614
self
1✔
615
                deprecated: 'Use importCommit:ofProject: instead of current one'
1✔
616
                on: '27 August 2025'
1✔
617
                in: 'MSR 1.3.0 '
1✔
618
                transformWith: '`@rcv importCommitOfProject: `arg1 withId: `arg2' -> '`@rcv importCommit: `arg2 ofProject: `arg1'.
1✔
619
        anID ifNil: [ ^ nil ].
1✔
620

1✔
621
        ('looking for commit ' , anID printString , ' in project : '
1✔
622
         , anProject id printString) recordInfo.
1✔
623

1✔
624
        commit := (self
1✔
625
                           detectEntityType: GLHCommit
1✔
626
                           overAttribut: #id
1✔
627
                           equalTo: anID) ifNil: [
1✔
628
                          result := self repoApi commits
1✔
629
                                            get: anID
1✔
630
                                            inProject: anProject id.
1✔
631
                          commit := (self parseCommitsResult: '[' , result , ']')
1✔
632
                                            first.
1✔
633

1✔
634
                          commit := self glhModel
1✔
635
                                            add: commit
1✔
636
                                            unless: self blockOnIdEquality.
1✔
637
                          commit repository: anProject repository.
1✔
638

1✔
639
                          commit ].
1✔
640

1✔
641
        self withCommitDiffs ifTrue: [ self importDiffOfCommit: commit ].
1✔
642

1✔
643
        ^ commit
1✔
644
]
1✔
645

1✔
646
{ #category : #'import - commits' }
1✔
647
GitlabModelImporter >> importCommits: aGLHProject [
1✔
648
        "limited to the last 20 commits"
1✔
649

1✔
650
        | results parsedResults params |
1✔
651
        self
1✔
652
                deprecated:
1✔
653
                'Use importLatestCommitsOfProject: instead of current one'
1✔
654
                on: '19 September 2025'
1✔
655
                in:
1✔
656
                'Pharo-12.0.0+SNAPSHOT.build.1571.sha.cf5fcd22e66957962c97dffc58b0393b7f368147 (64 Bit)'.
1✔
657
                
1✔
658
        params := { (#with_stats -> 'true') } asDictionary.
1✔
659
        results := self repoApi commits
1✔
660
                           getByPage: 1
1✔
661
                           perPage: 20
1✔
662
                           inProject: aGLHProject id
1✔
663
                           withParams: params.
1✔
664

1✔
665
        parsedResults := self parseCommitsResult: results.
1✔
666
        self glhModel addAll: parsedResults unless: self blockOnIdEquality.
1✔
667

1✔
668
        parsedResults do: [ :commit |
1✔
669
                commit repository: aGLHProject repository ].
1✔
670

1✔
671
        self withCommitDiffs ifTrue: [
1✔
672
                parsedResults do: [ :commit | self importDiffOfCommit: commit ] ].
1✔
673

1✔
674
        ^ parsedResults
1✔
675
]
1✔
676

1✔
677
{ #category : #'import - commits' }
1✔
678
GitlabModelImporter >> importCommitsFollowing: aCommit upToDays: aNumberOfDay [
1✔
679
        "import the 'n' commits of a project starting from an initial 'aCommit' commit. 
1✔
680
        Lazy import does not import the entities inside the model"
1✔
681

1✔
682
        | date |
1✔
683
        date := aCommit created_at asDateAndTime.
1✔
684

1✔
685
        ^ self
1✔
686
                  importCommitsOfBranch: aCommit branch
1✔
687
                  since: date
1✔
688
                  until: date + aNumberOfDay day
1✔
689
]
1✔
690

1✔
691
{ #category : #'import - commits' }
1✔
692
GitlabModelImporter >> importCommitsFromTag: fromTag toTag: toTag [ 
1✔
693
        | results commits project|
1✔
694
                
1✔
695
        (fromTag isNil or: [ toTag isNil ] ) ifTrue: [ ^ OrderedCollection new.  ] .
1✔
696

1✔
697
        project := fromTag repository project.
1✔
698
        results := self repoApi repositories compareInProject: (project id) from: fromTag name to: toTag name.
1✔
699
        
1✔
700
        commits := (NeoJSONReader fromString: results ) at: #commits ifAbsent: ['[]'].
1✔
701
        
1✔
702
        
1✔
703
        commits := self parseCommitsResult: (NeoJSONWriter toString: commits).
1✔
704
         commits := glhModel addAll: commits unless: self blockOnIdEquality.
1✔
705
        commits := project repository commits addAll: commits unless: self blockOnIdEquality.
1✔
706
        
1✔
707
        self chainsCommitsFrom: commits. 
1✔
708
        
1✔
709
        ^ commits. 
1✔
710
        
1✔
711
]
1✔
712

1✔
713
{ #category : #'import - commits' }
1✔
714
GitlabModelImporter >> importCommitsOfBranch: aGLHBranch [
1✔
715

1✔
716
        | commits |
1✔
717
        "        result := self glhApi
1✔
718
                          commitsOfProject: aGLHBranch repository project id
1✔
719
                          forRefName: aGLHBranch name."
1✔
720
        commits := self
1✔
721
                           importCommitsOfBranch: aGLHBranch
1✔
722
                           since: withCommitsSince.
1✔
723

1✔
724
        self chainsCommitsFrom: commits.
1✔
725

1✔
726
        commits do: [ :aCommit |
1✔
727
                aCommit repository: aGLHBranch repository.
1✔
728
                self completeImportedCommit: aCommit ].
1✔
729
        ^ commits
1✔
730
]
1✔
731

1✔
732
{ #category : #'import - commits' }
1✔
733
GitlabModelImporter >> importCommitsOfBranch: aGLHBranch fromCommit: anInitialCommit [
1✔
734

1✔
735
        | commits |
1✔
736
        "        result := self glhApi
1✔
737
                          commitsOfProject: aGLHBranch repository project id
1✔
738
                          forRefName: aGLHBranch name."
1✔
739
        commits := self
1✔
740
                           importCommitsOfBranch: aGLHBranch
1✔
741
                           since: anInitialCommit committed_date.
1✔
742

1✔
743
        commits do: [ :aCommit |
1✔
744
                aCommit repository: aGLHBranch repository.
1✔
745
                self completeImportedCommit: aCommit ].
1✔
746
        ^ commits
1✔
747
]
1✔
748

1✔
749
{ #category : #'import - commits' }
1✔
750
GitlabModelImporter >> importCommitsOfBranch: aGLHBranch since: fromDate [
1✔
751

1✔
752
        ^ self importCommitsOfBranch: aGLHBranch since: fromDate until: nil
1✔
753
]
1✔
754

1✔
755
{ #category : #'import - commits' }
1✔
756
GitlabModelImporter >> importCommitsOfBranch: aGLHBranch since: fromDate until: toDate [
1✔
757

1✔
758
        | params result allCommits |
1✔
759
        params := {
1✔
760
                          (#ref_name -> aGLHBranch name).
1✔
761
                          (#since -> (fromDate
1✔
762
                                    ifNotNil: [ fromDate asDate asDateAndTime asString ]
1✔
763
                                    ifNil: [ '' ])).
1✔
764
                          (#until -> (toDate
1✔
765
                                    ifNotNil: [ toDate asDate asDateAndTime asString ]
1✔
766
                                    ifNil: [ '' ])).
1✔
767
                          (#with_stats -> 'true') } asDictionary.
1✔
768
        result := self repoApi commits
1✔
769
                          getAllInProject: aGLHBranch repository project id
1✔
770
                          withParams: params.
1✔
771

1✔
772
        allCommits := (result collect: [ :commitsJson |
1✔
773
                               self parseCommitsResult: commitsJson ]) flattened.
1✔
774

1✔
775
        aGLHBranch commits addAll: allCommits unless: self blockOnIdEquality.
1✔
776

1✔
777
        self glhModel
1✔
778
                addAll: aGLHBranch commits
1✔
779
                unless: self blockOnIdEquality.
1✔
780

1✔
781
        self chainsCommitsFrom: allCommits.
1✔
782

1✔
783
        ^ allCommits
1✔
784
]
1✔
785

1✔
786
{ #category : #'import - commits' }
1✔
787
GitlabModelImporter >> importCommitsOfBranch: aGLHBranch until: toDate [
1✔
788

1✔
789
        ^ self importCommitsOfBranch: aGLHBranch since: nil until: toDate
1✔
790
]
1✔
791

1✔
792
{ #category : #'import - commits' }
1✔
793
GitlabModelImporter >> importCommitsOfProject: aProject since: fromDate until: toDate [
1✔
794

1✔
795
        | params results allCommits |
1✔
796
        params := {
1✔
797
                          (#since
1✔
798
                           ->
1✔
799
                           (fromDate
1✔
800
                                    ifNotNil: [ fromDate asDate asDateAndTime asString ]
1✔
801
                                    ifNil: [ '' ])).
1✔
802
                          (#until
1✔
803
                           ->
1✔
804
                           (toDate
1✔
805
                                    ifNotNil: [ toDate asDate asDateAndTime asString ]
1✔
806
                                    ifNil: [ '' ])).
1✔
807
                          (#with_stats -> 'true').
1✔
808
                          (#all -> 'true') } asDictionary.
1✔
809
        results := self repoApi commits
1✔
810
                           getAllInProject: aProject id
1✔
811
                           withParams: params.
1✔
812

1✔
813
        allCommits := (results collect: [ :commitsJson |
1✔
814
                               self parseCommitsResult: commitsJson ]) flattened.
1✔
815

1✔
816
        allCommits:= aProject repository commits
1✔
817
                addAll: allCommits
1✔
818
                unless: self blockOnIdEquality.
1✔
819

1✔
820
        ^ self glhModel addAll: allCommits unless: self blockOnIdEquality
1✔
821
]
1✔
822

1✔
823
{ #category : #'import - commits' }
1✔
824
GitlabModelImporter >> importCommitsOfTag: aGLHTag [
1✔
825

1✔
826
        | taggedCommit tags commits date |
1✔
827
        self
1✔
828
                deprecated: 'Use importCommitsFromTag:toTag: instead of current one'
1✔
829
                on: '21 July 2025'
1✔
830
                in:
1✔
831
                'Pharo-12.0.0+SNAPSHOT.build.1571.sha.cf5fcd22e66957962c97dffc58b0393b7f368147 (64 Bit)'.
1✔
832
        
1✔
833
        
1✔
834
        tags := self importTagsForProject: aGLHTag repository project.
1✔
835

1✔
836

1✔
837
        taggedCommit := aGLHTag commit ifNil: [
1✔
838
                                self
1✔
839
                                        importCommit: aGLHTag target
1✔
840
                                        ofProject: aGLHTag repository project ].
1✔
841

1✔
842
        date := (tags isEmptyOrNil and: [ tags size < 2 ])
1✔
843
                        ifTrue: [ aGLHTag created_at ]
1✔
844
                        ifFalse: [ tags second commit committed_date ].
1✔
845

1✔
846
        commits := self
1✔
847
                           importParentCommitsOfCommit: taggedCommit
1✔
848
                           since: tags third created_at.
1✔
849
        commits add: taggedCommit.
1✔
850
        self chainsCommitsFrom: commits.
1✔
851

1✔
852
        ^ commits
1✔
853
]
1✔
854

1✔
855
{ #category : #'import - projects' }
1✔
856
GitlabModelImporter >> importContributedProjectsOfUser: aGLHUser [
1✔
857

1✔
858
        | remaningProjects params results projects projectsIds |
1✔
859
        params := {
1✔
860
                          (#order_by -> 'last_activity_at').
1✔
861
                          (#simple -> 'true') } asDictionary.
1✔
862
        results := self repoApi projects
1✔
863
                           contributedProjectsOfUser: aGLHUser id
1✔
864
                           withParams: params.
1✔
865

1✔
866
        projectsIds := (results collect: [ :projectsJson |
1✔
867
                             (NeoJSONReader fromString: projectsJson) collect: [:projectJson | projectJson at: #id ] ]) flattened.
1✔
868
        
1✔
869
        projects := self importProjects: projectsIds.
1✔
870
        remaningProjects := self importProjects:
1✔
871
                                    ((projects collect: #id) difference:
1✔
872
                                             ((self userCatalogue atId: aGLHUser id) at:
1✔
873
                                                      #contributedProjects)).
1✔
874

1✔
875

1✔
876
        aGLHUser contributedProjects
1✔
877
                addAll: projects , remaningProjects
1✔
878
                unless: self blockOnIdEquality.
1✔
879

1✔
880
        self userCatalogue
1✔
881
                addUser: aGLHUser
1✔
882
                withProjects: (aGLHUser contributedProjects collect: #id).
1✔
883

1✔
884
        ^ projects
1✔
885
]
1✔
886

1✔
887
{ #category : #'import - users' }
1✔
888
GitlabModelImporter >> importCreatorOfCommit: aCommit [
1✔
889

1✔
890
        aCommit commitCreator ifNil: [
1✔
891
                aCommit commitCreator:
1✔
892
                        (self importUserByUsername: aCommit author_name) ].
1✔
893
        self userCatalogue
1✔
894
                addUser: aCommit commitCreator
1✔
895
                withProject: aCommit repository project id.
1✔
896
        ^ aCommit commitCreator
1✔
897
]
1✔
898

1✔
899
{ #category : #'import - commits' }
1✔
900
GitlabModelImporter >> importDiffOfCommit: aCommit [
1✔
901

1✔
902
        | result diffsResult |
1✔
903
        aCommit diffs ifNotEmpty: [
1✔
904
                'Diff already importer: ' , aCommit short_id printString recordInfo.
1✔
905
                ^ aCommit diffs ].
1✔
906
        ('Import diff of commit: ' , aCommit short_id printString) recordInfo.
1✔
907

1✔
908
        result := self repoApi commits
1✔
909
                          diffOf: aCommit id
1✔
910
                          inProject: aCommit repository project id
1✔
911
                          uniDiff: true.
1✔
912

1✔
913
        (self isServerError: result) ifTrue: [ ^ {  } ].
1✔
914
        diffsResult := self newParseDiffResult: result.
1✔
915

1✔
916
        aCommit diffs addAll: diffsResult unless: self blockForDiffEquality.
1✔
917
        
1✔
918
        "changes are added into the model during the import"
1✔
919
        aCommit diffs do: [ :diff | self importDiffRangesForDiff: diff ].
1✔
920

1✔
921
        ^ aCommit diffs
1✔
922
]
1✔
923

1✔
924
{ #category : #'import - merge-requests' }
1✔
925
GitlabModelImporter >> importDiffOfMergeRequest: aMergeRequest [
1✔
926

1✔
927
        | result diffsResult |
1✔
928
        aMergeRequest diffs ifNotEmpty: [
1✔
929
                'Diff of already importer: '
1✔
930
                , aMergeRequest iid printString recordInfo.
1✔
931
                ^ aMergeRequest diffs ].
1✔
932
        ('Import diff commits of MR ' , aMergeRequest iid printString)
1✔
933
                recordInfo.
1✔
934
        result := self repoApi mergeRequests
1✔
935
                          diffsOf: aMergeRequest iid
1✔
936
                          inProject: aMergeRequest project_id.
1✔
937
        diffsResult := result flatCollect: [ :aResult |
1✔
938
                               self newParseDiffResult: aResult ].
1✔
939

1✔
940

1✔
941
        aMergeRequest diffs
1✔
942
                addAll: diffsResult
1✔
943
                unless: self blockForDiffEquality.
1✔
944
        self glhModel
1✔
945
                addAll: aMergeRequest diffs
1✔
946
                unless: self blockForDiffEquality.
1✔
947

1✔
948
        aMergeRequest diffs do: [ :diff | self importDiffRangesForDiff: diff ].
1✔
949

1✔
950
        ^ aMergeRequest diffs
1✔
951
]
1✔
952

1✔
953
{ #category : #'import - repositories' }
1✔
954
GitlabModelImporter >> importDirectoryFiles: aDirectoryFile OfBranch: aBranch [
1✔
955

1✔
956
        | result files apiFiles params |
1✔
957
        params := { 
1✔
958
                #ref -> aBranch name.
1✔
959
                #path -> (aDirectoryFile path , '/')
1✔
960
        } asDictionary.
1✔
961
        result := self repoApi repositories repositoryTreeOfProject: aBranch repository project id withParams: params.
1✔
962
                         " treeOfRepository: aBranch repository project id
1✔
963
                          ofBranch: aBranch name
1✔
964
                          andPath: aDirectoryFile path , '/'."
1✔
965
        apiFiles := (result collect: [ :treeJson | self parseFileTreeResult: treeJson ]) flattened.
1✔
966
        files := apiFiles collect: [ :apiFile |
1✔
967
                         self convertApiFileAsFile: apiFile ].
1✔
968
        
1✔
969
        files do: [ :file |
1✔
970
                self glhModel add: file.
1✔
971
                aDirectoryFile addFile: file ].
1✔
972
        
1✔
973
        files
1✔
974
                select: [ :file | file isKindOf: GLHFileDirectory ]
1✔
975
                thenCollect: [ :file |
1✔
976
                self importDirectoryFiles: file OfBranch: aBranch ]
1✔
977
]
1✔
978

1✔
979
{ #category : #'import - file' }
1✔
980
GitlabModelImporter >> importFileWithPath: aPath ofProject: aGLHProject inBranch: aBranch [ 
1✔
981
        self flag: 'imported file need need to be store inside the model'.
1✔
982
        ^ self repoApi repositories getRawFile: aPath ofProject: aGLHProject id withParams: {#ref -> aBranch name} asDictionary .
1✔
983
]
1✔
984

1✔
985
{ #category : #'import - repositories' }
1✔
986
GitlabModelImporter >> importFilesOfBranch: aBranch [
1✔
987

1✔
988
        | result files apiFiles params |
1✔
989
        params := { 
1✔
990
                #ref -> aBranch name.
1✔
991
        } asDictionary.
1✔
992
        
1✔
993
        result := self repoApi repositories repositoryTreeOfProject: aBranch repository project id withParams: params.
1✔
994
        
1✔
995
                          "treeOfRepository: aBranch repository project id
1✔
996
                          ofBranch: aBranch name
1✔
997
                          andPath: nil."
1✔
998
        apiFiles := (result collect: [ :filesJson | self parseFileTreeResult: filesJson  ]) flattened.
1✔
999
        files := apiFiles collect: [ :apiFile | 
1✔
1000
                         self convertApiFileAsFile: apiFile ].
1✔
1001
        files do: [ :file | 
1✔
1002
                self glhModel add: file.
1✔
1003
                aBranch addFile: file ].
1✔
1004
        files
1✔
1005
                select: [ :file | file isKindOf: GLHFileDirectory ]
1✔
1006
                thenCollect: [ :file | 
1✔
1007
                self importDirectoryFiles: file OfBranch: aBranch ].
1✔
1008
        
1✔
1009
   ^files. 
1✔
1010
]
1✔
1011

1✔
1012
{ #category : #'import - groups' }
1✔
1013
GitlabModelImporter >> importGroup: aGroupID [
1✔
1014

1✔
1015
        | result groupResult |
1✔
1016
        ('Import group: ' , aGroupID printString) recordInfo.
1✔
1017

1✔
1018
        result := self repoApi groups get: aGroupID.
1✔
1019
        
1✔
1020
        "group: aGroupID."
1✔
1021
        groupResult := self parseGroupResult: result.
1✔
1022
        groupResult := self addGroupResultToModel: groupResult.
1✔
1023

1✔
1024
        groupResult projects do: [ :project |
1✔
1025
                self completeImportedProject: project ].
1✔
1026

1✔
1027
        (self subGroupsOf: aGroupID) do: [ :subGroup |
1✔
1028
                
1✔
1029
                groupResult subGroups
1✔
1030
                        add: (self importGroup: subGroup id)
1✔
1031
                        unless: self blockOnIdEquality ].
1✔
1032
        ^ groupResult
1✔
1033
]
1✔
1034

1✔
1035
{ #category : #'import - jobs' }
1✔
1036
GitlabModelImporter >> importJobsOf: aPipeline [
1✔
1037

1✔
1038
        | jobs results |
1✔
1039
        results := self repoApi jobs
1✔
1040
                           getAllForPipeline: aPipeline id
1✔
1041
                           inProject: aPipeline project id.
1✔
1042
        "jobsOfProject: aPipeline project id
1✔
1043
                          ofPipelines: aPipeline id."
1✔
1044
        jobs := (results collect: [ :jobsJson |
1✔
1045
                         self parseJobsResult: jobsJson ofProject: aPipeline project ])
1✔
1046
                        flattened.
1✔
1047
        jobs do: [ :job | aPipeline addJob: job ].
1✔
1048
        self glhModel addAll: jobs.
1✔
1049

1✔
1050
        ^ jobs
1✔
1051
]
1✔
1052

1✔
1053
{ #category : #'import - commits' }
1✔
1054
GitlabModelImporter >> importLatestCommitsOfProject: aGLHProject [
1✔
1055
        "limited to the last 50 commits"
1✔
1056

1✔
1057
        | results parsedResults params |
1✔
1058
        params := { 
1✔
1059
                #with_stats -> 'true'.
1✔
1060
                #all -> true
1✔
1061
         } asDictionary.
1✔
1062
        results := self repoApi commits getByPage: 1 perPage: 50 inProject: aGLHProject id withParams: params.
1✔
1063

1✔
1064
        parsedResults := self parseCommitsResult: results.
1✔
1065
        parsedResults := self glhModel
1✔
1066
                                 addAll: parsedResults
1✔
1067
                                 unless: self blockOnIdEquality.
1✔
1068

1✔
1069
        aGLHProject repository commits
1✔
1070
                addAll: parsedResults
1✔
1071
                unless: self blockOnIdEquality.
1✔
1072

1✔
1073
        self withCommitDiffs ifTrue: [
1✔
1074
                parsedResults do: [ :commit | self importDiffOfCommit: commit ] ].
1✔
1075

1✔
1076
        ^ parsedResults
1✔
1077
]
1✔
1078

1✔
1079
{ #category : #'import - merge-requests' }
1✔
1080
GitlabModelImporter >> importLatestMergeRequestsOfProject: aGLHProject [ 
1✔
1081
        
1✔
1082
        |results parsedResults|
1✔
1083
        results := self repoApi mergeRequests getByPage: 1 perPage: 20  inProject: aGLHProject id. 
1✔
1084
        parsedResults := self parseMergeRequestsResult: results. 
1✔
1085
        
1✔
1086
        parsedResults := glhModel addAll: parsedResults unless: self blockOnIdEquality.
1✔
1087
        parsedResults := aGLHProject mergeRequests addAll: parsedResults unless: self blockOnIdEquality.
1✔
1088
        ^ parsedResults.
1✔
1089
]
1✔
1090

1✔
1091
{ #category : #'import - pipelines' }
1✔
1092
GitlabModelImporter >> importLatestPipelinesOfProject: aGLHProject [ 
1✔
1093
        (self pipelinesOf: aGLHProject id withLimit:20) do: [ :pipeline |
1✔
1094
                |pip|
1✔
1095
                pip := self glhModel add: pipeline unless: self blockOnIdEquality .
1✔
1096
                pip := aGLHProject pipelines add: pip unless: self blockOnIdEquality.
1✔
1097
                self completeImportedPipeline: pip. 
1✔
1098
                ].
1✔
1099
        
1✔
1100
        ^ aGLHProject pipelines 
1✔
1101
]
1✔
1102

1✔
1103
{ #category : #'import - releases' }
1✔
1104
GitlabModelImporter >> importLatestReleaseOfProject: aGLHProject [ 
1✔
1105
        
1✔
1106
        |result foundRelease|
1✔
1107
        result := repoApi releases getLatestOfProject: aGLHProject id.
1✔
1108
        foundRelease := self parseReleaseResult: result. 
1✔
1109

1✔
1110
        foundRelease := glhModel add: foundRelease unless: self blockOnNameEquality.
1✔
1111
        foundRelease := aGLHProject releases add: foundRelease unless: self blockOnNameEquality.
1✔
1112

1✔
1113
        foundRelease author: (self importUser: foundRelease author id). 
1✔
1114
        
1✔
1115
        ^ foundRelease.
1✔
1116
]
1✔
1117

1✔
1118
{ #category : #'import - merge-requests' }
1✔
1119
GitlabModelImporter >> importMergeRequestCommits: aGLPHEMergeRequest [
1✔
1120

1✔
1121
        | commits result |
1✔
1122
        aGLPHEMergeRequest commits ifNotNil: [ ^ aGLPHEMergeRequest commits ].
1✔
1123
        
1✔
1124
        result := self repoApi mergeRequests commitsOf: aGLPHEMergeRequest iid inProject: aGLPHEMergeRequest project id.
1✔
1125
        
1✔
1126
        commits := (result collect: [ :commitsJson | self parseCommitsResult: commitsJson ]) flattened.
1✔
1127
        commits := commits collect: [ :commit | self importCommit: commit id ofProject: aGLPHEMergeRequest project ].
1✔
1128
        aGLPHEMergeRequest commits: commits.
1✔
1129

1✔
1130

1✔
1131
        ^ commits
1✔
1132
]
1✔
1133

1✔
1134
{ #category : #'import - merge-requests' }
1✔
1135
GitlabModelImporter >> importMergeRequestMergeCommits: aGLPHEMergeRequest [
1✔
1136

1✔
1137
        | foundCommits |
1✔
1138
        foundCommits := OrderedCollection new.
1✔
1139

1✔
1140
        ('Import commit sha of MR:  ' , aGLPHEMergeRequest iid printString)
1✔
1141
                recordInfo.
1✔
1142
        "the founds commits are added to the model during their respective import"
1✔
1143
        aGLPHEMergeRequest mergeRequestCommit: ((self
1✔
1144
                          importCommitOfProject: aGLPHEMergeRequest project
1✔
1145
                          withId: aGLPHEMergeRequest sha) ifNotNil: [ :commit |
1✔
1146
                         foundCommits add: commit ]).
1✔
1147

1✔
1148
        ('Import commit merge_commit_sha of MR:  '
1✔
1149
         , aGLPHEMergeRequest iid printString) recordInfo.
1✔
1150
        aGLPHEMergeRequest mergedCommit: ((self
1✔
1151
                          importCommitOfProject: aGLPHEMergeRequest project
1✔
1152
                          withId: aGLPHEMergeRequest merge_commit_sha) ifNotNil: [ :commit |
1✔
1153
                         foundCommits add: commit ]).
1✔
1154

1✔
1155
        ('Import commit squash_commit_sha of MR:  '
1✔
1156
         , aGLPHEMergeRequest iid printString) recordInfo.
1✔
1157
        aGLPHEMergeRequest squashCommit: ((self
1✔
1158
                          importCommitOfProject: aGLPHEMergeRequest project
1✔
1159
                          withId: aGLPHEMergeRequest squash_commit_sha) ifNotNil: [ :commit |
1✔
1160
                         foundCommits add: commit ]).
1✔
1161

1✔
1162

1✔
1163
        self chainsCommitsFrom: foundCommits.
1✔
1164
        ^ foundCommits
1✔
1165
]
1✔
1166

1✔
1167
{ #category : #'import - pipelines' }
1✔
1168
GitlabModelImporter >> importMergeRequestPipelines: aGLHMergeRequest [ 
1✔
1169
        "default limit to one page with last 100 pipelines"
1✔
1170
        
1✔
1171
        |results parseResults|
1✔
1172
        
1✔
1173
        results := self repoApi pipelines getByPage: 1 perPage: 100 inProject: aGLHMergeRequest project id forMergerRequestIid: aGLHMergeRequest iid. 
1✔
1174
        
1✔
1175
        parseResults := self parsePipelinesResult: results.
1✔
1176
        
1✔
1177
        parseResults := glhModel addAll: parseResults unless: self blockOnIdEquality.
1✔
1178
        parseResults := aGLHMergeRequest pipelines addAll: parseResults unless: self blockOnIdEquality.
1✔
1179
        ^ parseResults collect: [ :pip | self completeImportedPipeline: pip ]  .
1✔
1180
        
1✔
1181
]
1✔
1182

1✔
1183
{ #category : #'import - merge-requests' }
1✔
1184
GitlabModelImporter >> importMergeRequestsOfProject: aGLHProject [
1✔
1185

1✔
1186
        | results parsedResults mrs |
1✔
1187
        ('Import merge request of Project: ' , aGLHProject id printString)
1✔
1188
                recordInfo.
1✔
1189

1✔
1190
        results := self repoApi mergeRequests getAllOfProject: aGLHProject id.
1✔
1191
        parsedResults := (results collect: [ :projectsJson | self parseMergeRequestsResult: projectsJson ]) flattened. 
1✔
1192

1✔
1193
        aGLHProject mergeRequests
1✔
1194
                addAll: parsedResults
1✔
1195
                unless: self blockOnIdEquality.
1✔
1196

1✔
1197
        mrs := self glhModel
1✔
1198
                       addAll: aGLHProject mergeRequests
1✔
1199
                       unless: self blockOnIdEquality.
1✔
1200

1✔
1201

1✔
1202
        "gets it related commits"
1✔
1203
        aGLHProject mergeRequests do: [ :mr |
1✔
1204
                self importMergeRequestMergeCommits: mr ].
1✔
1205

1✔
1206

1✔
1207
        self withCommitDiffs ifTrue: [
1✔
1208
                aGLHProject mergeRequests do: [ :mr |
1✔
1209
                        self importDiffOfMergeRequest: mr ] ].
1✔
1210

1✔
1211
        ^ mrs
1✔
1212
]
1✔
1213

1✔
1214
{ #category : #'import - merge-requests' }
1✔
1215
GitlabModelImporter >> importMergeRequestsOfProject: aGLHProject since: fromDate until: toDate [
1✔
1216

1✔
1217
        | params result mergeRequests |
1✔
1218
        ('import MR of Project ' , aGLHProject name) recordInfo.
1✔
1219
        params := {
1✔
1220
                          (#created_after
1✔
1221
                           ->
1✔
1222
                           (fromDate
1✔
1223
                                    ifNotNil: [ fromDate asDateAndTime asString ]
1✔
1224
                                    ifNil: [ '' ])).
1✔
1225
                          (#created_before
1✔
1226
                           ->
1✔
1227
                           (toDate
1✔
1228
                                    ifNotNil: [ toDate asDateAndTime asString ]
1✔
1229
                                    ifNil: [ '' ])).
1✔
1230
                          (#scope -> 'all') } asDictionary.
1✔
1231

1✔
1232
        result := self repoApi mergeRequests
1✔
1233
                          getAllOfProject: aGLHProject id
1✔
1234
                          withParams: params.
1✔
1235
        mergeRequests := (result collect: [ :mergeRequestsJson |
1✔
1236
                                  self parseMergeRequestsResult: mergeRequestsJson ])
1✔
1237
                                 flattened.
1✔
1238

1✔
1239
        aGLHProject mergeRequests
1✔
1240
                addAll: mergeRequests
1✔
1241
                unless: self blockOnIdEquality.
1✔
1242

1✔
1243
        "gets it related commits"
1✔
1244
        aGLHProject mergeRequests do: [ :mr |
1✔
1245
                self importMergeRequestMergeCommits: mr ].
1✔
1246

1✔
1247
        self withCommitDiffs ifTrue: [
1✔
1248
                aGLHProject mergeRequests do: [ :mr |
1✔
1249
                        self importDiffOfMergeRequest: mr ] ].
1✔
1250

1✔
1251
        self glhModel
1✔
1252
                addAll: mergeRequests
1✔
1253
                unless: (self blockEqualityOn: #iid).
1✔
1254

1✔
1255
        ^ mergeRequests
1✔
1256
]
1✔
1257

1✔
1258
{ #category : #'import - merge-requests' }
1✔
1259
GitlabModelImporter >> importMergeResquestApprovals: aGLPHEMergeRequest [
1✔
1260

1✔
1261
        | results parsedResult |
1✔
1262
        (String streamContents: [ :str |
1✔
1263
                 str << 'Check approvals of '.
1✔
1264
                 aGLPHEMergeRequest printOn: str ]) recordInfo.
1✔
1265
        results := self repoApi mergeRequests approvalsOf: aGLPHEMergeRequest iid inProject: aGLPHEMergeRequest project id.
1✔
1266

1✔
1267
        parsedResult := generalReader
1✔
1268
                                on: results readStream;
1✔
1269
                                next.
1✔
1270

1✔
1271
        (parsedResult at: #approved_by) do: [ :approvedUser |
1✔
1272
                aGLPHEMergeRequest addApproved_by:
1✔
1273
                        (self importUser: ((approvedUser at: #user) at: #id)) ].
1✔
1274
        aGLPHEMergeRequest approved: (parsedResult at: #approved).
1✔
1275
        ^ aGLPHEMergeRequest
1✔
1276
]
1✔
1277

1✔
1278
{ #category : #'import - merge-requests' }
1✔
1279
GitlabModelImporter >> importMergeResquestAuthor: aGLPHEMergeRequest [
1✔
1280

1✔
1281
        | authorID |
1✔
1282
        aGLPHEMergeRequest author ifNotNil: [ ^ aGLPHEMergeRequest author ].
1✔
1283
        authorID := aGLPHEMergeRequest cacheAt: #authorID ifAbsent: [
1✔
1284
                            | result |
1✔
1285
                            result := self repoApi mergeRequests
1✔
1286
                                              get: aGLPHEMergeRequest iid
1✔
1287
                                              inProject: aGLPHEMergeRequest project_id.
1✔
1288

1✔
1289
                            (generalReader
1✔
1290
                                     on: result readStream;
1✔
1291
                                     next) at: #author at: #id ].
1✔
1292
        ^aGLPHEMergeRequest author: (self importUser: authorID)
1✔
1293
]
1✔
1294

1✔
1295
{ #category : #'import - merge-requests' }
1✔
1296
GitlabModelImporter >> importMergeResquestMerger: aGLPHEMergeRequest [
1✔
1297

1✔
1298
        | authorID |
1✔
1299
        aGLPHEMergeRequest merge_user ifNotNil: [
1✔
1300
                ^ aGLPHEMergeRequest merge_user ].
1✔
1301
        authorID := aGLPHEMergeRequest cacheAt: #mergeUserID ifAbsent: [
1✔
1302
                            | result |
1✔
1303
                            result := self repoApi mergeRequests
1✔
1304
                                              get: aGLPHEMergeRequest iid
1✔
1305
                                              inProject: aGLPHEMergeRequest project_id.
1✔
1306
                            (generalReader
1✔
1307
                                     on: result readStream;
1✔
1308
                                     next)
1✔
1309
                                    at: #merge_user
1✔
1310
                                    ifPresent: [ :mergeUser |
1✔
1311
                                    mergeUser ifNotNil: [ :mruser | mruser at: #id ] ] ].
1✔
1312
        ^aGLPHEMergeRequest merge_user: (self importUser: authorID)
1✔
1313
]
1✔
1314

1✔
1315
{ #category : #'import - notes' }
1✔
1316
GitlabModelImporter >> importNotesOfMergeRequest: mergeRequest [
1✔
1317
        | results notes |
1✔
1318
        
1✔
1319
        results := self repoApi notes allInMergeRequest: mergeRequest iid ofProject: mergeRequest project id.
1✔
1320
        
1✔
1321
        notes := results collect: [ :note | 
1✔
1322
                self parseNoteJson: note ].
1✔
1323
        "notes := self parseNoteJson: results."
1✔
1324
        notes do: [ :tabNotes | tabNotes do: [ :note |
1✔
1325
                        note author: (self importUser: (note author at: #id)).
1✔
1326
                        note name: note id asString]. ].
1✔
1327
        notes := notes flattened.
1✔
1328
        notes := self glhModel addAll: notes unless: self blockOnIdEquality. 
1✔
1329
        notes := mergeRequest note addAll: notes unless: self blockOnIdEquality. 
1✔
1330
        ^notes
1✔
1331
        
1✔
1332
]
1✔
1333

1✔
1334
{ #category : #'import - commits' }
1✔
1335
GitlabModelImporter >> importParentCommitsOfCommit: aGLHCommit since: aDate [
1✔
1336

1✔
1337
        | parentsIds commits |
1✔
1338
        commits := Set new.
1✔
1339
        aGLHCommit created_at asDateAndTime < aDate asDateAndTime ifTrue: [
1✔
1340
                 
1✔
1341
                ^ commits
1✔
1342
                          add: aGLHCommit;
1✔
1343
                          yourself ].
1✔
1344

1✔
1345
        parentsIds := aGLHCommit parent_ids.
1✔
1346

1✔
1347
        commits addAll: (parentsIds collect: [ :id |
1✔
1348
                         self
1✔
1349
                                 importCommit: id ofProject: aGLHCommit repository project  ]).
1✔
1350

1✔
1351
        
1✔
1352
        commits addAll: (commits collect: [ :parentCommit |
1✔
1353
                   self importParentCommitsOfCommit: parentCommit since: aDate ]).
1✔
1354

1✔
1355
        ^ commits flattened asSet. 
1✔
1356
]
1✔
1357

1✔
1358
{ #category : #'import - pipelines' }
1✔
1359
GitlabModelImporter >> importPipeline: pipelineId OfProject: aGLHProject [
1✔
1360

1✔
1361
        
1✔
1362
        | result pipeline|
1✔
1363
        
1✔
1364
        aGLHProject pipelines detect: [ :pip | pip id = pipelineId ] ifOne: [ :pip| ^pip ].
1✔
1365
        
1✔
1366
        ('Search pipelines of: ' , aGLHProject id printString) recordInfo.
1✔
1367
        result := self repoApi pipelines get: pipelineId inProject: aGLHProject id.
1✔
1368
        result isString ifTrue: [ ^ self parsePipelineResult: result ].
1✔
1369

1✔
1370
        pipeline :=  self parsePipelineResult: result.
1✔
1371

1✔
1372
        pipeline := self glhModel add: pipeline unless: self blockOnIdEquality .
1✔
1373
        pipeline := aGLHProject pipelines add: pipeline unless: self blockOnIdEquality.
1✔
1374
        
1✔
1375
        ^ self completeImportedPipeline: pipeline. 
1✔
1376
]
1✔
1377

1✔
1378
{ #category : #'import - pipelines' }
1✔
1379
GitlabModelImporter >> importPipelinesOfProject: aGLHProject [
1✔
1380

1✔
1381
        self flag: 'WARNING: this import ALL the pipelines at ones. Prefered ImportLatestPipleinesOfProject: for faster performance (if possible)'. 
1✔
1382
        ^ self importAllPipelinesOfProject: aGLHProject
1✔
1383
]
1✔
1384

1✔
1385
{ #category : #'import - pipelines' }
1✔
1386
GitlabModelImporter >> importPipelinesOfProject: aGLHProject after: after andBefore: before [
1✔
1387
        ^ (self pipelinesOf: aGLHProject id after: after andBefore: before) collect: [ :pipeline |
1✔
1388
                |pip|
1✔
1389
                pip := self glhModel add: pipeline unless: self blockOnIdEquality .
1✔
1390
                pip := aGLHProject pipelines add: pip unless: self blockOnIdEquality.
1✔
1391
                
1✔
1392
                ].
1✔
1393
        
1✔
1394
]
1✔
1395

1✔
1396
{ #category : #'import - pipelines' }
1✔
1397
GitlabModelImporter >> importPipelinesOfProject: aGLHProject after: after andBefore: before onBranch: aBranch [
1✔
1398
        | result parsedResults|
1✔
1399
        ('Search pipelines of: ' , aGLHProject id printString) recordInfo.
1✔
1400
        
1✔
1401
        result := self repoApi pipelines getAllInProject: aGLHProject id 
1✔
1402
                                                                                                withParams: {        #updated_before -> before.
1✔
1403
                                                                                                                                        #updated_after -> after.
1✔
1404
                                                                                                                                        #ref -> aBranch name} asDictionary .
1✔
1405
        result isString ifTrue: [ ^ self parsePipelinesResult: result ].
1✔
1406

1✔
1407
        parsedResults := (result collect: [ :pipelinesJson |
1✔
1408
                           self parsePipelinesResult: pipelinesJson ]) flattened.
1✔
1409
        
1✔
1410

1✔
1411
        ^ parsedResults collect: [ :pipeline |
1✔
1412
                |pip|
1✔
1413
                pip := self glhModel add: pipeline unless: self blockOnIdEquality .
1✔
1414
                aGLHProject pipelines add: pip unless: self blockOnIdEquality.
1✔
1415
                ].
1✔
1416
        
1✔
1417
]
1✔
1418

1✔
1419
{ #category : #'import - projects' }
1✔
1420
GitlabModelImporter >> importProject: aProjectID [
1✔
1421

1✔
1422
        | result projectResult |
1✔
1423
        ('Import project with id:  ' , aProjectID printString) recordInfo.
1✔
1424

1✔
1425
        (glhModel allWithType: GLHProject)
1✔
1426
                detect: [ :project | project id = aProjectID ]
1✔
1427
                ifFound: [ :project | ^ project ].
1✔
1428

1✔
1429
        result := self repoApi projects get: aProjectID.
1✔
1430
        projectResult := self parseProjectResult: result.
1✔
1431

1✔
1432
        ^ self completeImportedProject: projectResult
1✔
1433
]
1✔
1434

1✔
1435
{ #category : #'import - projects' }
1✔
1436
GitlabModelImporter >> importProjects [
1✔
1437

1✔
1438
        | result projects |
1✔
1439
        ('import all Projects') recordInfo.
1✔
1440

1✔
1441

1✔
1442
        result := self repoApi projects all.
1✔
1443
        projects := (result collect: [ :projectsJson | self parseArrayOfProject: projectsJson ]) flattened.
1✔
1444
        
1✔
1445
        self glhModel addAll: projects unless: self blockOnIdEquality.
1✔
1446

1✔
1447
        ^ projects
1✔
1448
]
1✔
1449

1✔
1450
{ #category : #'import - projects' }
1✔
1451
GitlabModelImporter >> importProjectsSince: since [
1✔
1452
        "heavy import of all projects"
1✔
1453

1✔
1454
        "copy import from commits"
1✔
1455

1✔
1456
        | newlyFoundProjects page foundProject amount |
1✔
1457
        ('import all Projects since: ' , since printString) recordInfo.
1✔
1458

1✔
1459
        "number of projects per page"
1✔
1460
        amount := 100.
1✔
1461
        page := 0.
1✔
1462
        foundProject := OrderedCollection new.
1✔
1463
        newlyFoundProjects := { true }.
1✔
1464
        [ newlyFoundProjects isNotEmpty ] whileTrue: [
1✔
1465
                | results |
1✔
1466
                page := page + 1.
1✔
1467
                ('import projects page #' , page printString) recordInfo.
1✔
1468

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

1✔
1471
                newlyFoundProjects := self glhModel
1✔
1472
                                              addAll: (self parseArrayOfProject: results)
1✔
1473
                                              unless: self blockOnIdEquality.
1✔
1474
                foundProject addAll: newlyFoundProjects ].
1✔
1475
]
1✔
1476

1✔
1477
{ #category : #'import - repositories' }
1✔
1478
GitlabModelImporter >> importRepository: aGLHRepository [
1✔
1479

1✔
1480
        | branches |
1✔
1481
        [
1✔
1482
        ('import the repository of project ' , aGLHRepository project name)
1✔
1483
                recordInfo.
1✔
1484
        branches := self importBranchesOf: aGLHRepository project.
1✔
1485
        self withFiles ifTrue: [
1✔
1486
                branches do: [ :branch | self importFilesOfBranch: branch ] ] ]
1✔
1487
                on: NeoJSONParseError
1✔
1488
                do: [
1✔
1489
                self inform: aGLHRepository project name , ' has no repository' ].
1✔
1490

1✔
1491
        withInitialCommits ifTrue: [
1✔
1492
                aGLHRepository branches do: [ :branch |
1✔
1493
                        self importCommitsOfBranch: branch ] ]
1✔
1494
]
1✔
1495

1✔
1496
{ #category : #'import - commits' }
1✔
1497
GitlabModelImporter >> importSZZFromCommit: aCommit [
1✔
1498

1✔
1499
        | diffRanges diffs szzCommits |
1✔
1500
        szzCommits := Set new.
1✔
1501
        diffs := self importDiffOfCommit: aCommit.
1✔
1502
        diffRanges := diffs flatCollect: #diffRanges.
1✔
1503
        diffRanges do: [ :range |
1✔
1504
                | blames |
1✔
1505
                blames := NeoJSONReader fromString: (self repoApi repositories
1✔
1506
                                           getBlameOf: range diff new_path
1✔
1507
                                           inRef: aCommit id
1✔
1508
                                           start: range start
1✔
1509
                                           end: range end
1✔
1510
                                           ofProject: aCommit repository project id).
1✔
1511
                blames collect: [ :blame |
1✔
1512
                        blame isDictionary ifTrue: [
1✔
1513
                                szzCommits add: (self
1✔
1514
                                                 importCommit: (blame at: #commit at: #id)
1✔
1515
                                                 ofProject: aCommit repository project) ] ] ].
1✔
1516
        ^ szzCommits
1✔
1517
]
1✔
1518

1✔
1519
{ #category : #'import - tags' }
1✔
1520
GitlabModelImporter >> importTagsForProject: aProject [ 
1✔
1521
        |results tags |
1✔
1522
        results  := repoApi tags getAllOfProject: aProject id.
1✔
1523
        "get a group of tags"
1✔
1524
        tags := results flatCollect: [ :result |
1✔
1525
                        self parseTagsResult: result. 
1✔
1526
                 ].
1✔
1527

1✔
1528
        "add the tags inside the model"
1✔
1529
        tags := glhModel addAll: tags unless: self blockOnNameEquality.
1✔
1530
        tags := aProject repository tags addAll: tags unless: self blockOnNameEquality.
1✔
1531
        
1✔
1532
        "update tag's commit if already imported"
1✔
1533
        tags do: [ :tag |
1✔
1534
                tag commit: (self importCommit: tag commit id ofProject: aProject).
1✔
1535
                 ].
1✔
1536
        
1✔
1537
        "update tag's release if already imported"
1✔
1538
        tags do: [ :tag |
1✔
1539
                |release|
1✔
1540
                tag release ifNotNil: [ 
1✔
1541
                        release := glhModel add: tag release unless: (self blockEqualityOn: #tag_name).
1✔
1542
                        release := aProject releases add: tag release unless: (self blockEqualityOn: #tag_name).
1✔
1543
                        tag release: release. 
1✔
1544
                         ].
1✔
1545
                 ].
1✔
1546
        
1✔
1547
        ^ tags
1✔
1548
]
1✔
1549

1✔
1550
{ #category : #'import - users' }
1✔
1551
GitlabModelImporter >> importUser: aUserID [
1✔
1552

1✔
1553
        | result userResult |
1✔
1554
        (self glhModel allWithType: GLHUser)
1✔
1555
                detect: [ :user | user id = aUserID ]
1✔
1556
                ifFound: [ :user | ^ user ].
1✔
1557
        ('Import user: ' , aUserID printString) recordInfo.
1✔
1558
        
1✔
1559
        result := self repoApi users get: aUserID.
1✔
1560
        userResult := self parseUserResult: result.
1✔
1561
        
1✔
1562
        userResult := self glhModel add: userResult unless: self blockOnIdEquality.
1✔
1563
        userCatalogue addUser: userResult.
1✔
1564
        ^ userResult 
1✔
1565
]
1✔
1566

1✔
1567
{ #category : #'import - users' }
1✔
1568
GitlabModelImporter >> importUserByUsername: anUsername [
1✔
1569

1✔
1570
        | dicUsername resultUser |
1✔
1571
        dicUsername := ((self glhModel allWithType: GLHUser) collect: [ :user |
1✔
1572
                                user username -> user ]) asSet asDictionary.
1✔
1573

1✔
1574
        dicUsername addAll: self userCatalogue collectUsernames.
1✔
1575

1✔
1576

1✔
1577
        resultUser := dicUsername
1✔
1578
                              at: anUsername
1✔
1579
                              ifAbsent: [ "thus we have to import this new user"
1✔
1580
                                      | result userId searchResult params |
1✔
1581
                                      ('Import user with username: '
1✔
1582
                                       , anUsername printString) recordInfo.
1✔
1583
                                      params := { (#search -> anUsername) } asDictionary.
1✔
1584
                                      result := self repoApi users allWithParams: params.
1✔
1585
                                                        
1✔
1586
                                                         "when result is an error"
1✔
1587
                                                         (result isString) ifTrue: [ result := { result } ].
1✔
1588
                                                        
1✔
1589
                                      searchResult := result ifEmpty: [ result ] ifNotEmpty: [(result collect: [ :usersJson |
1✔
1590
                                                               NeoJSONReader fromString: usersJson ]) first].
1✔
1591
                                                         
1✔
1592
                                      (searchResult class = Dictionary and: [
1✔
1593
                                               (searchResult at: #message) includesSubstring:
1✔
1594
                                                       '403 Forbidden' ])
1✔
1595
                                              ifTrue: [ "if the result is an 403 error we fake a new user"
1✔
1596
                                                      self glhModel
1✔
1597
                                                              add: (GLHUser new
1✔
1598
                                                                               username: anUsername;
1✔
1599
                                                                               name: anUsername;
1✔
1600
                                                                               yourself)
1✔
1601
                                                              unless: [ :nu :ou | nu username = ou username ] ]
1✔
1602
                                              ifFalse: [
1✔
1603
                                                      searchResult
1✔
1604
                                                              ifEmpty: [ "results can be empty thus we force a new user with the info we have "
1✔
1605
                                                                      self glhModel
1✔
1606
                                                                              add: (GLHUser new
1✔
1607
                                                                                               username: anUsername;
1✔
1608
                                                                                               name: anUsername;
1✔
1609
                                                                                               yourself)
1✔
1610
                                                                              unless: [ :nu :ou | nu username = ou username ] ]
1✔
1611
                                                              ifNotEmpty: [ "because we may already have the researched user, we look by ID in the model"
1✔
1612
                                                                      userId := searchResult first at: #id.
1✔
1613
                                                                      (self glhModel allWithType: GLHUser)
1✔
1614
                                                                              detect: [ :user | user id = userId ]
1✔
1615
                                                                              ifNone: [ self importUser: userId ] ] ] ].
1✔
1616

1✔
1617
        self userCatalogue addUser: resultUser withName: anUsername.
1✔
1618

1✔
1619
        ^ resultUser
1✔
1620
]
1✔
1621

1✔
1622
{ #category : #initialization }
1✔
1623
GitlabModelImporter >> initReader [
1✔
1624
        
1✔
1625
        "add specific reader for this importer here"
1✔
1626
        super initReader
1✔
1627
]
1✔
1628

1✔
1629
{ #category : #initialization }
1✔
1630
GitlabModelImporter >> initialize [
1✔
1631

1✔
1632
        super initialize.
1✔
1633
        withCommitDiffs := true.
1✔
1634
        withInitialCommits := false.
1✔
1635
        withInitialMergeRequest := false.
1✔
1636

1✔
1637
        self withCommitsSince: 1 week.
1✔
1638

1✔
1639
        
1✔
1640
]
1✔
1641

1✔
1642
{ #category : #private }
1✔
1643
GitlabModelImporter >> isServerError: aString [
1✔
1644
        ^ aString = '{"message":"500 Internal Server Error"}'
1✔
1645
]
1✔
1646

1✔
1647
{ #category : #'import - projects' }
1✔
1648
GitlabModelImporter >> loadAllProjectsFromRepositorySoftware [
1✔
1649
        "heavy import that load all the active project inside the model. Only import the project entities"
1✔
1650
        |projects|
1✔
1651
        
1✔
1652
        projects := self repoApi projects. 
1✔
1653
]
1✔
1654

1✔
1655
{ #category : #'private - parsing' }
1✔
1656
GitlabModelImporter >> newParseCommitResult: result [
1✔
1657

1✔
1658
        generalReader  on: result readStream.
1✔
1659

1✔
1660
        ^ generalReader nextAs: GLHCommit
1✔
1661
]
1✔
1662

1✔
1663
{ #category : #'private - parsing' }
1✔
1664
GitlabModelImporter >> newParseDiffResult: result [
1✔
1665

1✔
1666
        generalReader on: result readStream.
1✔
1667
        ^ generalReader nextAs: #ArrayOfDiff
1✔
1668
]
1✔
1669

1✔
1670
{ #category : #'private - parsing' }
1✔
1671
GitlabModelImporter >> parseArrayOfProject: arrayOfProjects [
1✔
1672

1✔
1673
        | reader |
1✔
1674
        reader := NeoJSONReader on: arrayOfProjects readStream.
1✔
1675
        reader
1✔
1676
                for: #ArrayOfProjects
1✔
1677
                customDo: [ :customMappting |
1✔
1678
                customMappting listOfElementSchema: GLHProject ].
1✔
1679
        reader for: GLHProject do: [ :mapping |
1✔
1680
                mapping mapInstVar: #name to: #name.
1✔
1681
                mapping mapInstVar: #description to: #description.
1✔
1682
                mapping mapInstVar: #id to: #id.
1✔
1683
                mapping mapInstVar: #archived to: #archived.
1✔
1684
                mapping mapInstVar: #web_url to: #html_url.
1✔
1685
                mapping mapInstVar: #topics to: #topics ].
1✔
1686
        ^ reader nextAs: #ArrayOfProjects
1✔
1687
]
1✔
1688

1✔
1689
{ #category : #'private - parsing' }
1✔
1690
GitlabModelImporter >> parseBranchesResult: result [
1✔
1691

1✔
1692
        | reader |
1✔
1693
        reader := generalReader on: result readStream.
1✔
1694

1✔
1695

1✔
1696
        ^ reader nextAs: #ArrayOfBranch
1✔
1697
]
1✔
1698

1✔
1699
{ #category : #'private - parsing' }
1✔
1700
GitlabModelImporter >> parseBranchesResult: result ofProject: aGLHProject [
1✔
1701

1✔
1702
        | reader |
1✔
1703
        reader := NeoJSONReader on: result readStream.
1✔
1704
        reader mapInstVarsFor: GLHBranch.
1✔
1705

1✔
1706
        reader for: GLHBranch do: [ :mapping |
1✔
1707
                mapping
1✔
1708
                        mapProperty: #commit
1✔
1709
                        getter: [  ]
1✔
1710
                        setter: [ :branch :rawCommit |
1✔
1711
                                branch sha: (rawCommit at: #id)
1✔
1712
                                "commit := self
1✔
1713
                                                  importCommit: (rawCommit at: #id)
1✔
1714
                                                  ofProject: aGLHProject.
1✔
1715
                                branch commits add: commit unless: self blockOnIdEquality " ] ].
1✔
1716

1✔
1717
        reader
1✔
1718
                for: #ArrayOfBranch
1✔
1719
                customDo: [ :customMappting |
1✔
1720
                customMappting listOfElementSchema: GLHBranch ].
1✔
1721

1✔
1722
        ^ reader nextAs: #ArrayOfBranch
1✔
1723
]
1✔
1724

1✔
1725
{ #category : #'private - parsing' }
1✔
1726
GitlabModelImporter >> parseCommitResult: result [
1✔
1727

1✔
1728
        | reader |
1✔
1729
        reader := NeoJSONReader on: result readStream.
1✔
1730

1✔
1731
        reader for: GLHCommit do: [ :mapping |
1✔
1732
                mapping mapInstVars:
1✔
1733
                        #( id short_id title author_name author_email committer_name
1✔
1734
                           committer_email message web_url ).
1✔
1735
                (mapping mapInstVar: #authored_date) valueSchema: DateAndTime.
1✔
1736
                (mapping mapInstVar: #committed_date) valueSchema: DateAndTime.
1✔
1737
                (mapping mapInstVar: #created_at) valueSchema: DateAndTime.
1✔
1738
                (mapping mapInstVar: #parent_ids) valueSchema: #ArrayOfIds.
1✔
1739
                mapping
1✔
1740
                        mapProperty: 'stats'
1✔
1741
                        getter: [ :el | "Not used" ]
1✔
1742
                        setter: [ :commit :value |
1✔
1743
                                commit deletions: (value at: #deletions).
1✔
1744
                                commit additions: (value at: #additions) ] ].
1✔
1745

1✔
1746
        reader for: DateAndTime customDo: [ :mapping |
1✔
1747
                mapping decoder: [ :string | DateAndTime fromString: string ] ].
1✔
1748

1✔
1749
        reader
1✔
1750
                for: #ArrayOfIds
1✔
1751
                customDo: [ :mapping | mapping decoder: [ :string | string ] ].
1✔
1752

1✔
1753

1✔
1754
        ^ reader nextAs: GLHCommit
1✔
1755
]
1✔
1756

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

1✔
1760
        | reader |
1✔
1761
        reader := NeoJSONReader on: result readStream.
1✔
1762

1✔
1763
          reader for: GLHCommit do: [ :mapping |
1✔
1764
                mapping mapInstVars:
1✔
1765
                        #( id short_id title author_name author_email committer_name
1✔
1766
                           committer_email message web_url ).
1✔
1767
                (mapping mapInstVar: #authored_date) valueSchema: DateAndTime.
1✔
1768
                (mapping mapInstVar: #committed_date) valueSchema: DateAndTime.
1✔
1769
                (mapping mapInstVar: #created_at) valueSchema: DateAndTime.
1✔
1770
                (mapping mapInstVar: #parent_ids) valueSchema: #ArrayOfIds.
1✔
1771
                mapping
1✔
1772
                        mapProperty: 'stats'
1✔
1773
                        getter: [ :el | "Not used" ]
1✔
1774
                        setter: [ :commit :value |
1✔
1775
                                commit deletions: (value at: #deletions).
1✔
1776
                                commit additions: (value at: #additions) ] ].
1✔
1777

1✔
1778
        reader for: DateAndTime customDo: [ :mapping |
1✔
1779
                mapping decoder: [ :string | DateAndTime fromString: string ] ].
1✔
1780

1✔
1781
        reader
1✔
1782
                for: #ArrayOfIds
1✔
1783
                customDo: [ :mapping | mapping decoder: [ :string | string ] ].
1✔
1784
  
1✔
1785
        reader
1✔
1786
                for: #ArrayOfCommit
1✔
1787
                customDo: [ :customMappting |
1✔
1788
                customMappting listOfElementSchema: GLHCommit ].
1✔
1789

1✔
1790
        ^ reader nextAs: #ArrayOfCommit
1✔
1791
]
1✔
1792

1✔
1793
{ #category : #private }
1✔
1794
GitlabModelImporter >> parseDiffResult: result [
1✔
1795

1✔
1796
        | reader |
1✔
1797
        self
1✔
1798
                deprecated: 'Use #newParseDiffResult: instead'
1✔
1799
                on: '28 June 2024'
1✔
1800
                in:
1✔
1801
                'Pharo-11.0.0+build.726.sha.aece1b5473acf3830a0e082c1bc3a15d4ff3522b (64 Bit)'.
1✔
1802
        reader := NeoJSONReader on: result readStream.
1✔
1803
        reader for: GLHDiff do: [ :mapping |
1✔
1804
                mapping mapInstVars:
1✔
1805
                        #( deleted_file new_file new_path old_path renamed_file ).
1✔
1806
                mapping mapInstVar: #diffString to: #diff ].
1✔
1807

1✔
1808
        reader
1✔
1809
                for: #ArrayOfDiffs
1✔
1810
                customDo: [ :customMappting |
1✔
1811
                customMappting listOfElementSchema: GLHDiff ].
1✔
1812
        ^ reader nextAs: #ArrayOfDiffs
1✔
1813
]
1✔
1814

1✔
1815
{ #category : #'private - parsing' }
1✔
1816
GitlabModelImporter >> parseFileTreeResult: aResult [
1✔
1817

1✔
1818
        | reader |
1✔
1819
        reader := NeoJSONReader on: aResult readStream.
1✔
1820
        reader mapInstVarsFor: GLHApiFile.
1✔
1821
        reader
1✔
1822
                for: #ArrayOfFile
1✔
1823
                customDo: [ :customMappting | 
1✔
1824
                customMappting listOfElementSchema: GLHApiFile ].
1✔
1825
        ^ reader nextAs: #ArrayOfFile
1✔
1826
]
1✔
1827

1✔
1828
{ #category : #'private - parsing' }
1✔
1829
GitlabModelImporter >> parseGroupResult: aResult [
1✔
1830

1✔
1831
        | reader |
1✔
1832

1✔
1833
        reader := NeoJSONReader on: aResult readStream.
1✔
1834
        reader for: GLHGroup do: [ :mapping |
1✔
1835
                mapping mapInstVars.
1✔
1836
                (mapping mapInstVar: #projects) valueSchema: #ArrayOfProjects ].
1✔
1837
        reader mapInstVarsFor: GLHProject.
1✔
1838
        reader
1✔
1839
                for: #ArrayOfProjects
1✔
1840
                customDo: [ :customMappting |
1✔
1841
                customMappting listOfElementSchema: GLHProject ].
1✔
1842
        ^ reader nextAs: GLHGroup
1✔
1843
]
1✔
1844

1✔
1845
{ #category : #'private - parsing' }
1✔
1846
GitlabModelImporter >> parseJobsResult: result ofProject: aProject [
1✔
1847

1✔
1848
        | reader |
1✔
1849
        reader := NeoJSONReader on: result readStream.
1✔
1850
        reader for: GLHJob do: [ :mapping |
1✔
1851
                mapping mapInstVars: #( id allow_failure web_url name ).
1✔
1852

1✔
1853
                mapping
1✔
1854
                        mapProperty: #user
1✔
1855
                        getter: [ :object | #ignore ]
1✔
1856
                        setter: [ :object :value |
1✔
1857
                        object user: (self importUser: (value at: #id)) ].
1✔
1858

1✔
1859
                mapping
1✔
1860
                        mapProperty: #commit
1✔
1861
                        getter: [ :object | #ignore ]
1✔
1862
                        setter: [ :object :value |
1✔
1863
                                value ifNotNil: [
1✔
1864
                                        object commit:
1✔
1865
                                                (self importCommit: (value at: #id) ofProject: aProject) ] ].
1✔
1866

1✔
1867
                mapping
1✔
1868
                        mapProperty: #duration
1✔
1869
                        getter: [ :object | #ignore ]
1✔
1870
                        setter: [ :object :value |
1✔
1871
                        value ifNotNil: [ object duration: value seconds ] ] ].
1✔
1872

1✔
1873
        reader
1✔
1874
                for: #ArrayOfGLHJob
1✔
1875
                customDo: [ :customMappting |
1✔
1876
                customMappting listOfElementSchema: GLHJob ].
1✔
1877
        ^ reader nextAs: #ArrayOfGLHJob
1✔
1878
]
1✔
1879

1✔
1880
{ #category : #'private - parsing' }
1✔
1881
GitlabModelImporter >> parseMergeRequestsResult: result [
1✔
1882

1✔
1883
        generalReader on: result readStream.
1✔
1884
        ^ generalReader nextAs: #ArrayOfMergeRequest
1✔
1885
]
1✔
1886

1✔
1887
{ #category : #'private - parsing' }
1✔
1888
GitlabModelImporter >> parseNoteJson: results [  
1✔
1889
    | reader |  
1✔
1890

1✔
1891
    "Créer un lecteur JSON"
1✔
1892
    reader := NeoJSONReader on: results readStream.    
1✔
1893

1✔
1894
    "Définir le mapping pour l'objet GLHNote"
1✔
1895
    reader for: GLHNote do: [ :mapping |  
1✔
1896
        mapping mapInstVars: #(id noteable_id attachment system confidential internal  
1✔
1897
                               noteable_iid resolvable imported imported_from  
1✔
1898
                               author body project_id noteable_type).  
1✔
1899

1✔
1900
        (mapping mapInstVar: #created_at) valueSchema: DateAndTime.  
1✔
1901
        (mapping mapInstVar: #updated_at) valueSchema: DateAndTime.  
1✔
1902
    ].    
1✔
1903

1✔
1904
    "Corriger la conversion des dates"
1✔
1905
    reader for: DateAndTime customDo: [ :mapping |  
1✔
1906
        mapping decoder: [ :string | DateAndTime readFrom: string readStream ] ].
1✔
1907

1✔
1908
        reader
1✔
1909
                for: #ArrayOfNote
1✔
1910
                customDo: [ :customMappting | 
1✔
1911
                customMappting listOfElementSchema: GLHNote ].
1✔
1912
         ^ reader nextAs: #ArrayOfNote
1✔
1913

1✔
1914
    "Retourner la Note"
1✔
1915
    "^ reader nextAs: GLHNote"
1✔
1916

1✔
1917

1✔
1918
]
1✔
1919

1✔
1920
{ #category : #'private - parsing' }
1✔
1921
GitlabModelImporter >> parsePipelineResult: result [
1✔
1922

1✔
1923
        | reader |
1✔
1924
        
1✔
1925
        (result includesSubstring: '{"message":"40' )ifTrue: [ ^ {  } ].
1✔
1926
        
1✔
1927
        reader := generalReader on: result readStream.
1✔
1928
        
1✔
1929
        ^ reader nextAs: GLHPipeline
1✔
1930
]
1✔
1931

1✔
1932
{ #category : #'private - parsing' }
1✔
1933
GitlabModelImporter >> parsePipelinesResult: result [
1✔
1934

1✔
1935
        | reader |
1✔
1936
        
1✔
1937
        (result includesSubstring: '{"message":"40' )ifTrue: [ ^ {  } ].
1✔
1938
        
1✔
1939
        reader := generalReader on: result readStream.
1✔
1940
        
1✔
1941
        ^ reader nextAs: #ArrayOfPipelines
1✔
1942
]
1✔
1943

1✔
1944
{ #category : #'private - parsing' }
1✔
1945
GitlabModelImporter >> parseProjectResult: aResult [ 
1✔
1946
                | reader |
1✔
1947
        reader := NeoJSONReader on: aResult readStream.
1✔
1948
        reader for: GLHProject do: [ :mapping |
1✔
1949
                mapping mapInstVars. ].
1✔
1950
"        reader mapInstVarsFor: GLHProject."
1✔
1951

1✔
1952
        ^ reader nextAs: GLHProject
1✔
1953
]
1✔
1954

1955
{ #category : #'private - parsing' }
1956
GitlabModelImporter >> parseReleaseResult: result [
×
1957
        |reader|
×
1958
        reader := generalReader on: result readStream.
×
1959
        
×
1960
        ^ reader nextAs: GLHRelease 
×
1961
]
×
1962

1963
{ #category : #'private - parsing' }
1964
GitlabModelImporter >> parseReleasesResult: result [
×
1965
        |reader|
×
1966
        reader := generalReader on: result readStream.
×
1967
        
×
1968
        ^ reader nextAs: #ArrayOfReleases
×
1969
]
×
1970

1971
{ #category : #'private - parsing' }
1972
GitlabModelImporter >> parseSubGroupResult: aResult [
×
1973

×
1974
        | reader |
×
1975
        reader := NeoJSONReader on: aResult readStream.
×
1976
        self configureReaderForGroup: reader.
×
1977
        ^ reader nextAs: #ArrayOfGroups
×
1978
]
×
1979

1980
{ #category : #'private - parsing' }
1981
GitlabModelImporter >> parseTagsResult: result [
×
1982
        |reader|
×
1983
        reader := generalReader on: result readStream.
×
1984
        
×
1985
        ^ reader nextAs: #ArrayOfTags
×
1986
]
×
1987

1988
{ #category : #'private - parsing' }
1989
GitlabModelImporter >> parseUserResult: result [
1✔
1990

1✔
1991
        | reader |
1✔
1992
        
1✔
1993
        reader := generalReader on: result readStream.
1✔
1994
        
1✔
1995
        ^ reader nextAs: GLHUser
1✔
1996

1✔
1997
        
1✔
1998

1✔
1999
]
1✔
2000

2001
{ #category : #'private - parsing' }
2002
GitlabModelImporter >> parseUsersResult: result [
×
2003

×
2004
        | reader |
×
2005
        
×
2006
        reader := generalReader on: result readStream.
×
2007
        
×
2008
        ^ reader nextAs: #ArrayOfUser
×
2009
        
×
2010
]
×
2011

2012
{ #category : #'import - projects' }
2013
GitlabModelImporter >> partiallyImportProject: aProjectID [
×
2014

×
2015
        | result projectResult |
×
2016
        ('Import project with id:  ' , aProjectID printString) recordInfo.
×
2017

×
2018
        (glhModel allWithType: GLHProject)
×
2019
                detect: [ :project | project id = aProjectID ]
×
2020
                ifFound: [ :project | ^ project ].
×
2021

×
2022
        result := self repoApi projects get: aProjectID.
×
2023
        projectResult := self parseProjectResult: result.
×
2024

×
2025
        projectResult repository: GLHRepository new.
×
2026
        self glhModel add: projectResult repository.
×
2027
        self importRepository: projectResult repository.
×
2028

×
2029
        ^ projectResult
×
2030
]
×
2031

2032
{ #category : #'import - pipelines' }
2033
GitlabModelImporter >> pipelinesOf: aProjectID after: after andBefore: before [
×
2034

×
2035
        | result |
×
2036
        ('Search pipelines of: ' , aProjectID printString) recordInfo.
×
2037
        
×
2038
        result := self repoApi pipelines getAllInProject: aProjectID 
×
2039
                                                                                                withParams: {        #updated_before -> before.
×
2040
                                                                                                                                        #updated_after -> after} asDictionary .
×
2041
        result isString ifTrue: [ ^ self parsePipelinesResult: result ].
×
2042

×
2043
        ^ (result collect: [ :pipelinesJson |
×
2044
                           self parsePipelinesResult: pipelinesJson ]) flattened
×
2045
]
×
2046

2047
{ #category : #'import - pipelines' }
2048
GitlabModelImporter >> pipelinesOf: aProjectID withLimit: aLimit [
1✔
2049

1✔
2050
        | result |
1✔
2051
        ('Search pipelines of: ' , aProjectID printString) recordInfo.
1✔
2052
        result := self repoApi pipelines getByPage: 1 perPage: aLimit inProject: aProjectID.
1✔
2053
        result isString ifTrue: [ ^ self parsePipelinesResult: result ].
1✔
2054

1✔
2055
        ^ (result collect: [ :pipelinesJson |
1✔
2056
                           self parsePipelinesResult: pipelinesJson ]) flattened
1✔
2057
]
1✔
2058

2059
{ #category : #accessing }
2060
GitlabModelImporter >> repoApi: anObject [
1✔
2061
        super repoApi: anObject.
1✔
2062
        self repoApi output: 'json'
1✔
2063
]
1✔
2064

2065
{ #category : #'search - merge request' }
2066
GitlabModelImporter >> searchMergeRequestMentionning: aString [ 
×
2067
        |mergeRequests results|
×
2068
        results := repoApi mergeRequests search: aString.
×
2069
        mergeRequests := self parseMergeRequestsResult: results.
×
2070
        mergeRequests :=        mergeRequests collect: [ :mr |
×
2071
                mr project: (self importProject: mr project_id).
×
2072
                mr
×
2073
                 ].
×
2074
        
×
2075
        ^ glhModel addAll: mergeRequests unless: self blockOnIdEquality. 
×
2076
]
×
2077

2078
{ #category : #private }
2079
GitlabModelImporter >> selectEntityType: aType overAttribut: aSelector equalTo: value [
×
2080

×
2081
        ^ (self glhModel allWithType: aType)
×
2082
                select: [ :entity | (entity perform: aSelector) = value ]
×
2083
]
×
2084

2085
{ #category : #'import - groups' }
2086
GitlabModelImporter >> subGroupsOf: aGroupID [
1✔
2087

1✔
2088
        | results subgroups |
1✔
2089
        ('Search subgroup of: ' , aGroupID printString) recordInfo.
1✔
2090
        results := self repoApi groups subgroupsOf: aGroupID.
1✔
2091
        subgroups := (results collect: [ :subgroupsJson | self parseSubGroupResult: subgroupsJson ]) flattened.
1✔
2092
        
1✔
2093
        ^ subgroups
1✔
2094
]
1✔
2095

2096
{ #category : #accessing }
2097
GitlabModelImporter >> withInitialCommits: boolean [
×
2098
        withInitialCommits := boolean 
×
2099
]
×
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