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

moosetechnology / GitProjectHealth / 13966424968

20 Mar 2025 09:50AM UTC coverage: 69.853% (-0.6%) from 70.404%
13966424968

Pull #157

github

web-flow
Merge 4f2bf4dc7 into 0366375be
Pull Request #157: new Note entity

1164 of 2048 new or added lines in 18 files covered. (56.84%)

2 existing lines in 1 file now uncovered.

14030 of 20085 relevant lines covered (69.85%)

0.7 hits per line

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

54.41
/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 }
NEW
13
GitlabModelImporter >> addCommits: commitsList toRepository: aProjectRepository [
×
NEW
14
        "I take a list of GLHCommit. But some might have been parsed but are already on the model..."
×
NEW
15

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

×
NEW
18
        | existingCommits newlyFoundCommit |
×
NEW
19
        existingCommits := aProjectRepository mooseModel allWithType:
×
NEW
20
                                   GLHCommit.
×
NEW
21
        newlyFoundCommit := commitsList reject: [ :commitParsed |
×
NEW
22
                                    existingCommits anySatisfy: [ :existingCommit |
×
NEW
23
                                            existingCommit id = commitParsed id ] ].
×
NEW
24
        aProjectRepository mooseModel addAll: newlyFoundCommit.
×
NEW
25
        aProjectRepository commits addAll: newlyFoundCommit.
×
NEW
26
        ^ newlyFoundCommit
×
NEW
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 : #private }
40
GitlabModelImporter >> chainsCommitsFrom: commitsCollection [
1✔
41

1✔
42
        | dic |
1✔
43
        
1✔
44
        ('Chains ', commitsCollection size printString , ' commits') recordInfo.
1✔
45
        
1✔
46
        dic := ((self glhModel allWithType: GLHCommit) collect: [ :commit |
1✔
47
                        commit id -> commit ]) asSet asDictionary.
1✔
48

1✔
49
        commitsCollection do: [ :commit |
1✔
50
                commit parent_ids do: [ :parentId | 
1✔
51
                        dic
1✔
52
                                at: parentId
1✔
53
                                ifPresent: [ :parentCommit |
1✔
54
                                        parentCommit childCommits
1✔
55
                                                add: commit
1✔
56
                                                unless: self blockOnIdEquality ]
1✔
57
                                ifAbsent: [  ] ] ].
1✔
58
        ^ commitsCollection
1✔
59
]
1✔
60

61
{ #category : #'import - commits' }
NEW
62
GitlabModelImporter >> commitsOfProject: aGLHProject forRefName: refName until: toDate [
×
NEW
63

×
NEW
64
        | params results allCommits |
×
NEW
65
        
×
NEW
66
        params := { 
×
NEW
67
                #ref_name -> refName.
×
NEW
68
                #until -> (toDate ifNotNil: [ toDate asDateAndTime asString ] ifNil: [ '' ]) 
×
NEW
69
        } asDictionary.
×
NEW
70
        results := self repoApi commits getAllInProject: aGLHProject id withParams: params.
×
NEW
71
        allCommits := (results collect: [ :commitsJson | self parseCommitsResult: commitsJson ]) flattened.
×
NEW
72
        
×
NEW
73
        self glhModel addAll: allCommits unless: self blockOnIdEquality.
×
NEW
74
        aGLHProject repository commits addAll: allCommits unless: self blockOnIdEquality.
×
NEW
75

×
NEW
76
        self withCommitDiffs ifTrue: [
×
NEW
77
                aGLHProject repository commits do: [ :commit |
×
NEW
78
                        self importDiffOfCommit: commit ] ].
×
NEW
79
        
×
NEW
80
        ^allCommits
×
NEW
81
]
×
82

83
{ #category : #'import - projects' }
84
GitlabModelImporter >> completeImportProject: aGLHProject [
1✔
85

1✔
86
        | importedProject |
1✔
87
        ('Complete import of project: ' , aGLHProject id printString)
1✔
88
                recordInfo.
1✔
89
        aGLHProject repository ifNotNil: [ ^ aGLHProject ].
1✔
90

1✔
91
        importedProject := self glhModel
1✔
92
                                   add: aGLHProject
1✔
93
                                   unless: self blockOnIdEquality.
1✔
94

1✔
95
        self importPipelinesOfProject: importedProject.
1✔
96

1✔
97
        "aGLHProject creator: (self importUser: aGLHProject creator_id)."
1✔
98

1✔
99
        (self importUser: importedProject creator_id) addCreatedProject:
1✔
100
                importedProject.
1✔
101

1✔
102

1✔
103
        importedProject repository: GLHRepository new.
1✔
104
        self glhModel add: importedProject repository.
1✔
105
        self importRepository: importedProject repository.
1✔
106

1✔
107

1✔
108
        withInitialMergeRequest ifTrue: [
1✔
109
                self
1✔
110
                        importMergeRequests: importedProject
1✔
111
                        since: DateAndTime today
1✔
112
                        until: DateAndTime now ].
1✔
113

1✔
114
        ^ importedProject
1✔
115
        
1✔
116

1✔
117
]
1✔
118

119
{ #category : #'import - notes' }
NEW
120
GitlabModelImporter >> importNotesfromMergeRequest: mergeRequestIID ofProject: projectId [
×
NEW
121
        | results notes |
×
NEW
122
        
×
NEW
123
        results := self repoApi notes allInMergeRequest: mergeRequestIID ofProject: projectId.
×
NEW
124
        
×
NEW
125
        notes := results collect: [ :note | 
×
NEW
126
                self parseNoteJson: note ].
×
NEW
127
        "notes := self parseNoteJson: results."
×
NEW
128
        notes do: [ :tabNotes | tabNotes do: [ :note |
×
NEW
129
                        note author: (self importUser: (note author at: #id)).
×
NEW
130
                        note name: note id asString]. ].
×
NEW
131
        
×
NEW
132
        notes do: [:note | self glhModel addAll: note unless: self blockOnIdEquality.].
×
NEW
133
        ^notes
×
NEW
134
        
×
NEW
135
]
×
136

137
{ #category : #'import - commits' }
138
GitlabModelImporter >> completeImportedCommit: aCommit [
1✔
139

1✔
140
        ('completing commit: ' , aCommit short_id printString) recordInfo.
1✔
141
        self importCreatorOfCommit: aCommit.
1✔
142

1✔
143
        self withCommitDiffs ifTrue: [
1✔
144
                | diffs |
1✔
145
                aCommit diffs ifEmpty: [
1✔
146
                        diffs := self importDiffOfCommit: aCommit.
1✔
147
                        self glhModel addAll: diffs unless: self blockForDiffEquality ] ].
1✔
148

1✔
149
        ^ aCommit
1✔
150
]
1✔
151

152
{ #category : #'private - configure reader' }
153
GitlabModelImporter >> configureReaderForCommit: reader [
1✔
154

1✔
155
          reader for: GLHCommit do: [ :mapping |
1✔
156
                mapping mapInstVars:
1✔
157
                        #( id short_id title author_name author_email committer_name
1✔
158
                           committer_email message web_url ).
1✔
159
                (mapping mapInstVar: #authored_date) valueSchema: DateAndTime.
1✔
160
                (mapping mapInstVar: #committed_date) valueSchema: DateAndTime.
1✔
161
                (mapping mapInstVar: #created_at) valueSchema: DateAndTime.
1✔
162
                (mapping mapInstVar: #parent_ids) valueSchema: #ArrayOfIds.
1✔
163
                mapping
1✔
164
                        mapProperty: 'stats'
1✔
165
                        getter: [ :el | "Not used" ]
1✔
166
                        setter: [ :commit :value |
1✔
167
                                commit deletions: (value at: #deletions).
1✔
168
                                commit additions: (value at: #additions) ] ].
1✔
169

1✔
170
        reader for: DateAndTime customDo: [ :mapping |
1✔
171
                mapping decoder: [ :string | DateAndTime fromString: string ] ].
1✔
172

1✔
173
        reader
1✔
174
                for: #ArrayOfIds
1✔
175
                customDo: [ :mapping | mapping decoder: [ :string | string ] ].
1✔
176
  
1✔
177
        reader
1✔
178
                for: #ArrayOfCommit
1✔
179
                customDo: [ :customMappting |
1✔
180
                customMappting listOfElementSchema: GLHCommit ].
1✔
181

1✔
182
]
1✔
183

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

1✔
187
        reader for: GLHDiff do: [ :mapping |
1✔
188
                mapping mapInstVars:
1✔
189
                        #( deleted_file new_file new_path old_path renamed_file ).
1✔
190
                mapping mapInstVar: #diffString to: #diff ].
1✔
191

1✔
192
        reader
1✔
193
                for: #ArrayOfDiffs
1✔
194
                customDo: [ :customMappting |
1✔
195
                customMappting listOfElementSchema: GLHDiff ].
1✔
196
        ^ reader
1✔
197
]
1✔
198

199
{ #category : #'private - configure reader' }
200
GitlabModelImporter >> configureReaderForGroup: reader [
1✔
201

1✔
202
        reader for: GLHGroup do: [ :mapping |
1✔
203
                mapping mapInstVars.
1✔
204
                (mapping mapInstVar: #projects) valueSchema: #ArrayOfProjects ].
1✔
205
        reader mapInstVarsFor: GLHProject.
1✔
206
        reader
1✔
207
                for: #ArrayOfProjects
1✔
208
                customDo: [ :customMappting |
1✔
209
                customMappting listOfElementSchema: GLHProject ].
1✔
210
        reader
1✔
211
                for: #ArrayOfGroups
1✔
212
                customDo: [ :customMappting |
1✔
213
                customMappting listOfElementSchema: GLHGroup ]
1✔
214
]
1✔
215

216
{ #category : #'private - configure reader' }
217
GitlabModelImporter >> configureReaderForMergeRequest: reader [
1✔
218
        "declare quil y a un array a mapper"
1✔
219

1✔
220
        reader for: #ArrayOfMergeRequest customDo: [ :customMappting |
1✔
221
                customMappting listOfElementSchema: GLHMergeRequest ].
1✔
222

1✔
223
        "declare la liste des properties"
1✔
224
        reader for: GLHMergeRequest do: [ :mapping |
1✔
225
                mapping mapInstVars:
1✔
226
                        #( blocking_discussions_resolved changes_count description
1✔
227
                           detailed_merge_status discussion_locked downvotes draft first_deployed_to_production_at
1✔
228
                           force_remove_source_branch has_conflicts id iid labels latest_build_finished_at
1✔
229
                           latest_build_started_at merge_commit_sha merge_status
1✔
230
                           merge_when_pipeline_succeeds merged_at milestone project_id
1✔
231
                           reference references_full references_relative
1✔
232
                           references_short sha should_remove_source_branch
1✔
233
                           source_branch source_project_id squash squash_commit_sha
1✔
234
                           squash_on_merge state subscribed target_branch target_project_id
1✔
235
                           task_completion_status_completed_count
1✔
236
                           task_completion_status_count time_stats_human_time_estimate
1✔
237
                           time_stats_human_total_time_spent
1✔
238
                           time_stats_time_estimate time_stats_total_time_spent
1✔
239
                           title updated_at upvotes user_notes_count web_url work_in_progress ).
1✔
240
                (mapping mapInstVar: #created_at) valueSchema: DateAndTime.
1✔
241
                (mapping mapInstVar: #updated_at) valueSchema: DateAndTime.
1✔
242
                (mapping mapInstVar: #merged_at) valueSchema: DateAndTime.
1✔
243
                (mapping mapInstVar: #closed_at) valueSchema: DateAndTime.
1✔
244
                "(mapping mapInstVar: #assignee) valueSchema: GLHUser."
1✔
245
                mapping
1✔
246
                        mapProperty: #author
1✔
247
                        getter: [  ]
1✔
248
                        setter: [ :object :value |
1✔
249
                        object cacheAt: #authorID put: (value at: #id) ].
1✔
250
                mapping
1✔
251
                        mapProperty: #merge_user
1✔
252
                        getter: [  ]
1✔
253
                        setter: [ :object :value | 
1✔
254
                                value ifNotNil: [
1✔
255
                                        object cacheAt: #mergeUserID put: (value at: #id) ] ] ].
1✔
256

1✔
257
        "(mapping mapInstVar: #closed_by) valueSchema: GLHUser.
1✔
258
        (mapping mapInstVar: #mergeCommit) valueSchema: GLHCommit."
1✔
259
        "indique ce que doit faire le reader lorsqu'il parse une DateAndTime object"
1✔
260
        reader for: DateAndTime customDo: [ :mapping |
1✔
261
                mapping decoder: [ :string |
1✔
262
                        string ifNil: [ nil ] ifNotNil: [ DateAndTime fromString: string ] ] ]
1✔
263
]
1✔
264

265
{ #category : #private }
NEW
266
GitlabModelImporter >> convertApiFileAsFile: aAPIFile [
×
NEW
267

×
NEW
268
        aAPIFile type = 'tree' ifTrue: [ 
×
NEW
269
                ^ GLHFileDirectory new
×
NEW
270
                          name: aAPIFile name;
×
NEW
271
                          yourself ].
×
NEW
272
        ^ GLHFileBlob new
×
NEW
273
                  name: aAPIFile name;
×
NEW
274
                  yourself
×
NEW
275
]
×
276

277
{ #category : #private }
278
GitlabModelImporter >> detectEntityType: aType overAttribut: aSelector equalTo: value [
1✔
279

1✔
280
        ^ (self glhModel allWithType: aType) detect: [ :entity |
1✔
281
                  (entity perform: aSelector) = value ] ifNone: [ nil ]. 
1✔
282
]
1✔
283

284
{ #category : #accessing }
NEW
285
GitlabModelImporter >> glhApi [
×
NEW
286

×
NEW
287
        self
×
NEW
288
                deprecated: 'Use #repoApi instead'
×
NEW
289
                on: '7 October 2024'
×
NEW
290
                in:
×
NEW
291
                'Pharo-11.0.0+build.726.sha.aece1b5473acf3830a0e082c1bc3a15d4ff3522b (64 Bit)'.
×
NEW
292

×
NEW
293
        ^ repoApi
×
NEW
294
]
×
295

296
{ #category : #accessing }
NEW
297
GitlabModelImporter >> glhApi: anObject [
×
NEW
298

×
NEW
299
        self
×
NEW
300
                deprecated: 'Use #repoApi: instead'
×
NEW
301
                on: '7 October 2024'
×
NEW
302
                in:
×
NEW
303
                'Pharo-11.0.0+build.726.sha.aece1b5473acf3830a0e082c1bc3a15d4ff3522b (64 Bit)'.
×
NEW
304

×
NEW
305
        repoApi := anObject
×
NEW
306
]
×
307

308
{ #category : #accessing }
309
GitlabModelImporter >> glhModel [
1✔
310

1✔
311
        ^ glhModel
1✔
312
]
1✔
313

314
{ #category : #accessing }
315
GitlabModelImporter >> glhModel: anObject [
1✔
316

1✔
317
        glhModel := anObject
1✔
318
]
1✔
319

320
{ #category : #'import - users' }
NEW
321
GitlabModelImporter >> importActiveHumanUsers [
×
NEW
322

×
NEW
323
        | params result users |
×
NEW
324
        params := { 
×
NEW
325
                #humans -> 'true'.
×
NEW
326
                #active -> 'true'.
×
NEW
327
                #without_project_bots -> 'true'
×
NEW
328
        } asDictionary.
×
NEW
329
        result := self repoApi users allWithParams: params.
×
NEW
330
        users := (result collect: [ :usersJson | self parseUsersResult: usersJson ]) flattened.
×
NEW
331
        
×
NEW
332
        self glhModel
×
NEW
333
                                 addAll: users
×
NEW
334
                                 unless: self blockOnIdEquality.
×
NEW
335

×
NEW
336
        ^ users
×
NEW
337
]
×
338

339
{ #category : #'import - groups' }
NEW
340
GitlabModelImporter >> importAllGroups [
×
NEW
341

×
NEW
342
        | params results groups |
×
NEW
343
        
×
NEW
344
        params := { 
×
NEW
345
                        #top_level_only -> 'true'
×
NEW
346
        } asDictionary.
×
NEW
347
        results := self repoApi groups getAllWithParams: params.
×
NEW
348
        
×
NEW
349
        groups := (results collect: [ :groupsJson | generalReader
×
NEW
350
                                            on: groupsJson readStream;
×
NEW
351
                                            nextAs: #ArrayOfGroups. ]) flattened.
×
NEW
352
        ^ groups
×
NEW
353
]
×
354

355
{ #category : #'import - commits' }
NEW
356
GitlabModelImporter >> importAndLoadLatestsCommitsOfProject: aGLHProject [
×
NEW
357

×
NEW
358
        | commits completedProject |
×
NEW
359
        completedProject := self completeImportProject: aGLHProject.
×
NEW
360
        commits := self importLastestCommitsOfProject: completedProject.
×
NEW
361
        commits do: [ :commit | self completeImportedCommit: commit ].
×
NEW
362
        self chainsCommitsFrom: commits.
×
NEW
363
        ^ commits
×
NEW
364
]
×
365

366
{ #category : #'import - commits' }
NEW
367
GitlabModelImporter >> importCommit: aCommitID ofProject: aGLHProject [
×
NEW
368

×
NEW
369
        | result parsedResult |
×
NEW
370
        (self glhModel allWithType: GLHCommit) asOrderedCollection
×
NEW
371
                detect: [ :commit | commit id = aCommitID ]
×
NEW
372
                ifFound: [ :commit | ^ commit ].
×
NEW
373
        result := self repoApi commits get: aCommitID inProject: aGLHProject id.
×
NEW
374
        
×
NEW
375
        parsedResult := self parseCommitResult: result.
×
NEW
376
        
×
NEW
377
        self
×
NEW
378
                addCommits: { parsedResult }
×
NEW
379
                toRepository: aGLHProject repository.
×
NEW
380
        ^ parsedResult
×
NEW
381
]
×
382

383
{ #category : #'import - commits' }
384
GitlabModelImporter >> importCommitOfProject: anProject withId: anID [
1✔
385

1✔
386
        | commit result |
1✔
387
        anID ifNil: [ ^ nil ].
1✔
388

1✔
389
        ('looking for commit ' , anID printString , ' in project : '
1✔
390
         , anProject id printString) recordInfo.
1✔
391

1✔
392
        commit := (self
1✔
393
                           detectEntityType: GLHCommit
1✔
394
                           overAttribut: #id
1✔
395
                           equalTo: anID) ifNil: [
1✔
396
                          result := self repoApi commits get: anID inProject: anProject id.
1✔
397
                          commit := (self parseCommitsResult: '[' , result , ']')
1✔
398
                                            first.
1✔
399

1✔
400
                          self glhModel add: commit unless: self blockOnIdEquality.
1✔
401
                          commit repository: anProject repository.
1✔
402

1✔
403
                          commit ].
1✔
404

1✔
405
        self withCommitDiffs ifTrue: [ self importDiffOfCommit: commit ].
1✔
406

1✔
407
        ^ commit
1✔
408
]
1✔
409

410
{ #category : #'import - commits' }
NEW
411
GitlabModelImporter >> importCommits: aGLHProject [
×
NEW
412
        "limited to the last 20 commits"
×
NEW
413

×
NEW
414
        | results parsedResults params |
×
NEW
415
        params := { 
×
NEW
416
         #with_stats -> 'true'
×
NEW
417
        } asDictionary.
×
NEW
418
        results := self repoApi commits getByPage: 1 perPage: 20 inProject: aGLHProject id withParams: params.
×
NEW
419
        
×
NEW
420
        parsedResults := self parseCommitsResult: results.
×
NEW
421
        self glhModel addAll: parsedResults unless: self blockOnIdEquality.
×
NEW
422

×
NEW
423
        parsedResults do: [ :commit |
×
NEW
424
                commit repository: aGLHProject repository ].
×
NEW
425

×
NEW
426
        self withCommitDiffs ifTrue: [
×
NEW
427
                parsedResults do: [ :commit | self importDiffOfCommit: commit ] ].
×
NEW
428
        
×
NEW
429
        ^ parsedResults. 
×
NEW
430
]
×
431

432
{ #category : #'import - commits' }
NEW
433
GitlabModelImporter >> importCommitsFollowing: aCommit upToDays: aNumberOfDay [
×
NEW
434
        "import the 'n' commits of a project starting from an initial 'aCommit' commit. 
×
NEW
435
        Lazy import does not import the entities inside the model"
×
NEW
436

×
NEW
437
        | date |
×
NEW
438
        date := aCommit created_at asDateAndTime.
×
NEW
439

×
NEW
440
        ^ self
×
NEW
441
                  importCommitsOfBranch: aCommit branch
×
NEW
442
                  forRefName: aCommit branch name
×
NEW
443
                  since: date
×
NEW
444
                  until: (date + aNumberOfDay day)
×
NEW
445
]
×
446

447
{ #category : #commit }
NEW
448
GitlabModelImporter >> importCommitsOf: aGLHProject withStats: aBoolean until: toDate [
×
NEW
449

×
NEW
450
        | newlyFoundCommit page |
×
NEW
451
        
×
NEW
452
        self deprecated: [  ] .
×
NEW
453
        
×
NEW
454
        page := 0.
×
NEW
455
        newlyFoundCommit := { true }.
×
NEW
456
        [ newlyFoundCommit isNotEmpty ] whileTrue: [
×
NEW
457
                | results parsedResults existingCommits |
×
NEW
458
                page := page + 1.
×
NEW
459
                ('import commit page ' , page printString) recordInfo.
×
NEW
460
                results := self repoApi
×
NEW
461
                                   commitsOfProject: aGLHProject id
×
NEW
462
                                   forRefName: nil
×
NEW
463
                                   since: nil
×
NEW
464
                                   until: nil
×
NEW
465
                                   path: nil
×
NEW
466
                                   author: nil
×
NEW
467
                                   all: nil
×
NEW
468
                                   with_stats: aBoolean
×
NEW
469
                                   firstParent: nil
×
NEW
470
                                   order: nil
×
NEW
471
                                   trailers: nil
×
NEW
472
                                   perPage: 100
×
NEW
473
                                   page: page.
×
NEW
474
                parsedResults := self parseCommitsResult: results.
×
NEW
475
                existingCommits := aGLHProject mooseModel allWithType: GLHCommit.
×
NEW
476

×
NEW
477
                newlyFoundCommit := parsedResults reject: [ :commitParsed |
×
NEW
478
                                            (toDate isNil or: [
×
NEW
479
                                                     commitParsed committed_date
×
NEW
480
                                                     < toDate asDateAndTime ]) or: [
×
NEW
481
                                                    existingCommits anySatisfy: [ :existingCommit |
×
NEW
482
                                                            existingCommit id = commitParsed id ] ] ].
×
NEW
483
                aGLHProject mooseModel addAll: newlyFoundCommit.
×
NEW
484
                aGLHProject repository commits addAll: newlyFoundCommit ].
×
NEW
485

×
NEW
486

×
NEW
487
        self withCommitDiffs ifTrue: [
×
NEW
488
                aGLHProject repository commits do: [ :commit |
×
NEW
489
                        self importDiffOfCommit: commit ] ]
×
NEW
490
]
×
491

492
{ #category : #'import - commits' }
NEW
493
GitlabModelImporter >> importCommitsOfBranch: aGLHBranch [
×
NEW
494

×
NEW
495
        | commits |
×
NEW
496
        "        result := self glhApi
×
NEW
497
                          commitsOfProject: aGLHBranch repository project id
×
NEW
498
                          forRefName: aGLHBranch name."
×
NEW
499
        commits := self
×
NEW
500
                           importCommitsOfBranch: aGLHBranch
×
NEW
501
                           forRefName: aGLHBranch name
×
NEW
502
                           since: withCommitsSince.
×
NEW
503

×
NEW
504
        self chainsCommitsFrom: commits.
×
NEW
505

×
NEW
506
        commits do: [ :aCommit |
×
NEW
507
                aCommit repository: aGLHBranch repository.
×
NEW
508
                self completeImportedCommit: aCommit. 
×
NEW
509
                 ]
×
NEW
510
]
×
511

512
{ #category : #'import - commits' }
NEW
513
GitlabModelImporter >> importCommitsOfBranch: aGLHBranch forRefName: refName since: fromDate [
×
NEW
514

×
NEW
515
        ^ self
×
NEW
516
                  importCommitsOfBranch: aGLHBranch
×
NEW
517
                  forRefName: aGLHBranch name
×
NEW
518
                  since: fromDate
×
NEW
519
                  until: nil
×
NEW
520
]
×
521

522
{ #category : #'import - commits' }
NEW
523
GitlabModelImporter >> importCommitsOfBranch: aGLHBranch forRefName: refName since: fromDate until: toDate [
×
NEW
524

×
NEW
525
        | params result allCommits |
×
NEW
526
        params := { 
×
NEW
527
          #ref_name -> aGLHBranch name.
×
NEW
528
          #since ->  (fromDate ifNotNil: [ fromDate asDate asDateAndTime asString ] ifNil: [ '' ]).
×
NEW
529
          #until -> (toDate ifNotNil: [ toDate asDate asDateAndTime asString ] ifNil: [ '' ]). 
×
NEW
530

×
NEW
531
        } asDictionary.
×
NEW
532
        result := self repoApi commits getAllInProject: aGLHBranch repository project id withParams: params.
×
NEW
533
        
×
NEW
534
        allCommits := (result collect: [ :commitsJson | self parseCommitsResult: commitsJson ]) flattened.
×
NEW
535
        
×
NEW
536
        aGLHBranch commits
×
NEW
537
                        addAll: allCommits
×
NEW
538
                        unless: self blockOnIdEquality.
×
NEW
539

×
NEW
540
        self glhModel
×
NEW
541
                addAll: aGLHBranch commits
×
NEW
542
                unless: self blockOnIdEquality.
×
NEW
543

×
NEW
544
        ^ allCommits
×
NEW
545
]
×
546

547
{ #category : #'import - commits' }
NEW
548
GitlabModelImporter >> importCommitsOfBranch: aGLHBranch forRefName: refName until: toDate [
×
NEW
549

×
NEW
550
        ^ self
×
NEW
551
                  importCommitsOfBranch: aGLHBranch
×
NEW
552
                  forRefName: aGLHBranch name
×
NEW
553
                  since: nil
×
NEW
554
                  until: toDate
×
NEW
555
]
×
556

557
{ #category : #'import - commits' }
558
GitlabModelImporter >> importCommitsOfProject: aProject since: fromDate until: toDate [
1✔
559

1✔
560
        | params results allCommits |
1✔
561
        params := {
1✔
562
                          (#since
1✔
563
                           ->
1✔
564
                           (fromDate
1✔
565
                                    ifNotNil: [ fromDate asDate asDateAndTime asString ]
1✔
566
                                    ifNil: [ '' ])).
1✔
567
                          (#until
1✔
568
                           ->
1✔
569
                           (toDate
1✔
570
                                    ifNotNil: [ toDate asDate asDateAndTime asString ]
1✔
571
                                    ifNil: [ '' ])).
1✔
572
                          (#with_stats -> 'true').
1✔
573
                          (#all -> 'true') } asDictionary.
1✔
574
        results := self repoApi commits
1✔
575
                           getAllInProject: aProject id
1✔
576
                           withParams: params.
1✔
577

1✔
578
        allCommits := (results collect: [ :commitsJson |
1✔
579
                               self parseCommitsResult: commitsJson ]) flattened.
1✔
580

1✔
581
        allCommits:= aProject repository commits
1✔
582
                addAll: allCommits
1✔
583
                unless: self blockOnIdEquality.
1✔
584

1✔
585
        ^ self glhModel addAll: allCommits unless: self blockOnIdEquality
1✔
586
]
1✔
587

588
{ #category : #'import - projects' }
NEW
589
GitlabModelImporter >> importContributedProjectsOfUser: aGLHUser [
×
NEW
590

×
NEW
591
        | remaningProjects params results projects projectsIds |
×
NEW
592
        params := {
×
NEW
593
                          (#order_by -> 'last_activity_at').
×
NEW
594
                          (#simple -> 'true') } asDictionary.
×
NEW
595
        results := self repoApi projects
×
NEW
596
                           contributedProjectsOfUser: aGLHUser id
×
NEW
597
                           withParams: params.
×
NEW
598

×
NEW
599
        projectsIds := (results collect: [ :projectsJson |
×
NEW
600
                             (NeoJSONReader fromString: projectsJson) collect: [:projectJson | projectJson at: #id ] ]) flattened.
×
NEW
601
        
×
NEW
602
        projects := self importProjects: projectsIds.
×
NEW
603
        remaningProjects := self importProjects:
×
NEW
604
                                    ((projects collect: #id) difference:
×
NEW
605
                                             ((self userCatalogue atId: aGLHUser id) at:
×
NEW
606
                                                      #contributedProjects)).
×
NEW
607

×
NEW
608

×
NEW
609
        aGLHUser contributedProjects
×
NEW
610
                addAll: projects , remaningProjects
×
NEW
611
                unless: self blockOnIdEquality.
×
NEW
612

×
NEW
613
        self userCatalogue
×
NEW
614
                addUser: aGLHUser
×
NEW
615
                withProjects: (aGLHUser contributedProjects collect: #id).
×
NEW
616

×
NEW
617
        ^ projects
×
NEW
618
]
×
619

620
{ #category : #'import - commits' }
621
GitlabModelImporter >> importCreatorOfCommit: aCommit [
1✔
622

1✔
623
        aCommit commitCreator ifNil: [
1✔
624
                aCommit commitCreator:
1✔
625
                        (self importUserByUsername: aCommit author_name) ].
1✔
626
        self userCatalogue
1✔
627
                addUser: aCommit commitCreator
1✔
628
                withProject: aCommit repository project id.
1✔
629
        ^ aCommit commitCreator
1✔
630
]
1✔
631

632
{ #category : #'import - commits' }
633
GitlabModelImporter >> importDiffOfCommit: aCommit [
1✔
634

1✔
635
        | result diffsResult |
1✔
636
        aCommit diffs ifNotEmpty: [
1✔
637
                'Diff already importer: ' , aCommit short_id printString recordInfo.
1✔
638
                ^ aCommit diffs ].
1✔
639
        ('Import diff of commit: ' , aCommit short_id printString) recordInfo.
1✔
640

1✔
641
        result := self repoApi commits
1✔
642
                          diffOf: aCommit id
1✔
643
                          inProject: aCommit repository project id
1✔
644
                          uniDiff: true.
1✔
645

1✔
646
        (self isServerError: result) ifTrue: [ ^ {  } ].
1✔
647
        diffsResult := self newParseDiffResult: result.
1✔
648

1✔
649
        aCommit diffs addAll: diffsResult unless: self blockForDiffEquality.
1✔
650
        
1✔
651
        "changes are added into the model during the import"
1✔
652
        aCommit diffs do: [ :diff | self importDiffRangesForDiff: diff ].
1✔
653

1✔
654
        ^ aCommit diffs
1✔
655
]
1✔
656

657
{ #category : #'import - merge request' }
658
GitlabModelImporter >> importDiffOfMergeRequest: aMergeRequest [
1✔
659

1✔
660
        | result diffsResult |
1✔
661
        aMergeRequest diffs ifNotEmpty: [
1✔
662
                'Diff of already importer: '
1✔
663
                , aMergeRequest iid printString recordInfo.
1✔
664
                ^ aMergeRequest diffs ].
1✔
665
        ('Import diff commits of MR ' , aMergeRequest iid printString)
1✔
666
                recordInfo.
1✔
667
        result := self repoApi mergeRequests diffsOf: aMergeRequest iid inProject: aMergeRequest project_id.
1✔
668

1✔
669
        diffsResult := self newParseDiffResult: result.
1✔
670

1✔
671

1✔
672
        aMergeRequest diffs
1✔
673
                addAll: diffsResult
1✔
674
                unless: self blockForDiffEquality.
1✔
675
        self glhModel
1✔
676
                addAll: aMergeRequest diffs
1✔
677
                unless: self blockForDiffEquality.
1✔
678

1✔
679
        aMergeRequest diffs do: [ :diff | self importDiffRangesForDiff: diff ].
1✔
680

1✔
681
        ^ aMergeRequest diffs
1✔
682
]
1✔
683

684
{ #category : #'import - repositories' }
NEW
685
GitlabModelImporter >> importDirectoryFiles: aDirectoryFile OfBranch: aBranch [
×
NEW
686

×
NEW
687
        | result files apiFiles params |
×
NEW
688
        params := { 
×
NEW
689
                #ref -> aBranch name.
×
NEW
690
                #path -> (aDirectoryFile path , '/')
×
NEW
691
        } asDictionary.
×
NEW
692
        result := self repoApi repositories repositoryTreeOfProject: aBranch repository project id withParams: params.
×
NEW
693
                         " treeOfRepository: aBranch repository project id
×
NEW
694
                          ofBranch: aBranch name
×
NEW
695
                          andPath: aDirectoryFile path , '/'."
×
NEW
696
        apiFiles := (result collect: [ :treeJson | self parseFileTreeResult: treeJson ]) flattened.
×
NEW
697
        files := apiFiles collect: [ :apiFile |
×
NEW
698
                         self convertApiFileAsFile: apiFile ].
×
NEW
699
        
×
NEW
700
        files do: [ :file |
×
NEW
701
                self glhModel add: file.
×
NEW
702
                aDirectoryFile addFile: file ].
×
NEW
703
        
×
NEW
704
        files
×
NEW
705
                select: [ :file | file isKindOf: GLHFileDirectory ]
×
NEW
706
                thenCollect: [ :file |
×
NEW
707
                self importDirectoryFiles: file OfBranch: aBranch ]
×
NEW
708
]
×
709

710
{ #category : #'import - repositories' }
NEW
711
GitlabModelImporter >> importFilesOfBranch: aBranch [
×
NEW
712

×
NEW
713
        | result files apiFiles params |
×
NEW
714
        params := { 
×
NEW
715
                #ref -> aBranch name.
×
NEW
716
        } asDictionary.
×
NEW
717
        
×
NEW
718
        result := self repoApi repositories repositoryTreeOfProject: aBranch repository project id withParams: params.
×
NEW
719
        
×
NEW
720
                          "treeOfRepository: aBranch repository project id
×
NEW
721
                          ofBranch: aBranch name
×
NEW
722
                          andPath: nil."
×
NEW
723
        apiFiles := (result collect: [ :filesJson | self parseFileTreeResult: filesJson  ]) flattened.
×
NEW
724
        files := apiFiles collect: [ :apiFile | 
×
NEW
725
                         self convertApiFileAsFile: apiFile ].
×
NEW
726
        files do: [ :file | 
×
NEW
727
                self glhModel add: file.
×
NEW
728
                aBranch addFile: file ].
×
NEW
729
        files
×
NEW
730
                select: [ :file | file isKindOf: GLHFileDirectory ]
×
NEW
731
                thenCollect: [ :file | 
×
NEW
732
                self importDirectoryFiles: file OfBranch: aBranch ]
×
NEW
733
]
×
734

735
{ #category : #'import - groups' }
736
GitlabModelImporter >> importGroup: aGroupID [
1✔
737

1✔
738
        | result groupResult |
1✔
739
        ('Import group: ' , aGroupID printString) recordInfo.
1✔
740

1✔
741
        result := self repoApi groups get: aGroupID.
1✔
742
        
1✔
743
        "group: aGroupID."
1✔
744
        groupResult := self parseGroupResult: result.
1✔
745
        groupResult := self addGroupResultToModel: groupResult.
1✔
746

1✔
747
        groupResult projects do: [ :project |
1✔
748
                self completeImportProject: project ].
1✔
749

1✔
750
        (self subGroupsOf: aGroupID) do: [ :subGroup |
1✔
751
                
1✔
752
                groupResult subGroups
1✔
753
                        add: (self importGroup: subGroup id)
1✔
754
                        unless: self blockOnIdEquality ].
1✔
755
        ^ groupResult
1✔
756
]
1✔
757

758
{ #category : #'import - jobs' }
NEW
759
GitlabModelImporter >> importJobsOf: aPipeline [
×
NEW
760

×
NEW
761
        | jobs results |
×
NEW
762
        results := self repoApi jobs allForPipeline: aPipeline id inProject: aPipeline project id.
×
NEW
763
                          "jobsOfProject: aPipeline project id
×
NEW
764
                          ofPipelines: aPipeline id."
×
NEW
765
        jobs := (results collect: [ :jobsJson | self parseJobsResult: jobsJson ofProject: aPipeline project ]) flattened.
×
NEW
766
        jobs do: [ :job | aPipeline addJob: job ].
×
NEW
767
        self glhModel addAll: jobs.
×
NEW
768
        
×
NEW
769
        ^jobs
×
NEW
770

×
NEW
771
]
×
772

773
{ #category : #'import - commits' }
774
GitlabModelImporter >> importLastestCommitsOfProject: aGLHProject [
1✔
775
        "limited to the last 50 commits"
1✔
776

1✔
777
        | results parsedResults params |
1✔
778
        params := { 
1✔
779
                #with_stats -> 'true'.
1✔
780
                #all -> true
1✔
781
         } asDictionary.
1✔
782
        results := self repoApi commits getByPage: 1 perPage: 50 inProject: aGLHProject id withParams: params.
1✔
783

1✔
784
        parsedResults := self parseCommitsResult: results.
1✔
785
        parsedResults := self glhModel
1✔
786
                                 addAll: parsedResults
1✔
787
                                 unless: self blockOnIdEquality.
1✔
788

1✔
789
        aGLHProject repository commits
1✔
790
                addAll: parsedResults
1✔
791
                unless: self blockOnIdEquality.
1✔
792

1✔
793
        self withCommitDiffs ifTrue: [
1✔
794
                parsedResults do: [ :commit | self importDiffOfCommit: commit ] ].
1✔
795

1✔
796
        ^ parsedResults
1✔
797
]
1✔
798

799
{ #category : #'import - merge request' }
NEW
800
GitlabModelImporter >> importMergeRequestCommits: aGLPHEMergeRequest [
×
NEW
801

×
NEW
802
        | commits result |
×
NEW
803
        aGLPHEMergeRequest commits ifNotNil: [ ^ aGLPHEMergeRequest commits ].
×
NEW
804
        
×
NEW
805
        result := self repoApi mergeRequests commitsOf: aGLPHEMergeRequest iid inProject: aGLPHEMergeRequest project id.
×
NEW
806
        
×
NEW
807
        commits := (result collect: [ :commitsJson | self parseCommitsResult: commitsJson ]) flattened.
×
NEW
808
        commits := commits collect: [ :commit | self importCommit: commit id ofProject: aGLPHEMergeRequest project ].
×
NEW
809
        aGLPHEMergeRequest commits: commits.
×
NEW
810

×
NEW
811

×
NEW
812
        ^ commits
×
NEW
813
]
×
814

815
{ #category : #'import - merge request' }
816
GitlabModelImporter >> importMergeRequestMergeCommits: aGLPHEMergeRequest [
1✔
817

1✔
818
        | foundCommits |
1✔
819
        foundCommits := OrderedCollection new.
1✔
820

1✔
821
        ('Import commit sha of MR:  ' , aGLPHEMergeRequest iid printString)
1✔
822
                recordInfo.
1✔
823
        "the founds commits are added to the model during their respective import"
1✔
824
        aGLPHEMergeRequest mergeRequestCommit: ((self
1✔
825
                          importCommitOfProject: aGLPHEMergeRequest project
1✔
826
                          withId: aGLPHEMergeRequest sha) ifNotNil: [ :commit |
1✔
827
                         foundCommits add: commit ]).
1✔
828

1✔
829
        ('Import commit merge_commit_sha of MR:  '
1✔
830
         , aGLPHEMergeRequest iid printString) recordInfo.
1✔
831
        aGLPHEMergeRequest mergedCommit: ((self
1✔
832
                          importCommitOfProject: aGLPHEMergeRequest project
1✔
833
                          withId: aGLPHEMergeRequest merge_commit_sha) ifNotNil: [ :commit |
1✔
834
                         foundCommits add: commit ]).
1✔
835

1✔
836
        ('Import commit squash_commit_sha of MR:  '
1✔
837
         , aGLPHEMergeRequest iid printString) recordInfo.
1✔
838
        aGLPHEMergeRequest squashCommit: ((self
1✔
839
                          importCommitOfProject: aGLPHEMergeRequest project
1✔
840
                          withId: aGLPHEMergeRequest squash_commit_sha) ifNotNil: [ :commit |
1✔
841
                         foundCommits add: commit ]).
1✔
842

1✔
843

1✔
844
        self chainsCommitsFrom: foundCommits.
1✔
845
        ^ foundCommits
1✔
846
]
1✔
847

848
{ #category : #'import - merge request' }
849
GitlabModelImporter >> importMergeRequests: aGLHProject [
1✔
850

1✔
851
        | results parsedResults mrs |
1✔
852
        ('Import merge request of Project: ' , aGLHProject id printString)
1✔
853
                recordInfo.
1✔
854

1✔
855
        results := self repoApi mergeRequests allOfProject: aGLHProject id.
1✔
856
        parsedResults := (results collect: [ :projectsJson | self parseMergeRequestResult: projectsJson ]) flattened. 
1✔
857

1✔
858
        aGLHProject mergeRequests
1✔
859
                addAll: parsedResults
1✔
860
                unless: self blockOnIdEquality.
1✔
861

1✔
862
        mrs := self glhModel
1✔
863
                       addAll: aGLHProject mergeRequests
1✔
864
                       unless: self blockOnIdEquality.
1✔
865

1✔
866

1✔
867
        "gets it related commits"
1✔
868
        aGLHProject mergeRequests do: [ :mr |
1✔
869
                self importMergeRequestMergeCommits: mr ].
1✔
870

1✔
871

1✔
872
        self withCommitDiffs ifTrue: [
1✔
873
                aGLHProject mergeRequests do: [ :mr |
1✔
874
                        self importDiffOfMergeRequest: mr ] ].
1✔
875

1✔
876
        ^ mrs
1✔
877
]
1✔
878

879
{ #category : #'import - merge request' }
NEW
880
GitlabModelImporter >> importMergeRequests: aGLHProject since: fromDate until: toDate [
×
NEW
881

×
NEW
882
        | params result mergeRequests |
×
NEW
883
        ('import MR of Project ' , aGLHProject name) recordInfo.
×
NEW
884
        params := {
×
NEW
885
                          (#created_after
×
NEW
886
                           ->
×
NEW
887
                           (fromDate
×
NEW
888
                                    ifNotNil: [ fromDate asDateAndTime asString ]
×
NEW
889
                                    ifNil: [ '' ])).
×
NEW
890
                          (#created_before
×
NEW
891
                           ->
×
NEW
892
                           (toDate
×
NEW
893
                                    ifNotNil: [ toDate asDateAndTime asString ]
×
NEW
894
                                    ifNil: [ '' ])).
×
NEW
895
                          (#scope -> 'all') } asDictionary.
×
NEW
896

×
NEW
897
        result := self repoApi mergeRequests
×
NEW
898
                          allOfProject: aGLHProject id
×
NEW
899
                          withParams: params.
×
NEW
900
        mergeRequests := (result collect: [ :mergeRequestsJson |
×
NEW
901
                                  self parseMergeRequestResult: mergeRequestsJson ])
×
NEW
902
                                 flattened.
×
NEW
903

×
NEW
904
        aGLHProject mergeRequests
×
NEW
905
                addAll: mergeRequests
×
NEW
906
                unless: self blockOnIdEquality.
×
NEW
907

×
NEW
908
        "gets it related commits"
×
NEW
909
        aGLHProject mergeRequests do: [ :mr |
×
NEW
910
                self importMergeRequestMergeCommits: mr ].
×
NEW
911

×
NEW
912
        self withCommitDiffs ifTrue: [
×
NEW
913
                aGLHProject mergeRequests do: [ :mr |
×
NEW
914
                        self importDiffOfMergeRequest: mr ] ].
×
NEW
915

×
NEW
916
        self glhModel
×
NEW
917
                addAll: mergeRequests
×
NEW
918
                unless: (self blockEqualityOn: #iid).
×
NEW
919

×
NEW
920
        ^ mergeRequests
×
NEW
921
]
×
922

923
{ #category : #'import - merge request' }
NEW
924
GitlabModelImporter >> importMergeResquestApprovals: aGLPHEMergeRequest [
×
NEW
925

×
NEW
926
        | results parsedResult |
×
NEW
927
        (String streamContents: [ :str |
×
NEW
928
                 str << 'Check approvals of '.
×
NEW
929
                 aGLPHEMergeRequest printOn: str ]) recordInfo.
×
NEW
930
        results := self repoApi mergeRequests approvalsOf: aGLPHEMergeRequest iid inProject: aGLPHEMergeRequest project id.
×
NEW
931

×
NEW
932
        parsedResult := generalReader
×
NEW
933
                                on: results readStream;
×
NEW
934
                                next.
×
NEW
935

×
NEW
936
        (parsedResult at: #approved_by) do: [ :approvedUser |
×
NEW
937
                aGLPHEMergeRequest addApproved_by:
×
NEW
938
                        (self importUser: ((approvedUser at: #user) at: #id)) ].
×
NEW
939
        aGLPHEMergeRequest approved: (parsedResult at: #approved).
×
NEW
940
        ^ aGLPHEMergeRequest
×
NEW
941
]
×
942

943
{ #category : #'import - merge request' }
944
GitlabModelImporter >> importMergeResquestAuthor: aGLPHEMergeRequest [
1✔
945

1✔
946
        | authorID |
1✔
947
        aGLPHEMergeRequest author ifNotNil: [ ^ aGLPHEMergeRequest author ].
1✔
948
        authorID := aGLPHEMergeRequest cacheAt: #authorID ifAbsent: [
1✔
949
                            | result |
1✔
950
                            result := self repoApi mergeRequests
1✔
951
                                              get: aGLPHEMergeRequest iid
1✔
952
                                              inProject: aGLPHEMergeRequest project_id.
1✔
953

1✔
954
                            (generalReader
1✔
955
                                     on: result readStream;
1✔
956
                                     next) at: #author at: #id ].
1✔
957
        ^aGLPHEMergeRequest author: (self importUser: authorID)
1✔
958
]
1✔
959

960
{ #category : #'import - merge request' }
961
GitlabModelImporter >> importMergeResquestMerger: aGLPHEMergeRequest [
1✔
962

1✔
963
        | authorID |
1✔
964
        aGLPHEMergeRequest merge_user ifNotNil: [
1✔
965
                ^ aGLPHEMergeRequest merge_user ].
1✔
966
        authorID := aGLPHEMergeRequest cacheAt: #mergeUserID ifAbsent: [
1✔
967
                            | result |
1✔
968
                            result := self repoApi mergeRequests
1✔
969
                                              get: aGLPHEMergeRequest iid
1✔
970
                                              inProject: aGLPHEMergeRequest project_id.
1✔
971
                            (generalReader
1✔
972
                                     on: result readStream;
1✔
973
                                     next)
1✔
974
                                    at: #merge_user
1✔
975
                                    ifPresent: [ :mergeUser |
1✔
976
                                    mergeUser ifNotNil: [ :mruser | mruser at: #id ] ] ].
1✔
977
        ^aGLPHEMergeRequest merge_user: (self importUser: authorID)
1✔
978
]
1✔
979

980
{ #category : #'import - commits' }
NEW
981
GitlabModelImporter >> importParentCommitsOfCommit: aGLHCommit since: aDate [
×
NEW
982

×
NEW
983
        | parentsIds commits |
×
NEW
984
        commits := OrderedCollection new.
×
NEW
985
        aGLHCommit created_at asDateAndTime < aDate asDateAndTime ifTrue: [
×
NEW
986
                 
×
NEW
987
                ^ commits
×
NEW
988
                          add: aGLHCommit;
×
NEW
989
                          yourself ].
×
NEW
990

×
NEW
991
        parentsIds := aGLHCommit parent_ids.
×
NEW
992

×
NEW
993
        commits addAll: (parentsIds collect: [ :id |
×
NEW
994
                         self
×
NEW
995
                                 importCommitOfProject: aGLHCommit repository project
×
NEW
996
                                 withId: id ]).
×
NEW
997

×
NEW
998

×
NEW
999
        ^ (commits collect: [ :parentCommit |
×
NEW
1000
                   self importParentCommitsOfCommit: parentCommit since: aDate ])
×
NEW
1001
                  flatten
×
NEW
1002
]
×
1003

1004
{ #category : #'imports - pipelines' }
1005
GitlabModelImporter >> importPipelinesOfProject: aGLHProject [
1✔
1006

1✔
1007
        (self pipelinesOf: aGLHProject id) do: [ :pipeline |
1✔
1008
                self glhModel add: pipeline unless: self blockOnIdEquality .
1✔
1009
                aGLHProject pipelines add: pipeline unless: self blockOnIdEquality]
1✔
1010
]
1✔
1011

1012
{ #category : #'import - projects' }
1013
GitlabModelImporter >> importProject: aProjectID [
1✔
1014

1✔
1015
        | result projectResult |
1✔
1016
        ('Import project with id:  ' , aProjectID printString) recordInfo.
1✔
1017

1✔
1018
        (glhModel allWithType: GLHProject)
1✔
1019
                detect: [ :project | project id = aProjectID ]
1✔
1020
                ifFound: [ :project | ^ project ].
1✔
1021

1✔
1022
        result := self repoApi projects get: aProjectID.
1✔
1023
        projectResult := self parseProjectResult: result.
1✔
1024

1✔
1025
        ^ self completeImportProject: projectResult
1✔
1026
]
1✔
1027

1028
{ #category : #'import - projects' }
NEW
1029
GitlabModelImporter >> importProjects [
×
NEW
1030

×
NEW
1031
        | result projects |
×
NEW
1032
        ('import all Projects') recordInfo.
×
NEW
1033

×
NEW
1034

×
NEW
1035
        result := self repoApi projects all.
×
NEW
1036
        projects := (result collect: [ :projectsJson | self parseArrayOfProject: projectsJson ]) flattened.
×
NEW
1037
        
×
NEW
1038
        self glhModel addAll: projects unless: self blockOnIdEquality.
×
NEW
1039

×
NEW
1040
        ^ projects
×
NEW
1041
]
×
1042

1043
{ #category : #'import - projects' }
NEW
1044
GitlabModelImporter >> importProjects: aCollectionOfProjectID [
×
NEW
1045

×
NEW
1046

×
NEW
1047
        ^ aCollectionOfProjectID collect: [ :id | self importProject: id ]
×
NEW
1048
]
×
1049

1050
{ #category : #imports }
NEW
1051
GitlabModelImporter >> importProjectsSince: since [
×
NEW
1052
        "heavy import of all projects"
×
NEW
1053

×
NEW
1054
        "copy import from commits"
×
NEW
1055

×
NEW
1056
        | newlyFoundProjects page foundProject amount |
×
NEW
1057
        ('import all Projects since: ' , since printString) recordInfo.
×
NEW
1058

×
NEW
1059
        "number of projects per page"
×
NEW
1060
        amount := 100.
×
NEW
1061
        page := 0.
×
NEW
1062
        foundProject := OrderedCollection new.
×
NEW
1063
        newlyFoundProjects := { true }.
×
NEW
1064
        [ newlyFoundProjects isNotEmpty ] whileTrue: [
×
NEW
1065
                | results |
×
NEW
1066
                page := page + 1.
×
NEW
1067
                ('import projects page #' , page printString) recordInfo.
×
NEW
1068

×
NEW
1069
                results := self repoApi projects: amount since: since page: page.
×
NEW
1070

×
NEW
1071
                newlyFoundProjects := self glhModel
×
NEW
1072
                                              addAll: (self parseArrayOfProject: results)
×
NEW
1073
                                              unless: self blockOnIdEquality.
×
NEW
1074
                foundProject addAll: newlyFoundProjects ].
×
NEW
1075
]
×
1076

1077
{ #category : #'import - repositories' }
1078
GitlabModelImporter >> importRepository: aGLHRepository [
1✔
1079

1✔
1080
        | resultBranches branches |
1✔
1081
        [
1✔
1082
        ('import the repository of project ' , aGLHRepository project name)
1✔
1083
                recordInfo.
1✔
1084

1✔
1085
        resultBranches := self repoApi branches getAllFromProject:
1✔
1086
                                  aGLHRepository project id.
1✔
1087

1✔
1088
        branches := (resultBranches collect: [ :branchesJson |
1✔
1089
                             self parseBranchesResult: branchesJson ]) flattened.
1✔
1090

1✔
1091
        'import the branches of project ' recordInfo.
1✔
1092

1✔
1093
        branches := aGLHRepository branches
1✔
1094
                            addAll: branches
1✔
1095
                            unless: self blockOnNameEquality.
1✔
1096
        branches := self glhModel
1✔
1097
                            addAll: branches
1✔
1098
                            unless: self blockOnNameEquality.
1✔
1099

1✔
1100

1✔
1101
        self withFiles ifTrue: [
1✔
1102
                branches do: [ :branch | self importFilesOfBranch: branch ] ] ]
1✔
1103
                on: NeoJSONParseError
1✔
1104
                do: [
1✔
1105
                self inform: aGLHRepository project name , ' has no repository' ].
1✔
1106
        
1✔
1107
        withInitialCommits ifTrue: [
1✔
1108
                aGLHRepository branches do: [ :branch |
1✔
1109
                        self importCommitsOfBranch: branch ] ]
1✔
1110
]
1✔
1111

1112
{ #category : #'import - users' }
1113
GitlabModelImporter >> importUser: aUserID [
1✔
1114

1✔
1115
        | result userResult |
1✔
1116
        (self glhModel allWithType: GLHUser)
1✔
1117
                detect: [ :user | user id = aUserID ]
1✔
1118
                ifFound: [ :user | ^ user ].
1✔
1119
        ('Import user: ' , aUserID printString) recordInfo.
1✔
1120
        
1✔
1121
        result := self repoApi users get: aUserID.
1✔
1122
        userResult := self parseUserResult: result.
1✔
1123
        
1✔
1124
        userResult := self glhModel add: userResult unless: self blockOnIdEquality.
1✔
1125
        userCatalogue addUser: userResult.
1✔
1126
        ^ userResult 
1✔
1127
]
1✔
1128

1129
{ #category : #'import - users' }
1130
GitlabModelImporter >> importUserByUsername: anUsername [
1✔
1131

1✔
1132
        | dicUsername resultUser |
1✔
1133
        dicUsername := ((self glhModel allWithType: GLHUser) collect: [ :user |
1✔
1134
                                user username -> user ]) asSet asDictionary.
1✔
1135

1✔
1136
        dicUsername addAll: self userCatalogue collectUsernames.
1✔
1137

1✔
1138

1✔
1139
        resultUser := dicUsername
1✔
1140
                              at: anUsername
1✔
1141
                              ifAbsent: [ "thus we have to import this new user"
1✔
1142
                                      | result userId searchResult params |
1✔
1143
                                      ('Import user with username: '
1✔
1144
                                       , anUsername printString) recordInfo.
1✔
1145
                                      params := { (#search -> anUsername) } asDictionary.
1✔
1146
                                      result := self repoApi users allWithParams: params.
1✔
1147
                                                        
1✔
1148
                                                         "when result is an error"
1✔
1149
                                                         (result isString) ifTrue: [ result := { result } ].
1✔
1150
                                                        
1✔
1151
                                      searchResult := result ifEmpty: [ result ] ifNotEmpty: [(result collect: [ :usersJson |
1✔
1152
                                                               NeoJSONReader fromString: usersJson ]) first].
1✔
1153
                                                         
1✔
1154
                                      (searchResult class = Dictionary and: [
1✔
1155
                                               (searchResult at: #message) includesSubstring:
1✔
1156
                                                       '403 Forbidden' ])
1✔
1157
                                              ifTrue: [ "if the result is an 403 error we fake a new user"
1✔
1158
                                                      self glhModel
1✔
1159
                                                              add: (GLHUser new
1✔
1160
                                                                               username: anUsername;
1✔
1161
                                                                               name: anUsername;
1✔
1162
                                                                               yourself)
1✔
1163
                                                              unless: [ :nu :ou | nu username = ou username ] ]
1✔
1164
                                              ifFalse: [
1✔
1165
                                                      searchResult
1✔
1166
                                                              ifEmpty: [ "results can be empty thus we force a new user with the info we have "
1✔
1167
                                                                      self glhModel
1✔
1168
                                                                              add: (GLHUser new
1✔
1169
                                                                                               username: anUsername;
1✔
1170
                                                                                               name: anUsername;
1✔
1171
                                                                                               yourself)
1✔
1172
                                                                              unless: [ :nu :ou | nu username = ou username ] ]
1✔
1173
                                                              ifNotEmpty: [ "because we may already have the researched user, we look by ID in the model"
1✔
1174
                                                                      userId := searchResult first at: #id.
1✔
1175
                                                                      (self glhModel allWithType: GLHUser)
1✔
1176
                                                                              detect: [ :user | user id = userId ]
1✔
1177
                                                                              ifNone: [ self importUser: userId ] ] ] ].
1✔
1178

1✔
1179
        self userCatalogue addUser: resultUser withName: anUsername.
1✔
1180

1✔
1181
        ^ resultUser
1✔
1182
]
1✔
1183

1184
{ #category : #initialization }
1185
GitlabModelImporter >> initReader [
1✔
1186

1✔
1187
        generalReader := NeoJSONReader new.
1✔
1188
        self configureReaderForCommit: generalReader.
1✔
1189
        self configureReaderForGroup: generalReader.
1✔
1190
        self configureReaderForDiffs: generalReader.
1✔
1191
        self configureReaderForMergeRequest: generalReader
1✔
1192
]
1✔
1193

1194
{ #category : #initialization }
1195
GitlabModelImporter >> initialize [
1✔
1196

1✔
1197
        super initialize.
1✔
1198
        withCommitDiffs := true.
1✔
1199
        withInitialCommits := false.
1✔
1200
        withInitialMergeRequest := false.
1✔
1201

1✔
1202
        self withCommitsSince: 1 week.
1✔
1203

1✔
1204
        self initReader
1✔
1205
]
1✔
1206

1207
{ #category : #private }
1208
GitlabModelImporter >> isServerError: aString [
1✔
1209
        ^ aString = '{"message":"500 Internal Server Error"}'
1✔
1210
]
1✔
1211

1212
{ #category : #'import - projects' }
NEW
1213
GitlabModelImporter >> loadAllProjectsFromRepositorySoftware [
×
NEW
1214
        "heavy import that load all the active project inside the model. Only import the project entities"
×
NEW
1215
        |projects|
×
NEW
1216
        
×
NEW
1217
        projects := self repoApi projects. 
×
NEW
1218
]
×
1219

1220
{ #category : #'private - parsing' }
NEW
1221
GitlabModelImporter >> newParseCommitResult: result [
×
NEW
1222

×
NEW
1223
        generalReader  on: result readStream.
×
NEW
1224

×
NEW
1225
        ^ generalReader nextAs: GLHCommit
×
NEW
1226
]
×
1227

1228
{ #category : #'private - parsing' }
1229
GitlabModelImporter >> newParseDiffResult: result [
1✔
1230

1✔
1231
        generalReader on: result readStream.
1✔
1232
        ^ generalReader nextAs: #ArrayOfDiffs
1✔
1233
]
1✔
1234

1235
{ #category : #'private - parsing' }
NEW
1236
GitlabModelImporter >> parseArrayOfProject: arrayOfProjects [
×
NEW
1237

×
NEW
1238
        | reader |
×
NEW
1239
        reader := NeoJSONReader on: arrayOfProjects readStream.
×
NEW
1240
        reader
×
NEW
1241
                for: #ArrayOfProjects
×
NEW
1242
                customDo: [ :customMappting |
×
NEW
1243
                customMappting listOfElementSchema: GLHProject ].
×
NEW
1244
        reader for: GLHProject do: [ :mapping |
×
NEW
1245
                mapping mapInstVar: #name to: #name.
×
NEW
1246
                mapping mapInstVar: #description to: #description.
×
NEW
1247
                mapping mapInstVar: #id to: #id.
×
NEW
1248
                mapping mapInstVar: #archived to: #archived.
×
NEW
1249
                mapping mapInstVar: #web_url to: #html_url.
×
NEW
1250
                mapping mapInstVar: #topics to: #topics ].
×
NEW
1251
        ^ reader nextAs: #ArrayOfProjects
×
NEW
1252
]
×
1253

1254
{ #category : #'private - parsing' }
1255
GitlabModelImporter >> parseBranchesResult: result [
1✔
1256

1✔
1257
        | reader |
1✔
1258
        reader := NeoJSONReader on: result readStream.
1✔
1259
        reader mapInstVarsFor: GLHBranch.
1✔
1260
        reader
1✔
1261
                for: #ArrayOfBranch
1✔
1262
                customDo: [ :customMappting | 
1✔
1263
                customMappting listOfElementSchema: GLHBranch ].
1✔
1264
        ^ reader nextAs: #ArrayOfBranch
1✔
1265
]
1✔
1266

1267
{ #category : #'private - parsing' }
NEW
1268
GitlabModelImporter >> parseCommitResult: result [
×
NEW
1269

×
NEW
1270
        | reader |
×
NEW
1271
        reader := NeoJSONReader on: result readStream.
×
NEW
1272

×
NEW
1273
        reader for: GLHCommit do: [ :mapping |
×
NEW
1274
                mapping mapInstVars:
×
NEW
1275
                        #( id short_id title author_name author_email committer_name
×
NEW
1276
                           committer_email message web_url ).
×
NEW
1277
                (mapping mapInstVar: #authored_date) valueSchema: DateAndTime.
×
NEW
1278
                (mapping mapInstVar: #committed_date) valueSchema: DateAndTime.
×
NEW
1279
                (mapping mapInstVar: #created_at) valueSchema: DateAndTime.
×
NEW
1280
                (mapping mapInstVar: #parent_ids) valueSchema: #ArrayOfIds.
×
NEW
1281
                mapping
×
NEW
1282
                        mapProperty: 'stats'
×
NEW
1283
                        getter: [ :el | "Not used" ]
×
NEW
1284
                        setter: [ :commit :value |
×
NEW
1285
                                commit deletions: (value at: #deletions).
×
NEW
1286
                                commit additions: (value at: #additions) ] ].
×
NEW
1287

×
NEW
1288
        reader for: DateAndTime customDo: [ :mapping |
×
NEW
1289
                mapping decoder: [ :string | DateAndTime fromString: string ] ].
×
NEW
1290

×
NEW
1291
        reader
×
NEW
1292
                for: #ArrayOfIds
×
NEW
1293
                customDo: [ :mapping | mapping decoder: [ :string | string ] ].
×
NEW
1294

×
NEW
1295

×
NEW
1296
        ^ reader nextAs: GLHCommit
×
NEW
1297
]
×
1298

1299
{ #category : #'private - parsing' }
1300
GitlabModelImporter >> parseNoteJson: results [  
1✔
1301
    | reader |  
1✔
1302

1✔
1303
    "Créer un lecteur JSON"
1✔
1304
    reader := NeoJSONReader on: results readStream.    
1✔
1305

1✔
1306
    "Définir le mapping pour l'objet GLHNote"
1✔
1307
    reader for: GLHNote do: [ :mapping |  
1✔
1308
        mapping mapInstVars: #(id noteable_id attachment system confidential internal  
1✔
1309
                               noteable_iid resolvable imported imported_from  
1✔
1310
                               author body project_id noteable_type).  
1✔
1311

1✔
1312
        (mapping mapInstVar: #created_at) valueSchema: DateAndTime.  
1✔
1313
        (mapping mapInstVar: #updated_at) valueSchema: DateAndTime.  
1✔
1314
    ].    
1✔
1315

1✔
1316
    "Corriger la conversion des dates"
1✔
1317
    reader for: DateAndTime customDo: [ :mapping |  
1✔
1318
        mapping decoder: [ :string | DateAndTime readFrom: string readStream ] ].
1✔
1319

1✔
1320
        reader
1✔
1321
                for: #ArrayOfNote
1✔
1322
                customDo: [ :customMappting | 
1✔
1323
                customMappting listOfElementSchema: GLHNote ].
1✔
1324
         ^ reader nextAs: #ArrayOfNote
1✔
1325

1✔
1326
    "Retourner la Note"
1✔
1327
    "^ reader nextAs: GLHNote"
1✔
1328

1✔
1329

1✔
1330
]
1✔
1331

1332
{ #category : #'private - parsing' }
1333
GitlabModelImporter >> parseCommitsResult: result [
1✔
1334

1✔
1335
        | reader |
1✔
1336
        reader := NeoJSONReader on: result readStream.
1✔
1337

1✔
1338
          reader for: GLHCommit do: [ :mapping |
1✔
1339
                mapping mapInstVars:
1✔
1340
                        #( id short_id title author_name author_email committer_name
1✔
1341
                           committer_email message web_url ).
1✔
1342
                (mapping mapInstVar: #authored_date) valueSchema: DateAndTime.
1✔
1343
                (mapping mapInstVar: #committed_date) valueSchema: DateAndTime.
1✔
1344
                (mapping mapInstVar: #created_at) valueSchema: DateAndTime.
1✔
1345
                (mapping mapInstVar: #parent_ids) valueSchema: #ArrayOfIds.
1✔
1346
                mapping
1✔
1347
                        mapProperty: 'stats'
1✔
1348
                        getter: [ :el | "Not used" ]
1✔
1349
                        setter: [ :commit :value |
1✔
1350
                                commit deletions: (value at: #deletions).
1✔
1351
                                commit additions: (value at: #additions) ] ].
1✔
1352

1✔
1353
        reader for: DateAndTime customDo: [ :mapping |
1✔
1354
                mapping decoder: [ :string | DateAndTime fromString: string ] ].
1✔
1355

1✔
1356
        reader
1✔
1357
                for: #ArrayOfIds
1✔
1358
                customDo: [ :mapping | mapping decoder: [ :string | string ] ].
1✔
1359
  
1✔
1360
        reader
1✔
1361
                for: #ArrayOfCommit
1✔
1362
                customDo: [ :customMappting |
1✔
1363
                customMappting listOfElementSchema: GLHCommit ].
1✔
1364

1✔
1365
        ^ reader nextAs: #ArrayOfCommit
1✔
1366
]
1✔
1367

1368
{ #category : #private }
NEW
1369
GitlabModelImporter >> parseDiffResult: result [
×
NEW
1370

×
NEW
1371
        | reader |
×
NEW
1372
        self
×
NEW
1373
                deprecated: 'Use #newParseDiffResult: instead'
×
NEW
1374
                on: '28 June 2024'
×
NEW
1375
                in:
×
NEW
1376
                'Pharo-11.0.0+build.726.sha.aece1b5473acf3830a0e082c1bc3a15d4ff3522b (64 Bit)'.
×
NEW
1377
        reader := NeoJSONReader on: result readStream.
×
NEW
1378
        reader for: GLHDiff do: [ :mapping |
×
NEW
1379
                mapping mapInstVars:
×
NEW
1380
                        #( deleted_file new_file new_path old_path renamed_file ).
×
NEW
1381
                mapping mapInstVar: #diffString to: #diff ].
×
NEW
1382

×
NEW
1383
        reader
×
NEW
1384
                for: #ArrayOfDiffs
×
NEW
1385
                customDo: [ :customMappting |
×
NEW
1386
                customMappting listOfElementSchema: GLHDiff ].
×
NEW
1387
        ^ reader nextAs: #ArrayOfDiffs
×
NEW
1388
]
×
1389

1390
{ #category : #'private - parsing' }
NEW
1391
GitlabModelImporter >> parseFileTreeResult: aResult [
×
NEW
1392

×
NEW
1393
        | reader |
×
NEW
1394
        reader := NeoJSONReader on: aResult readStream.
×
NEW
1395
        reader mapInstVarsFor: GLHApiFile.
×
NEW
1396
        reader
×
NEW
1397
                for: #ArrayOfFile
×
NEW
1398
                customDo: [ :customMappting | 
×
NEW
1399
                customMappting listOfElementSchema: GLHApiFile ].
×
NEW
1400
        ^ reader nextAs: #ArrayOfFile
×
NEW
1401
]
×
1402

1403
{ #category : #'private - parsing' }
1404
GitlabModelImporter >> parseGroupResult: aResult [
1✔
1405

1✔
1406
        | reader |
1✔
1407

1✔
1408
        reader := NeoJSONReader on: aResult readStream.
1✔
1409
        reader for: GLHGroup do: [ :mapping |
1✔
1410
                mapping mapInstVars.
1✔
1411
                (mapping mapInstVar: #projects) valueSchema: #ArrayOfProjects ].
1✔
1412
        reader mapInstVarsFor: GLHProject.
1✔
1413
        reader
1✔
1414
                for: #ArrayOfProjects
1✔
1415
                customDo: [ :customMappting |
1✔
1416
                customMappting listOfElementSchema: GLHProject ].
1✔
1417
        ^ reader nextAs: GLHGroup
1✔
1418
]
1✔
1419

1420
{ #category : #'private - parsing' }
NEW
1421
GitlabModelImporter >> parseJobsResult: result ofProject: aProject [
×
NEW
1422

×
NEW
1423
        | reader |
×
NEW
1424
        reader := NeoJSONReader on: result readStream.
×
NEW
1425
        reader for: GLHJob do: [ :mapping |
×
NEW
1426
                mapping mapInstVars: #( id allow_failure web_url name ).
×
NEW
1427

×
NEW
1428
                mapping
×
NEW
1429
                        mapProperty: #user
×
NEW
1430
                        getter: [ :object | #ignore ]
×
NEW
1431
                        setter: [ :object :value |
×
NEW
1432
                        object user: (self importUser: (value at: #id)) ].
×
NEW
1433

×
NEW
1434
                mapping
×
NEW
1435
                        mapProperty: #commit
×
NEW
1436
                        getter: [ :object | #ignore ]
×
NEW
1437
                        setter: [ :object :value |
×
NEW
1438
                                value ifNotNil: [
×
NEW
1439
                                        object commit:
×
NEW
1440
                                                (self importCommit: (value at: #id) ofProject: aProject) ] ].
×
NEW
1441

×
NEW
1442
                mapping
×
NEW
1443
                        mapProperty: #duration
×
NEW
1444
                        getter: [ :object | #ignore ]
×
NEW
1445
                        setter: [ :object :value |
×
NEW
1446
                        value ifNotNil: [ object duration: value seconds ] ] ].
×
NEW
1447

×
NEW
1448
        reader
×
NEW
1449
                for: #ArrayOfGLHJob
×
NEW
1450
                customDo: [ :customMappting |
×
NEW
1451
                customMappting listOfElementSchema: GLHJob ].
×
NEW
1452
        ^ reader nextAs: #ArrayOfGLHJob
×
NEW
1453
]
×
1454

1455
{ #category : #'private - parsing' }
1456
GitlabModelImporter >> parseMergeRequestResult: result [
1✔
1457

1✔
1458
        generalReader on: result readStream.
1✔
1459
        ^ generalReader nextAs: #ArrayOfMergeRequest
1✔
1460
]
1✔
1461

1462
{ #category : #'private - parsing' }
NEW
1463
GitlabModelImporter >> parsePipelinesResult: result [
×
NEW
1464

×
NEW
1465
        | reader |
×
NEW
1466
        
×
NEW
1467
        (result includesSubstring: '{"message":"40' )ifTrue: [ ^ {  } ].
×
NEW
1468
        
×
NEW
1469
        reader := NeoJSONReader on: result readStream.
×
NEW
1470
        reader mapInstVarsFor: GLHPipeline.
×
NEW
1471
        reader for: GLHPipeline do: [ :mapping |
×
NEW
1472
                mapping
×
NEW
1473
                        mapProperty: #created_at
×
NEW
1474
                        getter: [ :object | #ignore ]
×
NEW
1475
                        setter: [ :object :value |
×
NEW
1476
                        object runDate: (DateAndTime fromString: value) ] ].
×
NEW
1477
        reader
×
NEW
1478
                for: #ArrayOfPipelines
×
NEW
1479
                customDo: [ :customMappting |
×
NEW
1480
                customMappting listOfElementSchema: GLHPipeline ].
×
NEW
1481
        ^ reader nextAs: #ArrayOfPipelines
×
NEW
1482
]
×
1483

1484
{ #category : #'private - parsing' }
1485
GitlabModelImporter >> parseProjectResult: aResult [ 
1✔
1486
                | reader |
1✔
1487
        reader := NeoJSONReader on: aResult readStream.
1✔
1488
        reader for: GLHProject do: [ :mapping |
1✔
1489
                mapping mapInstVars. ].
1✔
1490
"        reader mapInstVarsFor: GLHProject."
1✔
1491

1✔
1492
        ^ reader nextAs: GLHProject
1✔
1493
]
1✔
1494

1✔
1495
{ #category : #'private - parsing' }
1✔
1496
GitlabModelImporter >> parseSubGroupResult: aResult [
1✔
1497

1✔
1498
        | reader |
1✔
1499
        reader := NeoJSONReader on: aResult readStream.
1✔
1500
        self configureReaderForGroup: reader.
1✔
1501
        ^ reader nextAs: #ArrayOfGroups
1✔
1502
]
1✔
1503

1✔
1504
{ #category : #'private - parsing' }
1✔
1505
GitlabModelImporter >> parseUserResult: result [
1✔
1506

1✔
1507
        | reader |
1✔
1508
        reader := NeoJSONReader on: result readStream.
1✔
1509
        reader mapInstVarsFor: GLHUser.
1✔
1510
        ^ reader nextAs: GLHUser
1✔
1511
]
1✔
1512

1✔
1513
{ #category : #'private - parsing' }
1✔
1514
GitlabModelImporter >> parseUsersResult: result [
1✔
1515

1✔
1516
        | reader |
1✔
1517
        reader := NeoJSONReader on: result readStream.
1✔
1518

1✔
1519
        reader mapInstVarsFor: GLHUser.
1✔
1520

1✔
1521
        reader
1✔
1522
                for: #ArrayOfUser
1✔
1523
                customDo: [ :customMappting |
1✔
1524
                customMappting listOfElementSchema: GLHUser ].
1✔
1525

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

1✔
1529
{ #category : #'imports - pipelines' }
1✔
1530
GitlabModelImporter >> pipelinesOf: aProjectID [
1✔
1531

1✔
1532
        | result |
1✔
1533
        ('Search pipelines of: ' , aProjectID printString) recordInfo.
1✔
1534
        result := self repoApi pipelines getAllInProject: aProjectID.
1✔
1535
        result isString ifTrue: [ ^ self parsePipelinesResult: result ].
1✔
1536

1✔
1537
        ^ (result collect: [ :pipelinesJson |
1✔
1538
                           self parsePipelinesResult: pipelinesJson ]) flattened
1✔
1539
]
1✔
1540

1✔
1541
{ #category : #private }
1✔
1542
GitlabModelImporter >> selectEntityType: aType overAttribut: aSelector equalTo: value [
1✔
1543

1✔
1544
        ^ (self glhModel allWithType: aType)
1✔
1545
                select: [ :entity | (entity perform: aSelector) = value ]
1✔
1546
]
1✔
1547

1✔
1548
{ #category : #'import - groups' }
1✔
1549
GitlabModelImporter >> subGroupsOf: aGroupID [
1✔
1550

1✔
1551
        | results subgroups |
1✔
1552
        ('Search subgroup of: ' , aGroupID printString) recordInfo.
1✔
1553
        results := self repoApi groups subgroupsOf: aGroupID.
1✔
1554
        subgroups := (results collect: [ :subgroupsJson | self parseSubGroupResult: subgroupsJson ]) flattened.
1✔
1555
        
1✔
1556
        ^ subgroups
1✔
1557
]
1✔
1558

1✔
1559
{ #category : #accessing }
1✔
1560
GitlabModelImporter >> withInitialCommits: boolean [
1✔
1561
        withInitialCommits := boolean 
1✔
1562
]
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