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

moosetechnology / GitProjectHealth / 15138400978

20 May 2025 01:09PM UTC coverage: 72.46% (-0.8%) from 73.222%
15138400978

Pull #196

github

web-flow
Merge 5333b1b84 into 118855527
Pull Request #196: Pipeline 2

781 of 1772 new or added lines in 15 files covered. (44.07%)

38 existing lines in 2 files now uncovered.

15984 of 22059 relevant lines covered (72.46%)

0.72 hits per line

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

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

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

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

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

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

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

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

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

51
{ #category : #private }
52
GitlabModelImporter >> chainsCommitsFrom: commitsCollection [
1✔
53

1✔
54
        | dic |
1✔
55
        
1✔
56
        ('Chains ', commitsCollection size printString , ' commits') recordInfo.
1✔
57
        
1✔
58
        dic := ((self glhModel allWithType: GLHCommit) collect: [ :commit |
1✔
59
                        commit id -> commit ]) asSet asDictionary.
1✔
60

1✔
61
        commitsCollection do: [ :commit |
1✔
62
                commit parent_ids do: [ :parentId | 
1✔
63
                        dic
1✔
64
                                at: parentId
1✔
65
                                ifPresent: [ :parentCommit |
1✔
66
                                        parentCommit childCommits
1✔
67
                                                add: commit
1✔
68
                                                unless: self blockOnIdEquality ]
1✔
69
                                ifAbsent: [  ] ] ].
1✔
70
        ^ commitsCollection
1✔
71
]
1✔
72

73
{ #category : #'import - commits' }
74
GitlabModelImporter >> commitsOfProject: aGLHProject forRefName: refName until: toDate [
×
75

×
76
        | params results allCommits |
×
77
        
×
78
        params := { 
×
79
                #ref_name -> refName.
×
80
                #until -> (toDate ifNotNil: [ toDate asDateAndTime asString ] ifNil: [ '' ]) 
×
81
        } asDictionary.
×
82
        results := self repoApi commits getAllInProject: aGLHProject id withParams: params.
×
83
        allCommits := (results collect: [ :commitsJson | self parseCommitsResult: commitsJson ]) flattened.
×
84
        
×
85
        self glhModel addAll: allCommits unless: self blockOnIdEquality.
×
86
        aGLHProject repository commits addAll: allCommits unless: self blockOnIdEquality.
×
87

×
88
        self withCommitDiffs ifTrue: [
×
89
                aGLHProject repository commits do: [ :commit |
×
90
                        self importDiffOfCommit: commit ] ].
×
91
        
×
92
        ^allCommits
×
93
]
×
94

95
{ #category : #'import - projects' }
UNCOV
96
GitlabModelImporter >> completeImportProject: aGLHProject [
×
UNCOV
97

×
UNCOV
98
        | importedProject |
×
UNCOV
99
        ('Complete import of project: ' , aGLHProject id printString)
×
UNCOV
100
                recordInfo.
×
UNCOV
101
        aGLHProject repository ifNotNil: [ ^ aGLHProject ].
×
UNCOV
102

×
UNCOV
103
        importedProject := self glhModel
×
UNCOV
104
                                   add: aGLHProject
×
UNCOV
105
                                   unless: self blockOnIdEquality.
×
UNCOV
106

×
NEW
107
        self importLatestPipelinesOfProject: importedProject.
×
UNCOV
108

×
UNCOV
109
        "aGLHProject creator: (self importUser: aGLHProject creator_id)."
×
UNCOV
110

×
UNCOV
111
        (self importUser: importedProject creator_id) addCreatedProject:
×
UNCOV
112
                importedProject.
×
UNCOV
113

×
UNCOV
114

×
UNCOV
115
        importedProject repository: GLHRepository new.
×
UNCOV
116
        self glhModel add: importedProject repository.
×
UNCOV
117
        self importRepository: importedProject repository.
×
UNCOV
118

×
UNCOV
119

×
UNCOV
120
        withInitialMergeRequest ifTrue: [
×
UNCOV
121
                self
×
UNCOV
122
                        importMergeRequests: importedProject
×
UNCOV
123
                        since: DateAndTime today
×
UNCOV
124
                        until: DateAndTime now ].
×
UNCOV
125

×
UNCOV
126
        ^ importedProject
×
UNCOV
127
        
×
UNCOV
128

×
UNCOV
129
]
×
130

131
{ #category : #'import - commits' }
132
GitlabModelImporter >> completeImportedCommit: aCommit [
1✔
133

1✔
134
        ('completing commit: ' , aCommit short_id printString) recordInfo.
1✔
135
        self importCreatorOfCommit: aCommit.
1✔
136

1✔
137
        self withCommitDiffs ifTrue: [
1✔
138
                | diffs |
1✔
139
                aCommit diffs ifEmpty: [
1✔
140
                        diffs := self importDiffOfCommit: aCommit.
1✔
141
                        self glhModel addAll: diffs unless: self blockForDiffEquality ] ].
1✔
142

1✔
143
        ^ aCommit
1✔
144
]
1✔
145

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

165
{ #category : #'import - projects' }
166
GitlabModelImporter >> completeImportedProject: aGLHProject [
1✔
167

1✔
168
        | importedProject |
1✔
169
        ('Complete import of project: ' , aGLHProject id printString)
1✔
170
                recordInfo.
1✔
171
        aGLHProject repository ifNotNil: [ ^ aGLHProject ].
1✔
172

1✔
173
        importedProject := self glhModel
1✔
174
                                   add: aGLHProject
1✔
175
                                   unless: self blockOnIdEquality.
1✔
176

1✔
177
        self importLatestPipelinesOfProject: importedProject.
1✔
178

1✔
179
        "aGLHProject creator: (self importUser: aGLHProject creator_id)."
1✔
180

1✔
181
        (self importUser: importedProject creator_id) addCreatedProject:
1✔
182
                importedProject.
1✔
183

1✔
184

1✔
185
        importedProject repository: GLHRepository new.
1✔
186
        self glhModel add: importedProject repository.
1✔
187
        self importRepository: importedProject repository.
1✔
188

1✔
189

1✔
190
        withInitialMergeRequest ifTrue: [
1✔
191
                self
1✔
192
                        importMergeRequests: importedProject
1✔
193
                        since: DateAndTime today
1✔
194
                        until: DateAndTime now ].
1✔
195

1✔
196
        ^ importedProject
1✔
197
        
1✔
198

1✔
199
]
1✔
200

201
{ #category : #'private - configure reader' }
202
GitlabModelImporter >> configureReaderForCommit: reader [
1✔
203

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

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

1✔
222
        reader
1✔
223
                for: #ArrayOfIds
1✔
224
                customDo: [ :mapping | mapping decoder: [ :string | string ] ].
1✔
225
  
1✔
226
        reader
1✔
227
                for: #ArrayOfCommit
1✔
228
                customDo: [ :customMappting |
1✔
229
                customMappting listOfElementSchema: GLHCommit ].
1✔
230

1✔
231
]
1✔
232

233
{ #category : #'private - configure reader' }
234
GitlabModelImporter >> configureReaderForDiffs: reader [
1✔
235

1✔
236
        reader for: GLHDiff do: [ :mapping |
1✔
237
                mapping mapInstVars:
1✔
238
                        #( deleted_file new_file new_path old_path renamed_file ).
1✔
239
                mapping mapInstVar: #diffString to: #diff ].
1✔
240

1✔
241
        reader
1✔
242
                for: #ArrayOfDiffs
1✔
243
                customDo: [ :customMappting |
1✔
244
                customMappting listOfElementSchema: GLHDiff ].
1✔
245
        ^ reader
1✔
246
]
1✔
247

248
{ #category : #'private - configure reader' }
249
GitlabModelImporter >> configureReaderForGroup: reader [
1✔
250

1✔
251
        reader for: GLHGroup do: [ :mapping |
1✔
252
                mapping mapInstVars.
1✔
253
                (mapping mapInstVar: #projects) valueSchema: #ArrayOfProjects ].
1✔
254
        reader mapInstVarsFor: GLHProject.
1✔
255
        reader
1✔
256
                for: #ArrayOfProjects
1✔
257
                customDo: [ :customMappting |
1✔
258
                customMappting listOfElementSchema: GLHProject ].
1✔
259
        reader
1✔
260
                for: #ArrayOfGroups
1✔
261
                customDo: [ :customMappting |
1✔
262
                customMappting listOfElementSchema: GLHGroup ]
1✔
263
]
1✔
264

265
{ #category : #'private - configure reader' }
266
GitlabModelImporter >> configureReaderForMergeRequest: reader [
1✔
267
        "declare quil y a un array a mapper"
1✔
268

1✔
269
        reader for: #ArrayOfMergeRequest customDo: [ :customMappting |
1✔
270
                customMappting listOfElementSchema: GLHMergeRequest ].
1✔
271

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

1✔
306
        "(mapping mapInstVar: #closed_by) valueSchema: GLHUser.
1✔
307
        (mapping mapInstVar: #mergeCommit) valueSchema: GLHCommit."
1✔
308
        "indique ce que doit faire le reader lorsqu'il parse une DateAndTime object"
1✔
309
        reader for: DateAndTime customDo: [ :mapping |
1✔
310
                mapping decoder: [ :string |
1✔
311
                        string ifNil: [ nil ] ifNotNil: [ DateAndTime fromString: string ] ] ]
1✔
312
]
1✔
313

314
{ #category : #'private - configure reader' }
315
GitlabModelImporter >> configureReaderForPipeline: reader [
1✔
316

1✔
317
        reader mapInstVarsFor: GLHPipeline.
1✔
318
        
1✔
319
        reader for: GLHPipeline do: [ :mapping |
1✔
320

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

378
{ #category : #private }
379
GitlabModelImporter >> convertApiFileAsFile: aAPIFile [
×
380

×
381
        aAPIFile type = 'tree' ifTrue: [ 
×
382
                ^ GLHFileDirectory new
×
383
                          name: aAPIFile name;
×
384
                          yourself ].
×
385
        ^ GLHFileBlob new
×
386
                  name: aAPIFile name;
×
387
                  yourself
×
388
]
×
389

390
{ #category : #private }
391
GitlabModelImporter >> detectEntityType: aType overAttribut: aSelector equalTo: value [
1✔
392

1✔
393
        ^ (self glhModel allWithType: aType) detect: [ :entity |
1✔
394
                  (entity perform: aSelector) = value ] ifNone: [ nil ]. 
1✔
395
]
1✔
396

397
{ #category : #accessing }
398
GitlabModelImporter >> glhApi [
×
399

×
400
        self
×
401
                deprecated: 'Use #repoApi instead'
×
402
                on: '7 October 2024'
×
403
                in:
×
404
                'Pharo-11.0.0+build.726.sha.aece1b5473acf3830a0e082c1bc3a15d4ff3522b (64 Bit)'.
×
405

×
406
        ^ repoApi
×
407
]
×
408

409
{ #category : #accessing }
410
GitlabModelImporter >> glhApi: anObject [
×
411

×
412
        self
×
413
                deprecated: 'Use #repoApi: instead'
×
414
                on: '7 October 2024'
×
415
                in:
×
416
                'Pharo-11.0.0+build.726.sha.aece1b5473acf3830a0e082c1bc3a15d4ff3522b (64 Bit)'.
×
417

×
418
        repoApi := anObject
×
419
]
×
420

421
{ #category : #accessing }
422
GitlabModelImporter >> glhModel [
1✔
423

1✔
424
        ^ glhModel
1✔
425
]
1✔
426

427
{ #category : #accessing }
428
GitlabModelImporter >> glhModel: anObject [
1✔
429

1✔
430
        glhModel := anObject
1✔
431
]
1✔
432

433
{ #category : #'import - users' }
434
GitlabModelImporter >> importActiveHumanUsers [
×
435

×
436
        | params result users |
×
437
        params := { 
×
438
                #humans -> 'true'.
×
439
                #active -> 'true'.
×
440
                #without_project_bots -> 'true'
×
441
        } asDictionary.
×
442
        result := self repoApi users allWithParams: params.
×
443
        users := (result collect: [ :usersJson | self parseUsersResult: usersJson ]) flattened.
×
444
        
×
445
        self glhModel
×
446
                                 addAll: users
×
447
                                 unless: self blockOnIdEquality.
×
448

×
449
        ^ users
×
450
]
×
451

452
{ #category : #'import - groups' }
453
GitlabModelImporter >> importAllGroups [
×
454

×
455
        | params results groups |
×
456
        
×
457
        params := { 
×
458
                        #top_level_only -> 'true'
×
459
        } asDictionary.
×
460
        results := self repoApi groups getAllWithParams: params.
×
461
        
×
462
        groups := (results collect: [ :groupsJson | generalReader
×
463
                                            on: groupsJson readStream;
×
464
                                            nextAs: #ArrayOfGroups. ]) flattened.
×
465
        ^ groups
×
466
]
×
467

468
{ #category : #'import - pipelines' }
NEW
469
GitlabModelImporter >> importAllPipelinesOfProject: aGLHProject [
×
NEW
470

×
NEW
471
        (self allPipelinesOf: aGLHProject id) do: [ :pipeline |
×
NEW
472
                |pip|
×
NEW
473
                pip := self glhModel add: pipeline unless: self blockOnIdEquality .
×
NEW
474
                pip := aGLHProject pipelines add: pip unless: self blockOnIdEquality.
×
NEW
475
                self completeImportedPipeline: pip. 
×
NEW
476
                ].
×
NEW
477
        
×
NEW
478
        ^ aGLHProject pipelines
×
NEW
479
]
×
480

481
{ #category : #'import - commits' }
482
GitlabModelImporter >> importAndLoadLatestsCommitsOfProject: aGLHProject [
×
483

×
484
        | commits completedProject |
×
NEW
485
        completedProject := self completeImportedProject: aGLHProject.
×
486
        commits := self importLastestCommitsOfProject: completedProject.
×
487
        commits do: [ :commit | self completeImportedCommit: commit ].
×
488
        self chainsCommitsFrom: commits.
×
489
        ^ commits
×
490
]
×
491

492
{ #category : #'import - commits' }
493
GitlabModelImporter >> importCommit: aCommitID ofProject: aGLHProject [
×
494

×
495
        | result parsedResult |
×
496
        (self glhModel allWithType: GLHCommit) asOrderedCollection
×
497
                detect: [ :commit | commit id = aCommitID ]
×
498
                ifFound: [ :commit | ^ commit ].
×
499
        result := self repoApi commits get: aCommitID inProject: aGLHProject id.
×
500
        
×
501
        parsedResult := self parseCommitResult: result.
×
502
        
×
503
        self
×
504
                addCommits: { parsedResult }
×
505
                toRepository: aGLHProject repository.
×
506
        ^ parsedResult
×
507
]
×
508

509
{ #category : #'import - commits' }
510
GitlabModelImporter >> importCommitOfProject: anProject withId: anID [
1✔
511

1✔
512
        | commit result |
1✔
513
        anID ifNil: [ ^ nil ].
1✔
514

1✔
515
        ('looking for commit ' , anID printString , ' in project : '
1✔
516
         , anProject id printString) recordInfo.
1✔
517

1✔
518
        commit := (self
1✔
519
                           detectEntityType: GLHCommit
1✔
520
                           overAttribut: #id
1✔
521
                           equalTo: anID) ifNil: [
1✔
522
                          result := self repoApi commits get: anID inProject: anProject id.
1✔
523
                          commit := (self parseCommitsResult: '[' , result , ']')
1✔
524
                                            first.
1✔
525

1✔
526
                          self glhModel add: commit unless: self blockOnIdEquality.
1✔
527
                          commit repository: anProject repository.
1✔
528

1✔
529
                          commit ].
1✔
530

1✔
531
        self withCommitDiffs ifTrue: [ self importDiffOfCommit: commit ].
1✔
532

1✔
533
        ^ commit
1✔
534
]
1✔
535

536
{ #category : #'import - commits' }
537
GitlabModelImporter >> importCommits: aGLHProject [
×
538
        "limited to the last 20 commits"
×
539

×
540
        | results parsedResults params |
×
541
        params := { 
×
542
         #with_stats -> 'true'
×
543
        } asDictionary.
×
544
        results := self repoApi commits getByPage: 1 perPage: 20 inProject: aGLHProject id withParams: params.
×
545
        
×
546
        parsedResults := self parseCommitsResult: results.
×
547
        self glhModel addAll: parsedResults unless: self blockOnIdEquality.
×
548

×
549
        parsedResults do: [ :commit |
×
550
                commit repository: aGLHProject repository ].
×
551

×
552
        self withCommitDiffs ifTrue: [
×
553
                parsedResults do: [ :commit | self importDiffOfCommit: commit ] ].
×
554
        
×
555
        ^ parsedResults. 
×
556
]
×
557

558
{ #category : #'import - commits' }
559
GitlabModelImporter >> importCommitsFollowing: aCommit upToDays: aNumberOfDay [
×
560
        "import the 'n' commits of a project starting from an initial 'aCommit' commit. 
×
561
        Lazy import does not import the entities inside the model"
×
562

×
563
        | date |
×
564
        date := aCommit created_at asDateAndTime.
×
565

×
566
        ^ self
×
567
                  importCommitsOfBranch: aCommit branch
×
568
                  forRefName: aCommit branch name
×
569
                  since: date
×
570
                  until: (date + aNumberOfDay day)
×
571
]
×
572

573
{ #category : #commit }
574
GitlabModelImporter >> importCommitsOf: aGLHProject withStats: aBoolean until: toDate [
×
575

×
576
        | newlyFoundCommit page |
×
577
        
×
578
        self deprecated: [  ] .
×
579
        
×
580
        page := 0.
×
581
        newlyFoundCommit := { true }.
×
582
        [ newlyFoundCommit isNotEmpty ] whileTrue: [
×
583
                | results parsedResults existingCommits |
×
584
                page := page + 1.
×
585
                ('import commit page ' , page printString) recordInfo.
×
586
                results := self repoApi
×
587
                                   commitsOfProject: aGLHProject id
×
588
                                   forRefName: nil
×
589
                                   since: nil
×
590
                                   until: nil
×
591
                                   path: nil
×
592
                                   author: nil
×
593
                                   all: nil
×
594
                                   with_stats: aBoolean
×
595
                                   firstParent: nil
×
596
                                   order: nil
×
597
                                   trailers: nil
×
598
                                   perPage: 100
×
599
                                   page: page.
×
600
                parsedResults := self parseCommitsResult: results.
×
601
                existingCommits := aGLHProject mooseModel allWithType: GLHCommit.
×
602

×
603
                newlyFoundCommit := parsedResults reject: [ :commitParsed |
×
604
                                            (toDate isNil or: [
×
605
                                                     commitParsed committed_date
×
606
                                                     < toDate asDateAndTime ]) or: [
×
607
                                                    existingCommits anySatisfy: [ :existingCommit |
×
608
                                                            existingCommit id = commitParsed id ] ] ].
×
609
                aGLHProject mooseModel addAll: newlyFoundCommit.
×
610
                aGLHProject repository commits addAll: newlyFoundCommit ].
×
611

×
612

×
613
        self withCommitDiffs ifTrue: [
×
614
                aGLHProject repository commits do: [ :commit |
×
615
                        self importDiffOfCommit: commit ] ]
×
616
]
×
617

618
{ #category : #'import - commits' }
619
GitlabModelImporter >> importCommitsOfBranch: aGLHBranch [
×
620

×
621
        | commits |
×
622
        "        result := self glhApi
×
623
                          commitsOfProject: aGLHBranch repository project id
×
624
                          forRefName: aGLHBranch name."
×
625
        commits := self
×
626
                           importCommitsOfBranch: aGLHBranch
×
627
                           forRefName: aGLHBranch name
×
628
                           since: withCommitsSince.
×
629

×
630
        self chainsCommitsFrom: commits.
×
631

×
632
        commits do: [ :aCommit |
×
633
                aCommit repository: aGLHBranch repository.
×
634
                self completeImportedCommit: aCommit. 
×
635
                 ]
×
636
]
×
637

638
{ #category : #'import - commits' }
639
GitlabModelImporter >> importCommitsOfBranch: aGLHBranch forRefName: refName since: fromDate [
×
640

×
641
        ^ self
×
642
                  importCommitsOfBranch: aGLHBranch
×
643
                  forRefName: aGLHBranch name
×
644
                  since: fromDate
×
645
                  until: nil
×
646
]
×
647

648
{ #category : #'import - commits' }
649
GitlabModelImporter >> importCommitsOfBranch: aGLHBranch forRefName: refName since: fromDate until: toDate [
×
650

×
651
        | params result allCommits |
×
652
        params := { 
×
653
          #ref_name -> aGLHBranch name.
×
654
          #since ->  (fromDate ifNotNil: [ fromDate asDate asDateAndTime asString ] ifNil: [ '' ]).
×
655
          #until -> (toDate ifNotNil: [ toDate asDate asDateAndTime asString ] ifNil: [ '' ]). 
×
656

×
657
        } asDictionary.
×
658
        result := self repoApi commits getAllInProject: aGLHBranch repository project id withParams: params.
×
659
        
×
660
        allCommits := (result collect: [ :commitsJson | self parseCommitsResult: commitsJson ]) flattened.
×
661
        
×
662
        aGLHBranch commits
×
663
                        addAll: allCommits
×
664
                        unless: self blockOnIdEquality.
×
665

×
666
        self glhModel
×
667
                addAll: aGLHBranch commits
×
668
                unless: self blockOnIdEquality.
×
669

×
670
        ^ allCommits
×
671
]
×
672

673
{ #category : #'import - commits' }
674
GitlabModelImporter >> importCommitsOfBranch: aGLHBranch forRefName: refName until: toDate [
×
675

×
676
        ^ self
×
677
                  importCommitsOfBranch: aGLHBranch
×
678
                  forRefName: aGLHBranch name
×
679
                  since: nil
×
680
                  until: toDate
×
681
]
×
682

683
{ #category : #'import - commits' }
684
GitlabModelImporter >> importCommitsOfProject: aProject since: fromDate until: toDate [
1✔
685

1✔
686
        | params results allCommits |
1✔
687
        params := {
1✔
688
                          (#since
1✔
689
                           ->
1✔
690
                           (fromDate
1✔
691
                                    ifNotNil: [ fromDate asDate asDateAndTime asString ]
1✔
692
                                    ifNil: [ '' ])).
1✔
693
                          (#until
1✔
694
                           ->
1✔
695
                           (toDate
1✔
696
                                    ifNotNil: [ toDate asDate asDateAndTime asString ]
1✔
697
                                    ifNil: [ '' ])).
1✔
698
                          (#with_stats -> 'true').
1✔
699
                          (#all -> 'true') } asDictionary.
1✔
700
        results := self repoApi commits
1✔
701
                           getAllInProject: aProject id
1✔
702
                           withParams: params.
1✔
703

1✔
704
        allCommits := (results collect: [ :commitsJson |
1✔
705
                               self parseCommitsResult: commitsJson ]) flattened.
1✔
706

1✔
707
        allCommits:= aProject repository commits
1✔
708
                addAll: allCommits
1✔
709
                unless: self blockOnIdEquality.
1✔
710

1✔
711
        ^ self glhModel addAll: allCommits unless: self blockOnIdEquality
1✔
712
]
1✔
713

714
{ #category : #'import - projects' }
715
GitlabModelImporter >> importContributedProjectsOfUser: aGLHUser [
×
716

×
717
        | remaningProjects params results projects projectsIds |
×
718
        params := {
×
719
                          (#order_by -> 'last_activity_at').
×
720
                          (#simple -> 'true') } asDictionary.
×
721
        results := self repoApi projects
×
722
                           contributedProjectsOfUser: aGLHUser id
×
723
                           withParams: params.
×
724

×
725
        projectsIds := (results collect: [ :projectsJson |
×
726
                             (NeoJSONReader fromString: projectsJson) collect: [:projectJson | projectJson at: #id ] ]) flattened.
×
727
        
×
728
        projects := self importProjects: projectsIds.
×
729
        remaningProjects := self importProjects:
×
730
                                    ((projects collect: #id) difference:
×
731
                                             ((self userCatalogue atId: aGLHUser id) at:
×
732
                                                      #contributedProjects)).
×
733

×
734

×
735
        aGLHUser contributedProjects
×
736
                addAll: projects , remaningProjects
×
737
                unless: self blockOnIdEquality.
×
738

×
739
        self userCatalogue
×
740
                addUser: aGLHUser
×
741
                withProjects: (aGLHUser contributedProjects collect: #id).
×
742

×
743
        ^ projects
×
744
]
×
745

746
{ #category : #'import - commits' }
747
GitlabModelImporter >> importCreatorOfCommit: aCommit [
1✔
748

1✔
749
        aCommit commitCreator ifNil: [
1✔
750
                aCommit commitCreator:
1✔
751
                        (self importUserByUsername: aCommit author_name) ].
1✔
752
        self userCatalogue
1✔
753
                addUser: aCommit commitCreator
1✔
754
                withProject: aCommit repository project id.
1✔
755
        ^ aCommit commitCreator
1✔
756
]
1✔
757

758
{ #category : #'import - commits' }
759
GitlabModelImporter >> importDiffOfCommit: aCommit [
1✔
760

1✔
761
        | result diffsResult |
1✔
762
        aCommit diffs ifNotEmpty: [
1✔
763
                'Diff already importer: ' , aCommit short_id printString recordInfo.
1✔
764
                ^ aCommit diffs ].
1✔
765
        ('Import diff of commit: ' , aCommit short_id printString) recordInfo.
1✔
766

1✔
767
        result := self repoApi commits
1✔
768
                          diffOf: aCommit id
1✔
769
                          inProject: aCommit repository project id
1✔
770
                          uniDiff: true.
1✔
771

1✔
772
        (self isServerError: result) ifTrue: [ ^ {  } ].
1✔
773
        diffsResult := self newParseDiffResult: result.
1✔
774

1✔
775
        aCommit diffs addAll: diffsResult unless: self blockForDiffEquality.
1✔
776
        
1✔
777
        "changes are added into the model during the import"
1✔
778
        aCommit diffs do: [ :diff | self importDiffRangesForDiff: diff ].
1✔
779

1✔
780
        ^ aCommit diffs
1✔
781
]
1✔
782

783
{ #category : #'import - merge request' }
784
GitlabModelImporter >> importDiffOfMergeRequest: aMergeRequest [
1✔
785

1✔
786
        | result diffsResult |
1✔
787
        aMergeRequest diffs ifNotEmpty: [
1✔
788
                'Diff of already importer: '
1✔
789
                , aMergeRequest iid printString recordInfo.
1✔
790
                ^ aMergeRequest diffs ].
1✔
791
        ('Import diff commits of MR ' , aMergeRequest iid printString)
1✔
792
                recordInfo.
1✔
793
        result := self repoApi mergeRequests diffsOf: aMergeRequest iid inProject: aMergeRequest project_id.
1✔
794

1✔
795
        diffsResult := self newParseDiffResult: result.
1✔
796

1✔
797

1✔
798
        aMergeRequest diffs
1✔
799
                addAll: diffsResult
1✔
800
                unless: self blockForDiffEquality.
1✔
801
        self glhModel
1✔
802
                addAll: aMergeRequest diffs
1✔
803
                unless: self blockForDiffEquality.
1✔
804

1✔
805
        aMergeRequest diffs do: [ :diff | self importDiffRangesForDiff: diff ].
1✔
806

1✔
807
        ^ aMergeRequest diffs
1✔
808
]
1✔
809

810
{ #category : #'import - repositories' }
811
GitlabModelImporter >> importDirectoryFiles: aDirectoryFile OfBranch: aBranch [
×
812

×
813
        | result files apiFiles params |
×
814
        params := { 
×
815
                #ref -> aBranch name.
×
816
                #path -> (aDirectoryFile path , '/')
×
817
        } asDictionary.
×
818
        result := self repoApi repositories repositoryTreeOfProject: aBranch repository project id withParams: params.
×
819
                         " treeOfRepository: aBranch repository project id
×
820
                          ofBranch: aBranch name
×
821
                          andPath: aDirectoryFile path , '/'."
×
822
        apiFiles := (result collect: [ :treeJson | self parseFileTreeResult: treeJson ]) flattened.
×
823
        files := apiFiles collect: [ :apiFile |
×
824
                         self convertApiFileAsFile: apiFile ].
×
825
        
×
826
        files do: [ :file |
×
827
                self glhModel add: file.
×
828
                aDirectoryFile addFile: file ].
×
829
        
×
830
        files
×
831
                select: [ :file | file isKindOf: GLHFileDirectory ]
×
832
                thenCollect: [ :file |
×
833
                self importDirectoryFiles: file OfBranch: aBranch ]
×
834
]
×
835

836
{ #category : #'import - repositories' }
837
GitlabModelImporter >> importFilesOfBranch: aBranch [
×
838

×
839
        | result files apiFiles params |
×
840
        params := { 
×
841
                #ref -> aBranch name.
×
842
        } asDictionary.
×
843
        
×
844
        result := self repoApi repositories repositoryTreeOfProject: aBranch repository project id withParams: params.
×
845
        
×
846
                          "treeOfRepository: aBranch repository project id
×
847
                          ofBranch: aBranch name
×
848
                          andPath: nil."
×
849
        apiFiles := (result collect: [ :filesJson | self parseFileTreeResult: filesJson  ]) flattened.
×
850
        files := apiFiles collect: [ :apiFile | 
×
851
                         self convertApiFileAsFile: apiFile ].
×
852
        files do: [ :file | 
×
853
                self glhModel add: file.
×
854
                aBranch addFile: file ].
×
855
        files
×
856
                select: [ :file | file isKindOf: GLHFileDirectory ]
×
857
                thenCollect: [ :file | 
×
858
                self importDirectoryFiles: file OfBranch: aBranch ]
×
859
]
×
860

861
{ #category : #'import - groups' }
862
GitlabModelImporter >> importGroup: aGroupID [
1✔
863

1✔
864
        | result groupResult |
1✔
865
        ('Import group: ' , aGroupID printString) recordInfo.
1✔
866

1✔
867
        result := self repoApi groups get: aGroupID.
1✔
868
        
1✔
869
        "group: aGroupID."
1✔
870
        groupResult := self parseGroupResult: result.
1✔
871
        groupResult := self addGroupResultToModel: groupResult.
1✔
872

1✔
873
        groupResult projects do: [ :project |
1✔
874
                self completeImportedProject: project ].
1✔
875

1✔
876
        (self subGroupsOf: aGroupID) do: [ :subGroup |
1✔
877
                
1✔
878
                groupResult subGroups
1✔
879
                        add: (self importGroup: subGroup id)
1✔
880
                        unless: self blockOnIdEquality ].
1✔
881
        ^ groupResult
1✔
882
]
1✔
883

884
{ #category : #'import - jobs' }
885
GitlabModelImporter >> importJobsOf: aPipeline [
×
886

×
887
        | jobs results |
×
NEW
888
        results := self repoApi jobs
×
NEW
889
                           getAllForPipeline: aPipeline id
×
NEW
890
                           inProject: aPipeline project id.
×
NEW
891
        "jobsOfProject: aPipeline project id
×
892
                          ofPipelines: aPipeline id."
×
NEW
893
        jobs := (results collect: [ :jobsJson |
×
NEW
894
                         self parseJobsResult: jobsJson ofProject: aPipeline project ])
×
NEW
895
                        flattened.
×
896
        jobs do: [ :job | aPipeline addJob: job ].
×
897
        self glhModel addAll: jobs.
×
898

×
NEW
899
        ^ jobs
×
UNCOV
900
]
×
901

902
{ #category : #'import - commits' }
903
GitlabModelImporter >> importLastestCommitsOfProject: aGLHProject [
1✔
904
        "limited to the last 50 commits"
1✔
905

1✔
906
        | results parsedResults params |
1✔
907
        params := { 
1✔
908
                #with_stats -> 'true'.
1✔
909
                #all -> true
1✔
910
         } asDictionary.
1✔
911
        results := self repoApi commits getByPage: 1 perPage: 50 inProject: aGLHProject id withParams: params.
1✔
912

1✔
913
        parsedResults := self parseCommitsResult: results.
1✔
914
        parsedResults := self glhModel
1✔
915
                                 addAll: parsedResults
1✔
916
                                 unless: self blockOnIdEquality.
1✔
917

1✔
918
        aGLHProject repository commits
1✔
919
                addAll: parsedResults
1✔
920
                unless: self blockOnIdEquality.
1✔
921

1✔
922
        self withCommitDiffs ifTrue: [
1✔
923
                parsedResults do: [ :commit | self importDiffOfCommit: commit ] ].
1✔
924

1✔
925
        ^ parsedResults
1✔
926
]
1✔
927

928
{ #category : #'import - merge request' }
NEW
929
GitlabModelImporter >> importLatestMergeRequestsOfProject: aGLHProject [ 
×
NEW
930
        
×
NEW
931
        |results parsedResults|
×
NEW
932
        results := self repoApi mergeRequests getByPage: 1 perPage: 20  inProject: aGLHProject id. 
×
NEW
933
        parsedResults := self parseMergeRequestsResult: results. 
×
NEW
934
        
×
NEW
935
        parsedResults := glhModel addAll: parsedResults unless: self blockOnIdEquality.
×
NEW
936
        parsedResults := aGLHProject mergeRequests addAll: parsedResults unless: self blockOnIdEquality.
×
NEW
937
        ^ parsedResults.
×
NEW
938
]
×
939

940
{ #category : #'import - pipelines' }
941
GitlabModelImporter >> importLatestPipelinesOfProject: aGLHProject [ 
1✔
942
        (self pipelinesOf: aGLHProject id withLimit:30) do: [ :pipeline |
1✔
943
                |pip|
1✔
944
                pip := self glhModel add: pipeline unless: self blockOnIdEquality .
1✔
945
                pip := aGLHProject pipelines add: pip unless: self blockOnIdEquality.
1✔
946
                self completeImportedPipeline: pip. 
1✔
947
                ].
1✔
948
        
1✔
949
        ^ aGLHProject pipelines 
1✔
950
]
1✔
951

952
{ #category : #'import - merge request' }
953
GitlabModelImporter >> importMergeRequestCommits: aGLPHEMergeRequest [
×
954

×
955
        | commits result |
×
956
        aGLPHEMergeRequest commits ifNotNil: [ ^ aGLPHEMergeRequest commits ].
×
957
        
×
958
        result := self repoApi mergeRequests commitsOf: aGLPHEMergeRequest iid inProject: aGLPHEMergeRequest project id.
×
959
        
×
960
        commits := (result collect: [ :commitsJson | self parseCommitsResult: commitsJson ]) flattened.
×
961
        commits := commits collect: [ :commit | self importCommit: commit id ofProject: aGLPHEMergeRequest project ].
×
962
        aGLPHEMergeRequest commits: commits.
×
963

×
964

×
965
        ^ commits
×
966
]
×
967

968
{ #category : #'import - merge request' }
969
GitlabModelImporter >> importMergeRequestMergeCommits: aGLPHEMergeRequest [
1✔
970

1✔
971
        | foundCommits |
1✔
972
        foundCommits := OrderedCollection new.
1✔
973

1✔
974
        ('Import commit sha of MR:  ' , aGLPHEMergeRequest iid printString)
1✔
975
                recordInfo.
1✔
976
        "the founds commits are added to the model during their respective import"
1✔
977
        aGLPHEMergeRequest mergeRequestCommit: ((self
1✔
978
                          importCommitOfProject: aGLPHEMergeRequest project
1✔
979
                          withId: aGLPHEMergeRequest sha) ifNotNil: [ :commit |
1✔
980
                         foundCommits add: commit ]).
1✔
981

1✔
982
        ('Import commit merge_commit_sha of MR:  '
1✔
983
         , aGLPHEMergeRequest iid printString) recordInfo.
1✔
984
        aGLPHEMergeRequest mergedCommit: ((self
1✔
985
                          importCommitOfProject: aGLPHEMergeRequest project
1✔
986
                          withId: aGLPHEMergeRequest merge_commit_sha) ifNotNil: [ :commit |
1✔
987
                         foundCommits add: commit ]).
1✔
988

1✔
989
        ('Import commit squash_commit_sha of MR:  '
1✔
990
         , aGLPHEMergeRequest iid printString) recordInfo.
1✔
991
        aGLPHEMergeRequest squashCommit: ((self
1✔
992
                          importCommitOfProject: aGLPHEMergeRequest project
1✔
993
                          withId: aGLPHEMergeRequest squash_commit_sha) ifNotNil: [ :commit |
1✔
994
                         foundCommits add: commit ]).
1✔
995

1✔
996

1✔
997
        self chainsCommitsFrom: foundCommits.
1✔
998
        ^ foundCommits
1✔
999
]
1✔
1000

1001
{ #category : #'import - pipelines' }
NEW
1002
GitlabModelImporter >> importMergeRequestPipelines: aGLHMergeRequest [ 
×
NEW
1003
        "default limit to one page with last 20 pipelines"
×
NEW
1004
        
×
NEW
1005
        |results parseResults|
×
NEW
1006
        
×
NEW
1007
        results := self repoApi pipelines getByPage: 1 perPage: 20 inProject: aGLHMergeRequest project id forMergerRequestIid: aGLHMergeRequest iid. 
×
NEW
1008
        
×
NEW
1009
        parseResults := self parsePipelinesResult: results.
×
NEW
1010
        
×
NEW
1011
        parseResults := glhModel addAll: parseResults unless: self blockOnIdEquality.
×
NEW
1012
        parseResults := aGLHMergeRequest pipelines addAll: parseResults unless: self blockOnIdEquality.
×
NEW
1013
        ^ parseResults collect: [ :pip | self completeImportedPipeline: pip ]  .
×
NEW
1014
        
×
NEW
1015
]
×
1016

1017
{ #category : #'import - merge request' }
1018
GitlabModelImporter >> importMergeRequests: aGLHProject [
1✔
1019

1✔
1020
        | results parsedResults mrs |
1✔
1021
        ('Import merge request of Project: ' , aGLHProject id printString)
1✔
1022
                recordInfo.
1✔
1023

1✔
1024
        results := self repoApi mergeRequests allOfProject: aGLHProject id.
1✔
1025
        parsedResults := (results collect: [ :projectsJson | self parseMergeRequestsResult: projectsJson ]) flattened. 
1✔
1026

1✔
1027
        aGLHProject mergeRequests
1✔
1028
                addAll: parsedResults
1✔
1029
                unless: self blockOnIdEquality.
1✔
1030

1✔
1031
        mrs := self glhModel
1✔
1032
                       addAll: aGLHProject mergeRequests
1✔
1033
                       unless: self blockOnIdEquality.
1✔
1034

1✔
1035

1✔
1036
        "gets it related commits"
1✔
1037
        aGLHProject mergeRequests do: [ :mr |
1✔
1038
                self importMergeRequestMergeCommits: mr ].
1✔
1039

1✔
1040

1✔
1041
        self withCommitDiffs ifTrue: [
1✔
1042
                aGLHProject mergeRequests do: [ :mr |
1✔
1043
                        self importDiffOfMergeRequest: mr ] ].
1✔
1044

1✔
1045
        ^ mrs
1✔
1046
]
1✔
1047

1048
{ #category : #'import - merge request' }
1049
GitlabModelImporter >> importMergeRequests: aGLHProject since: fromDate until: toDate [
×
1050

×
1051
        | params result mergeRequests |
×
1052
        ('import MR of Project ' , aGLHProject name) recordInfo.
×
1053
        params := {
×
1054
                          (#created_after
×
1055
                           ->
×
1056
                           (fromDate
×
1057
                                    ifNotNil: [ fromDate asDateAndTime asString ]
×
1058
                                    ifNil: [ '' ])).
×
1059
                          (#created_before
×
1060
                           ->
×
1061
                           (toDate
×
1062
                                    ifNotNil: [ toDate asDateAndTime asString ]
×
1063
                                    ifNil: [ '' ])).
×
1064
                          (#scope -> 'all') } asDictionary.
×
1065

×
1066
        result := self repoApi mergeRequests
×
1067
                          allOfProject: aGLHProject id
×
1068
                          withParams: params.
×
1069
        mergeRequests := (result collect: [ :mergeRequestsJson |
×
NEW
1070
                                  self parseMergeRequestsResult: mergeRequestsJson ])
×
1071
                                 flattened.
×
1072

×
1073
        aGLHProject mergeRequests
×
1074
                addAll: mergeRequests
×
1075
                unless: self blockOnIdEquality.
×
1076

×
1077
        "gets it related commits"
×
1078
        aGLHProject mergeRequests do: [ :mr |
×
1079
                self importMergeRequestMergeCommits: mr ].
×
1080

×
1081
        self withCommitDiffs ifTrue: [
×
1082
                aGLHProject mergeRequests do: [ :mr |
×
1083
                        self importDiffOfMergeRequest: mr ] ].
×
1084

×
1085
        self glhModel
×
1086
                addAll: mergeRequests
×
1087
                unless: (self blockEqualityOn: #iid).
×
1088

×
1089
        ^ mergeRequests
×
1090
]
×
1091

1092
{ #category : #'import - merge request' }
1093
GitlabModelImporter >> importMergeResquestApprovals: aGLPHEMergeRequest [
×
1094

×
1095
        | results parsedResult |
×
1096
        (String streamContents: [ :str |
×
1097
                 str << 'Check approvals of '.
×
1098
                 aGLPHEMergeRequest printOn: str ]) recordInfo.
×
1099
        results := self repoApi mergeRequests approvalsOf: aGLPHEMergeRequest iid inProject: aGLPHEMergeRequest project id.
×
1100

×
1101
        parsedResult := generalReader
×
1102
                                on: results readStream;
×
1103
                                next.
×
1104

×
1105
        (parsedResult at: #approved_by) do: [ :approvedUser |
×
1106
                aGLPHEMergeRequest addApproved_by:
×
1107
                        (self importUser: ((approvedUser at: #user) at: #id)) ].
×
1108
        aGLPHEMergeRequest approved: (parsedResult at: #approved).
×
1109
        ^ aGLPHEMergeRequest
×
1110
]
×
1111

1112
{ #category : #'import - merge request' }
1113
GitlabModelImporter >> importMergeResquestAuthor: aGLPHEMergeRequest [
1✔
1114

1✔
1115
        | authorID |
1✔
1116
        aGLPHEMergeRequest author ifNotNil: [ ^ aGLPHEMergeRequest author ].
1✔
1117
        authorID := aGLPHEMergeRequest cacheAt: #authorID ifAbsent: [
1✔
1118
                            | result |
1✔
1119
                            result := self repoApi mergeRequests
1✔
1120
                                              get: aGLPHEMergeRequest iid
1✔
1121
                                              inProject: aGLPHEMergeRequest project_id.
1✔
1122

1✔
1123
                            (generalReader
1✔
1124
                                     on: result readStream;
1✔
1125
                                     next) at: #author at: #id ].
1✔
1126
        ^aGLPHEMergeRequest author: (self importUser: authorID)
1✔
1127
]
1✔
1128

1129
{ #category : #'import - merge request' }
1130
GitlabModelImporter >> importMergeResquestMerger: aGLPHEMergeRequest [
1✔
1131

1✔
1132
        | authorID |
1✔
1133
        aGLPHEMergeRequest merge_user ifNotNil: [
1✔
1134
                ^ aGLPHEMergeRequest merge_user ].
1✔
1135
        authorID := aGLPHEMergeRequest cacheAt: #mergeUserID ifAbsent: [
1✔
1136
                            | result |
1✔
1137
                            result := self repoApi mergeRequests
1✔
1138
                                              get: aGLPHEMergeRequest iid
1✔
1139
                                              inProject: aGLPHEMergeRequest project_id.
1✔
1140
                            (generalReader
1✔
1141
                                     on: result readStream;
1✔
1142
                                     next)
1✔
1143
                                    at: #merge_user
1✔
1144
                                    ifPresent: [ :mergeUser |
1✔
1145
                                    mergeUser ifNotNil: [ :mruser | mruser at: #id ] ] ].
1✔
1146
        ^aGLPHEMergeRequest merge_user: (self importUser: authorID)
1✔
1147
]
1✔
1148

1149
{ #category : #'import - notes' }
1150
GitlabModelImporter >> importNotesfromMergeRequest: mergeRequest [
×
1151
        | results notes |
×
1152
        
×
1153
        results := self repoApi notes allInMergeRequest: mergeRequest iid ofProject: mergeRequest project id.
×
1154
        
×
1155
        notes := results collect: [ :note | 
×
1156
                self parseNoteJson: note ].
×
1157
        "notes := self parseNoteJson: results."
×
1158
        notes do: [ :tabNotes | tabNotes do: [ :note |
×
1159
                        note author: (self importUser: (note author at: #id)).
×
1160
                        note name: note id asString]. ].
×
1161
        notes := notes flattened.
×
1162
        notes := self glhModel addAll: notes unless: self blockOnIdEquality. 
×
1163
        notes := mergeRequest note addAll: notes unless: self blockOnIdEquality. 
×
1164
        ^notes
×
1165
        
×
1166
]
×
1167

1168
{ #category : #'import - commits' }
1169
GitlabModelImporter >> importParentCommitsOfCommit: aGLHCommit since: aDate [
×
1170

×
1171
        | parentsIds commits |
×
1172
        commits := OrderedCollection new.
×
1173
        aGLHCommit created_at asDateAndTime < aDate asDateAndTime ifTrue: [
×
1174
                 
×
1175
                ^ commits
×
1176
                          add: aGLHCommit;
×
1177
                          yourself ].
×
1178

×
1179
        parentsIds := aGLHCommit parent_ids.
×
1180

×
1181
        commits addAll: (parentsIds collect: [ :id |
×
1182
                         self
×
1183
                                 importCommitOfProject: aGLHCommit repository project
×
1184
                                 withId: id ]).
×
1185

×
1186

×
1187
        ^ (commits collect: [ :parentCommit |
×
1188
                   self importParentCommitsOfCommit: parentCommit since: aDate ])
×
1189
                  flatten
×
1190
]
×
1191

1192
{ #category : #'import - pipelines' }
NEW
1193
GitlabModelImporter >> importPipeline: pipelineId OfProject: aGLHProject [
×
NEW
1194

×
NEW
1195
        
×
NEW
1196
        | result pipeline|
×
NEW
1197
        
×
NEW
1198
        aGLHProject pipelines detect: [ :pip | pip id = pipelineId ] ifOne: [ :pip| ^pip ].
×
NEW
1199
        
×
NEW
1200
        ('Search pipelines of: ' , aGLHProject id printString) recordInfo.
×
NEW
1201
        result := self repoApi pipelines get: pipelineId inProject: aGLHProject id.
×
NEW
1202
        result isString ifTrue: [ ^ self parsePipelineResult: result ].
×
NEW
1203

×
NEW
1204
        pipeline :=  self parsePipelineResult: result.
×
UNCOV
1205

×
NEW
1206
        pipeline := self glhModel add: pipeline unless: self blockOnIdEquality .
×
NEW
1207
        pipeline := aGLHProject pipelines add: pipeline unless: self blockOnIdEquality.
×
NEW
1208
        
×
NEW
1209
        ^ self completeImportedPipeline: pipeline. 
×
UNCOV
1210
]
×
1211

1212
{ #category : #'import - projects' }
1213
GitlabModelImporter >> importProject: aProjectID [
1✔
1214

1✔
1215
        | result projectResult |
1✔
1216
        ('Import project with id:  ' , aProjectID printString) recordInfo.
1✔
1217

1✔
1218
        (glhModel allWithType: GLHProject)
1✔
1219
                detect: [ :project | project id = aProjectID ]
1✔
1220
                ifFound: [ :project | ^ project ].
1✔
1221

1✔
1222
        result := self repoApi projects get: aProjectID.
1✔
1223
        projectResult := self parseProjectResult: result.
1✔
1224

1✔
1225
        ^ self completeImportedProject: projectResult
1✔
1226
]
1✔
1227

1228
{ #category : #'import - projects' }
1229
GitlabModelImporter >> importProjects [
×
1230

×
1231
        | result projects |
×
1232
        ('import all Projects') recordInfo.
×
1233

×
1234

×
1235
        result := self repoApi projects all.
×
1236
        projects := (result collect: [ :projectsJson | self parseArrayOfProject: projectsJson ]) flattened.
×
1237
        
×
1238
        self glhModel addAll: projects unless: self blockOnIdEquality.
×
1239

×
1240
        ^ projects
×
1241
]
×
1242

1243
{ #category : #imports }
1244
GitlabModelImporter >> importProjectsSince: since [
×
1245
        "heavy import of all projects"
×
1246

×
1247
        "copy import from commits"
×
1248

×
1249
        | newlyFoundProjects page foundProject amount |
×
1250
        ('import all Projects since: ' , since printString) recordInfo.
×
1251

×
1252
        "number of projects per page"
×
1253
        amount := 100.
×
1254
        page := 0.
×
1255
        foundProject := OrderedCollection new.
×
1256
        newlyFoundProjects := { true }.
×
1257
        [ newlyFoundProjects isNotEmpty ] whileTrue: [
×
1258
                | results |
×
1259
                page := page + 1.
×
1260
                ('import projects page #' , page printString) recordInfo.
×
1261

×
1262
                results := self repoApi projects: amount since: since page: page.
×
1263

×
1264
                newlyFoundProjects := self glhModel
×
1265
                                              addAll: (self parseArrayOfProject: results)
×
1266
                                              unless: self blockOnIdEquality.
×
1267
                foundProject addAll: newlyFoundProjects ].
×
1268
]
×
1269

1270
{ #category : #'import - repositories' }
1271
GitlabModelImporter >> importRepository: aGLHRepository [
1✔
1272

1✔
1273
        | resultBranches branches |
1✔
1274
        [
1✔
1275
        ('import the repository of project ' , aGLHRepository project name)
1✔
1276
                recordInfo.
1✔
1277

1✔
1278
        resultBranches := self repoApi branches getAllFromProject:
1✔
1279
                                  aGLHRepository project id.
1✔
1280

1✔
1281
        branches := (resultBranches collect: [ :branchesJson |
1✔
1282
                             self parseBranchesResult: branchesJson ]) flattened.
1✔
1283

1✔
1284
        'import the branches of project ' recordInfo.
1✔
1285

1✔
1286
        branches := aGLHRepository branches
1✔
1287
                            addAll: branches
1✔
1288
                            unless: self blockOnNameEquality.
1✔
1289
        branches := self glhModel
1✔
1290
                            addAll: branches
1✔
1291
                            unless: self blockOnNameEquality.
1✔
1292

1✔
1293

1✔
1294
        self withFiles ifTrue: [
1✔
1295
                branches do: [ :branch | self importFilesOfBranch: branch ] ] ]
1✔
1296
                on: NeoJSONParseError
1✔
1297
                do: [
1✔
1298
                self inform: aGLHRepository project name , ' has no repository' ].
1✔
1299
        
1✔
1300
        withInitialCommits ifTrue: [
1✔
1301
                aGLHRepository branches do: [ :branch |
1✔
1302
                        self importCommitsOfBranch: branch ] ]
1✔
1303
]
1✔
1304

1305
{ #category : #'import - users' }
1306
GitlabModelImporter >> importUser: aUserID [
1✔
1307

1✔
1308
        | result userResult |
1✔
1309
        (self glhModel allWithType: GLHUser)
1✔
1310
                detect: [ :user | user id = aUserID ]
1✔
1311
                ifFound: [ :user | ^ user ].
1✔
1312
        ('Import user: ' , aUserID printString) recordInfo.
1✔
1313
        
1✔
1314
        result := self repoApi users get: aUserID.
1✔
1315
        userResult := self parseUserResult: result.
1✔
1316
        
1✔
1317
        userResult := self glhModel add: userResult unless: self blockOnIdEquality.
1✔
1318
        userCatalogue addUser: userResult.
1✔
1319
        ^ userResult 
1✔
1320
]
1✔
1321

1322
{ #category : #'import - users' }
1323
GitlabModelImporter >> importUserByUsername: anUsername [
1✔
1324

1✔
1325
        | dicUsername resultUser |
1✔
1326
        dicUsername := ((self glhModel allWithType: GLHUser) collect: [ :user |
1✔
1327
                                user username -> user ]) asSet asDictionary.
1✔
1328

1✔
1329
        dicUsername addAll: self userCatalogue collectUsernames.
1✔
1330

1✔
1331

1✔
1332
        resultUser := dicUsername
1✔
1333
                              at: anUsername
1✔
1334
                              ifAbsent: [ "thus we have to import this new user"
1✔
1335
                                      | result userId searchResult params |
1✔
1336
                                      ('Import user with username: '
1✔
1337
                                       , anUsername printString) recordInfo.
1✔
1338
                                      params := { (#search -> anUsername) } asDictionary.
1✔
1339
                                      result := self repoApi users allWithParams: params.
1✔
1340
                                                        
1✔
1341
                                                         "when result is an error"
1✔
1342
                                                         (result isString) ifTrue: [ result := { result } ].
1✔
1343
                                                        
1✔
1344
                                      searchResult := result ifEmpty: [ result ] ifNotEmpty: [(result collect: [ :usersJson |
1✔
1345
                                                               NeoJSONReader fromString: usersJson ]) first].
1✔
1346
                                                         
1✔
1347
                                      (searchResult class = Dictionary and: [
1✔
1348
                                               (searchResult at: #message) includesSubstring:
1✔
1349
                                                       '403 Forbidden' ])
1✔
1350
                                              ifTrue: [ "if the result is an 403 error we fake a new user"
1✔
1351
                                                      self glhModel
1✔
1352
                                                              add: (GLHUser new
1✔
1353
                                                                               username: anUsername;
1✔
1354
                                                                               name: anUsername;
1✔
1355
                                                                               yourself)
1✔
1356
                                                              unless: [ :nu :ou | nu username = ou username ] ]
1✔
1357
                                              ifFalse: [
1✔
1358
                                                      searchResult
1✔
1359
                                                              ifEmpty: [ "results can be empty thus we force a new user with the info we have "
1✔
1360
                                                                      self glhModel
1✔
1361
                                                                              add: (GLHUser new
1✔
1362
                                                                                               username: anUsername;
1✔
1363
                                                                                               name: anUsername;
1✔
1364
                                                                                               yourself)
1✔
1365
                                                                              unless: [ :nu :ou | nu username = ou username ] ]
1✔
1366
                                                              ifNotEmpty: [ "because we may already have the researched user, we look by ID in the model"
1✔
1367
                                                                      userId := searchResult first at: #id.
1✔
1368
                                                                      (self glhModel allWithType: GLHUser)
1✔
1369
                                                                              detect: [ :user | user id = userId ]
1✔
1370
                                                                              ifNone: [ self importUser: userId ] ] ] ].
1✔
1371

1✔
1372
        self userCatalogue addUser: resultUser withName: anUsername.
1✔
1373

1✔
1374
        ^ resultUser
1✔
1375
]
1✔
1376

1377
{ #category : #initialization }
1378
GitlabModelImporter >> initReader [
1✔
1379

1✔
1380
        generalReader := NeoJSONReader new.
1✔
1381
        self configureReaderForCommit: generalReader.
1✔
1382
        self configureReaderForGroup: generalReader.
1✔
1383
        self configureReaderForDiffs: generalReader.
1✔
1384
        self configureReaderForMergeRequest: generalReader.
1✔
1385
        self configureReaderForPipeline: generalReader. 
1✔
1386
]
1✔
1387

1388
{ #category : #initialization }
1389
GitlabModelImporter >> initialize [
1✔
1390

1✔
1391
        super initialize.
1✔
1392
        withCommitDiffs := true.
1✔
1393
        withInitialCommits := false.
1✔
1394
        withInitialMergeRequest := false.
1✔
1395

1✔
1396
        self withCommitsSince: 1 week.
1✔
1397

1✔
1398
        self initReader
1✔
1399
]
1✔
1400

1401
{ #category : #private }
1402
GitlabModelImporter >> isServerError: aString [
1✔
1403
        ^ aString = '{"message":"500 Internal Server Error"}'
1✔
1404
]
1✔
1405

1406
{ #category : #'import - projects' }
1407
GitlabModelImporter >> loadAllProjectsFromRepositorySoftware [
×
1408
        "heavy import that load all the active project inside the model. Only import the project entities"
×
1409
        |projects|
×
1410
        
×
1411
        projects := self repoApi projects. 
×
1412
]
×
1413

1414
{ #category : #'private - parsing' }
1415
GitlabModelImporter >> newParseCommitResult: result [
×
1416

×
1417
        generalReader  on: result readStream.
×
1418

×
1419
        ^ generalReader nextAs: GLHCommit
×
1420
]
×
1421

1422
{ #category : #'private - parsing' }
1423
GitlabModelImporter >> newParseDiffResult: result [
1✔
1424

1✔
1425
        generalReader on: result readStream.
1✔
1426
        ^ generalReader nextAs: #ArrayOfDiffs
1✔
1427
]
1✔
1428

1429
{ #category : #'private - parsing' }
1430
GitlabModelImporter >> parseArrayOfProject: arrayOfProjects [
×
1431

×
1432
        | reader |
×
1433
        reader := NeoJSONReader on: arrayOfProjects readStream.
×
1434
        reader
×
1435
                for: #ArrayOfProjects
×
1436
                customDo: [ :customMappting |
×
1437
                customMappting listOfElementSchema: GLHProject ].
×
1438
        reader for: GLHProject do: [ :mapping |
×
1439
                mapping mapInstVar: #name to: #name.
×
1440
                mapping mapInstVar: #description to: #description.
×
1441
                mapping mapInstVar: #id to: #id.
×
1442
                mapping mapInstVar: #archived to: #archived.
×
1443
                mapping mapInstVar: #web_url to: #html_url.
×
1444
                mapping mapInstVar: #topics to: #topics ].
×
1445
        ^ reader nextAs: #ArrayOfProjects
×
1446
]
×
1447

1448
{ #category : #'private - parsing' }
1449
GitlabModelImporter >> parseBranchesResult: result [
1✔
1450

1✔
1451
        | reader |
1✔
1452
        reader := NeoJSONReader on: result readStream.
1✔
1453
        reader mapInstVarsFor: GLHBranch.
1✔
1454
        reader
1✔
1455
                for: #ArrayOfBranch
1✔
1456
                customDo: [ :customMappting | 
1✔
1457
                customMappting listOfElementSchema: GLHBranch ].
1✔
1458
        ^ reader nextAs: #ArrayOfBranch
1✔
1459
]
1✔
1460

1461
{ #category : #'private - parsing' }
1462
GitlabModelImporter >> parseCommitResult: result [
×
1463

×
1464
        | reader |
×
1465
        reader := NeoJSONReader on: result readStream.
×
1466

×
1467
        reader for: GLHCommit do: [ :mapping |
×
1468
                mapping mapInstVars:
×
1469
                        #( id short_id title author_name author_email committer_name
×
1470
                           committer_email message web_url ).
×
1471
                (mapping mapInstVar: #authored_date) valueSchema: DateAndTime.
×
1472
                (mapping mapInstVar: #committed_date) valueSchema: DateAndTime.
×
1473
                (mapping mapInstVar: #created_at) valueSchema: DateAndTime.
×
1474
                (mapping mapInstVar: #parent_ids) valueSchema: #ArrayOfIds.
×
1475
                mapping
×
1476
                        mapProperty: 'stats'
×
1477
                        getter: [ :el | "Not used" ]
×
1478
                        setter: [ :commit :value |
×
1479
                                commit deletions: (value at: #deletions).
×
1480
                                commit additions: (value at: #additions) ] ].
×
1481

×
1482
        reader for: DateAndTime customDo: [ :mapping |
×
1483
                mapping decoder: [ :string | DateAndTime fromString: string ] ].
×
1484

×
1485
        reader
×
1486
                for: #ArrayOfIds
×
1487
                customDo: [ :mapping | mapping decoder: [ :string | string ] ].
×
1488

×
1489

×
1490
        ^ reader nextAs: GLHCommit
×
1491
]
×
1492

1493
{ #category : #'private - parsing' }
1494
GitlabModelImporter >> parseCommitsResult: result [
1✔
1495

1✔
1496
        | reader |
1✔
1497
        reader := NeoJSONReader on: result readStream.
1✔
1498

1✔
1499
          reader for: GLHCommit do: [ :mapping |
1✔
1500
                mapping mapInstVars:
1✔
1501
                        #( id short_id title author_name author_email committer_name
1✔
1502
                           committer_email message web_url ).
1✔
1503
                (mapping mapInstVar: #authored_date) valueSchema: DateAndTime.
1✔
1504
                (mapping mapInstVar: #committed_date) valueSchema: DateAndTime.
1✔
1505
                (mapping mapInstVar: #created_at) valueSchema: DateAndTime.
1✔
1506
                (mapping mapInstVar: #parent_ids) valueSchema: #ArrayOfIds.
1✔
1507
                mapping
1✔
1508
                        mapProperty: 'stats'
1✔
1509
                        getter: [ :el | "Not used" ]
1✔
1510
                        setter: [ :commit :value |
1✔
1511
                                commit deletions: (value at: #deletions).
1✔
1512
                                commit additions: (value at: #additions) ] ].
1✔
1513

1✔
1514
        reader for: DateAndTime customDo: [ :mapping |
1✔
1515
                mapping decoder: [ :string | DateAndTime fromString: string ] ].
1✔
1516

1✔
1517
        reader
1✔
1518
                for: #ArrayOfIds
1✔
1519
                customDo: [ :mapping | mapping decoder: [ :string | string ] ].
1✔
1520
  
1✔
1521
        reader
1✔
1522
                for: #ArrayOfCommit
1✔
1523
                customDo: [ :customMappting |
1✔
1524
                customMappting listOfElementSchema: GLHCommit ].
1✔
1525

1✔
1526
        ^ reader nextAs: #ArrayOfCommit
1✔
1527
]
1✔
1528

1529
{ #category : #private }
1530
GitlabModelImporter >> parseDiffResult: result [
×
1531

×
1532
        | reader |
×
1533
        self
×
1534
                deprecated: 'Use #newParseDiffResult: instead'
×
1535
                on: '28 June 2024'
×
1536
                in:
×
1537
                'Pharo-11.0.0+build.726.sha.aece1b5473acf3830a0e082c1bc3a15d4ff3522b (64 Bit)'.
×
1538
        reader := NeoJSONReader on: result readStream.
×
1539
        reader for: GLHDiff do: [ :mapping |
×
1540
                mapping mapInstVars:
×
1541
                        #( deleted_file new_file new_path old_path renamed_file ).
×
1542
                mapping mapInstVar: #diffString to: #diff ].
×
1543

×
1544
        reader
×
1545
                for: #ArrayOfDiffs
×
1546
                customDo: [ :customMappting |
×
1547
                customMappting listOfElementSchema: GLHDiff ].
×
1548
        ^ reader nextAs: #ArrayOfDiffs
×
1549
]
×
1550

1551
{ #category : #'private - parsing' }
1552
GitlabModelImporter >> parseFileTreeResult: aResult [
×
1553

×
1554
        | reader |
×
1555
        reader := NeoJSONReader on: aResult readStream.
×
1556
        reader mapInstVarsFor: GLHApiFile.
×
1557
        reader
×
1558
                for: #ArrayOfFile
×
1559
                customDo: [ :customMappting | 
×
1560
                customMappting listOfElementSchema: GLHApiFile ].
×
1561
        ^ reader nextAs: #ArrayOfFile
×
1562
]
×
1563

1564
{ #category : #'private - parsing' }
1565
GitlabModelImporter >> parseGroupResult: aResult [
1✔
1566

1✔
1567
        | reader |
1✔
1568

1✔
1569
        reader := NeoJSONReader on: aResult readStream.
1✔
1570
        reader for: GLHGroup do: [ :mapping |
1✔
1571
                mapping mapInstVars.
1✔
1572
                (mapping mapInstVar: #projects) valueSchema: #ArrayOfProjects ].
1✔
1573
        reader mapInstVarsFor: GLHProject.
1✔
1574
        reader
1✔
1575
                for: #ArrayOfProjects
1✔
1576
                customDo: [ :customMappting |
1✔
1577
                customMappting listOfElementSchema: GLHProject ].
1✔
1578
        ^ reader nextAs: GLHGroup
1✔
1579
]
1✔
1580

1581
{ #category : #'private - parsing' }
1582
GitlabModelImporter >> parseJobsResult: result ofProject: aProject [
×
1583

×
1584
        | reader |
×
1585
        reader := NeoJSONReader on: result readStream.
×
1586
        reader for: GLHJob do: [ :mapping |
×
1587
                mapping mapInstVars: #( id allow_failure web_url name ).
×
1588

×
1589
                mapping
×
1590
                        mapProperty: #user
×
1591
                        getter: [ :object | #ignore ]
×
1592
                        setter: [ :object :value |
×
1593
                        object user: (self importUser: (value at: #id)) ].
×
1594

×
1595
                mapping
×
1596
                        mapProperty: #commit
×
1597
                        getter: [ :object | #ignore ]
×
1598
                        setter: [ :object :value |
×
1599
                                value ifNotNil: [
×
1600
                                        object commit:
×
1601
                                                (self importCommit: (value at: #id) ofProject: aProject) ] ].
×
1602

×
1603
                mapping
×
1604
                        mapProperty: #duration
×
1605
                        getter: [ :object | #ignore ]
×
1606
                        setter: [ :object :value |
×
1607
                        value ifNotNil: [ object duration: value seconds ] ] ].
×
1608

×
1609
        reader
×
1610
                for: #ArrayOfGLHJob
×
1611
                customDo: [ :customMappting |
×
1612
                customMappting listOfElementSchema: GLHJob ].
×
1613
        ^ reader nextAs: #ArrayOfGLHJob
×
1614
]
×
1615

1616
{ #category : #'private - parsing' }
1617
GitlabModelImporter >> parseMergeRequestsResult: result [
1✔
1618

1✔
1619
        generalReader on: result readStream.
1✔
1620
        ^ generalReader nextAs: #ArrayOfMergeRequest
1✔
1621
]
1✔
1622

1623
{ #category : #'private - parsing' }
1624
GitlabModelImporter >> parseNoteJson: results [  
1✔
1625
    | reader |  
1✔
1626

1✔
1627
    "Créer un lecteur JSON"
1✔
1628
    reader := NeoJSONReader on: results readStream.    
1✔
1629

1✔
1630
    "Définir le mapping pour l'objet GLHNote"
1✔
1631
    reader for: GLHNote do: [ :mapping |  
1✔
1632
        mapping mapInstVars: #(id noteable_id attachment system confidential internal  
1✔
1633
                               noteable_iid resolvable imported imported_from  
1✔
1634
                               author body project_id noteable_type).  
1✔
1635

1✔
1636
        (mapping mapInstVar: #created_at) valueSchema: DateAndTime.  
1✔
1637
        (mapping mapInstVar: #updated_at) valueSchema: DateAndTime.  
1✔
1638
    ].    
1✔
1639

1✔
1640
    "Corriger la conversion des dates"
1✔
1641
    reader for: DateAndTime customDo: [ :mapping |  
1✔
1642
        mapping decoder: [ :string | DateAndTime readFrom: string readStream ] ].
1✔
1643

1✔
1644
        reader
1✔
1645
                for: #ArrayOfNote
1✔
1646
                customDo: [ :customMappting | 
1✔
1647
                customMappting listOfElementSchema: GLHNote ].
1✔
1648
         ^ reader nextAs: #ArrayOfNote
1✔
1649

1✔
1650
    "Retourner la Note"
1✔
1651
    "^ reader nextAs: GLHNote"
1✔
1652

1✔
1653

1✔
1654
]
1✔
1655

1656
{ #category : #'private - parsing' }
NEW
1657
GitlabModelImporter >> parsePipelineResult: result [
×
NEW
1658

×
NEW
1659
        | reader |
×
NEW
1660
        
×
NEW
1661
        (result includesSubstring: '{"message":"40' )ifTrue: [ ^ {  } ].
×
NEW
1662
        
×
NEW
1663
        reader := generalReader on: result readStream.
×
NEW
1664
        
×
NEW
1665
        ^ reader nextAs: GLHPipeline
×
NEW
1666
]
×
1667

1668
{ #category : #'private - parsing' }
1669
GitlabModelImporter >> parsePipelinesResult: result [
1✔
1670

1✔
1671
        | reader |
1✔
1672
        
1✔
1673
        (result includesSubstring: '{"message":"40' )ifTrue: [ ^ {  } ].
1✔
1674
        
1✔
1675
        reader := generalReader on: result readStream.
1✔
1676
        
1✔
1677
        ^ reader nextAs: #ArrayOfPipelines
1✔
1678
]
1✔
1679

1680
{ #category : #'private - parsing' }
1681
GitlabModelImporter >> parseProjectResult: aResult [ 
1✔
1682
                | reader |
1✔
1683
        reader := NeoJSONReader on: aResult readStream.
1✔
1684
        reader for: GLHProject do: [ :mapping |
1✔
1685
                mapping mapInstVars. ].
1✔
1686
"        reader mapInstVarsFor: GLHProject."
1✔
1687

1✔
1688
        ^ reader nextAs: GLHProject
1✔
1689
]
1✔
1690

1✔
1691
{ #category : #'private - parsing' }
1✔
1692
GitlabModelImporter >> parseSubGroupResult: aResult [
1✔
1693

1✔
1694
        | reader |
1✔
1695
        reader := NeoJSONReader on: aResult readStream.
1✔
1696
        self configureReaderForGroup: reader.
1✔
1697
        ^ reader nextAs: #ArrayOfGroups
1✔
1698
]
1✔
1699

1✔
1700
{ #category : #'private - parsing' }
1✔
1701
GitlabModelImporter >> parseUserResult: result [
1✔
1702

1✔
1703
        | reader |
1✔
1704
        reader := NeoJSONReader on: result readStream.
1✔
1705
        reader mapInstVarsFor: GLHUser.
1✔
1706
        ^ reader nextAs: GLHUser
1✔
1707
]
1✔
1708

1✔
1709
{ #category : #'private - parsing' }
1✔
1710
GitlabModelImporter >> parseUsersResult: result [
1✔
1711

1✔
1712
        | reader |
1✔
1713
        reader := NeoJSONReader on: result readStream.
1✔
1714

1✔
1715
        reader mapInstVarsFor: GLHUser.
1✔
1716

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

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

1✔
1725
{ #category : #'import - projects' }
1✔
1726
GitlabModelImporter >> partiallyImportProject: aProjectID [
1✔
1727

1✔
1728
        | result projectResult |
1✔
1729
        ('Import project with id:  ' , aProjectID printString) recordInfo.
1✔
1730

1✔
1731
        (glhModel allWithType: GLHProject)
1✔
1732
                detect: [ :project | project id = aProjectID ]
1✔
1733
                ifFound: [ :project | ^ project ].
1✔
1734

1✔
1735
        result := self repoApi projects get: aProjectID.
1✔
1736
        projectResult := self parseProjectResult: result.
1✔
1737

1✔
1738
        projectResult repository: GLHRepository new.
1✔
1739
        self glhModel add: projectResult repository.
1✔
1740
        self importRepository: projectResult repository.
1✔
1741

1✔
1742
        ^ projectResult
1✔
1743
]
1✔
1744

1✔
1745
{ #category : #'import - pipelines' }
1✔
1746
GitlabModelImporter >> pipelinesOf: aProjectID withLimit: aLimit [
1✔
1747

1✔
1748
        | result |
1✔
1749
        ('Search pipelines of: ' , aProjectID printString) recordInfo.
1✔
1750
        result := self repoApi pipelines getByPage: 1 perPage: aLimit inProject: aProjectID.
1✔
1751
        result isString ifTrue: [ ^ self parsePipelinesResult: result ].
1✔
1752

1✔
1753
        ^ (result collect: [ :pipelinesJson |
1✔
1754
                           self parsePipelinesResult: pipelinesJson ]) flattened
1✔
1755
]
1✔
1756

1✔
1757
{ #category : #accessing }
1✔
1758
GitlabModelImporter >> repoApi: anObject [
1✔
1759
        super repoApi: anObject.
1✔
1760
        self repoApi output: 'json'
1✔
1761
]
1✔
1762

1✔
1763
{ #category : #private }
1✔
1764
GitlabModelImporter >> selectEntityType: aType overAttribut: aSelector equalTo: value [
1✔
1765

1✔
1766
        ^ (self glhModel allWithType: aType)
1✔
1767
                select: [ :entity | (entity perform: aSelector) = value ]
1✔
1768
]
1✔
1769

1✔
1770
{ #category : #'import - groups' }
1✔
1771
GitlabModelImporter >> subGroupsOf: aGroupID [
1✔
1772

1✔
1773
        | results subgroups |
1✔
1774
        ('Search subgroup of: ' , aGroupID printString) recordInfo.
1✔
1775
        results := self repoApi groups subgroupsOf: aGroupID.
1✔
1776
        subgroups := (results collect: [ :subgroupsJson | self parseSubGroupResult: subgroupsJson ]) flattened.
1✔
1777
        
1✔
1778
        ^ subgroups
1✔
1779
]
1✔
1780

1✔
1781
{ #category : #accessing }
1✔
1782
GitlabModelImporter >> withInitialCommits: boolean [
1✔
1783
        withInitialCommits := boolean 
1✔
1784
]
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc