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

moosetechnology / GitProjectHealth / 13991037947

21 Mar 2025 11:46AM UTC coverage: 69.927% (-0.5%) from 70.404%
13991037947

Pull #157

github

web-flow
Merge 422845cad into deee850ed
Pull Request #157: new Note entity

1195 of 2071 new or added lines in 18 files covered. (57.7%)

2 existing lines in 1 file now uncovered.

14061 of 20108 relevant lines covered (69.93%)

0.7 hits per line

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

53.95
/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 - commits' }
120
GitlabModelImporter >> completeImportedCommit: aCommit [
1✔
121

1✔
122
        ('completing commit: ' , aCommit short_id printString) recordInfo.
1✔
123
        self importCreatorOfCommit: aCommit.
1✔
124

1✔
125
        self withCommitDiffs ifTrue: [
1✔
126
                | diffs |
1✔
127
                aCommit diffs ifEmpty: [
1✔
128
                        diffs := self importDiffOfCommit: aCommit.
1✔
129
                        self glhModel addAll: diffs unless: self blockForDiffEquality ] ].
1✔
130

1✔
131
        ^ aCommit
1✔
132
]
1✔
133

134
{ #category : #'private - configure reader' }
135
GitlabModelImporter >> configureReaderForCommit: reader [
1✔
136

1✔
137
          reader for: GLHCommit do: [ :mapping |
1✔
138
                mapping mapInstVars:
1✔
139
                        #( id short_id title author_name author_email committer_name
1✔
140
                           committer_email message web_url ).
1✔
141
                (mapping mapInstVar: #authored_date) valueSchema: DateAndTime.
1✔
142
                (mapping mapInstVar: #committed_date) valueSchema: DateAndTime.
1✔
143
                (mapping mapInstVar: #created_at) valueSchema: DateAndTime.
1✔
144
                (mapping mapInstVar: #parent_ids) valueSchema: #ArrayOfIds.
1✔
145
                mapping
1✔
146
                        mapProperty: 'stats'
1✔
147
                        getter: [ :el | "Not used" ]
1✔
148
                        setter: [ :commit :value |
1✔
149
                                commit deletions: (value at: #deletions).
1✔
150
                                commit additions: (value at: #additions) ] ].
1✔
151

1✔
152
        reader for: DateAndTime customDo: [ :mapping |
1✔
153
                mapping decoder: [ :string | DateAndTime fromString: string ] ].
1✔
154

1✔
155
        reader
1✔
156
                for: #ArrayOfIds
1✔
157
                customDo: [ :mapping | mapping decoder: [ :string | string ] ].
1✔
158
  
1✔
159
        reader
1✔
160
                for: #ArrayOfCommit
1✔
161
                customDo: [ :customMappting |
1✔
162
                customMappting listOfElementSchema: GLHCommit ].
1✔
163

1✔
164
]
1✔
165

166
{ #category : #'private - configure reader' }
167
GitlabModelImporter >> configureReaderForDiffs: reader [
1✔
168

1✔
169
        reader for: GLHDiff do: [ :mapping |
1✔
170
                mapping mapInstVars:
1✔
171
                        #( deleted_file new_file new_path old_path renamed_file ).
1✔
172
                mapping mapInstVar: #diffString to: #diff ].
1✔
173

1✔
174
        reader
1✔
175
                for: #ArrayOfDiffs
1✔
176
                customDo: [ :customMappting |
1✔
177
                customMappting listOfElementSchema: GLHDiff ].
1✔
178
        ^ reader
1✔
179
]
1✔
180

181
{ #category : #'private - configure reader' }
182
GitlabModelImporter >> configureReaderForGroup: reader [
1✔
183

1✔
184
        reader for: GLHGroup do: [ :mapping |
1✔
185
                mapping mapInstVars.
1✔
186
                (mapping mapInstVar: #projects) valueSchema: #ArrayOfProjects ].
1✔
187
        reader mapInstVarsFor: GLHProject.
1✔
188
        reader
1✔
189
                for: #ArrayOfProjects
1✔
190
                customDo: [ :customMappting |
1✔
191
                customMappting listOfElementSchema: GLHProject ].
1✔
192
        reader
1✔
193
                for: #ArrayOfGroups
1✔
194
                customDo: [ :customMappting |
1✔
195
                customMappting listOfElementSchema: GLHGroup ]
1✔
196
]
1✔
197

198
{ #category : #'private - configure reader' }
199
GitlabModelImporter >> configureReaderForMergeRequest: reader [
1✔
200
        "declare quil y a un array a mapper"
1✔
201

1✔
202
        reader for: #ArrayOfMergeRequest customDo: [ :customMappting |
1✔
203
                customMappting listOfElementSchema: GLHMergeRequest ].
1✔
204

1✔
205
        "declare la liste des properties"
1✔
206
        reader for: GLHMergeRequest do: [ :mapping |
1✔
207
                mapping mapInstVars:
1✔
208
                        #( blocking_discussions_resolved changes_count description
1✔
209
                           detailed_merge_status discussion_locked downvotes draft first_deployed_to_production_at
1✔
210
                           force_remove_source_branch has_conflicts id iid labels latest_build_finished_at
1✔
211
                           latest_build_started_at merge_commit_sha merge_status
1✔
212
                           merge_when_pipeline_succeeds merged_at milestone project_id
1✔
213
                           reference references_full references_relative
1✔
214
                           references_short sha should_remove_source_branch
1✔
215
                           source_branch source_project_id squash squash_commit_sha
1✔
216
                           squash_on_merge state subscribed target_branch target_project_id
1✔
217
                           task_completion_status_completed_count
1✔
218
                           task_completion_status_count time_stats_human_time_estimate
1✔
219
                           time_stats_human_total_time_spent
1✔
220
                           time_stats_time_estimate time_stats_total_time_spent
1✔
221
                           title updated_at upvotes user_notes_count web_url work_in_progress ).
1✔
222
                (mapping mapInstVar: #created_at) valueSchema: DateAndTime.
1✔
223
                (mapping mapInstVar: #updated_at) valueSchema: DateAndTime.
1✔
224
                (mapping mapInstVar: #merged_at) valueSchema: DateAndTime.
1✔
225
                (mapping mapInstVar: #closed_at) valueSchema: DateAndTime.
1✔
226
                "(mapping mapInstVar: #assignee) valueSchema: GLHUser."
1✔
227
                mapping
1✔
228
                        mapProperty: #author
1✔
229
                        getter: [  ]
1✔
230
                        setter: [ :object :value |
1✔
231
                        object cacheAt: #authorID put: (value at: #id) ].
1✔
232
                mapping
1✔
233
                        mapProperty: #merge_user
1✔
234
                        getter: [  ]
1✔
235
                        setter: [ :object :value | 
1✔
236
                                value ifNotNil: [
1✔
237
                                        object cacheAt: #mergeUserID put: (value at: #id) ] ] ].
1✔
238

1✔
239
        "(mapping mapInstVar: #closed_by) valueSchema: GLHUser.
1✔
240
        (mapping mapInstVar: #mergeCommit) valueSchema: GLHCommit."
1✔
241
        "indique ce que doit faire le reader lorsqu'il parse une DateAndTime object"
1✔
242
        reader for: DateAndTime customDo: [ :mapping |
1✔
243
                mapping decoder: [ :string |
1✔
244
                        string ifNil: [ nil ] ifNotNil: [ DateAndTime fromString: string ] ] ]
1✔
245
]
1✔
246

247
{ #category : #private }
NEW
248
GitlabModelImporter >> convertApiFileAsFile: aAPIFile [
×
NEW
249

×
NEW
250
        aAPIFile type = 'tree' ifTrue: [ 
×
NEW
251
                ^ GLHFileDirectory new
×
NEW
252
                          name: aAPIFile name;
×
NEW
253
                          yourself ].
×
NEW
254
        ^ GLHFileBlob new
×
NEW
255
                  name: aAPIFile name;
×
NEW
256
                  yourself
×
NEW
257
]
×
258

259
{ #category : #private }
260
GitlabModelImporter >> detectEntityType: aType overAttribut: aSelector equalTo: value [
1✔
261

1✔
262
        ^ (self glhModel allWithType: aType) detect: [ :entity |
1✔
263
                  (entity perform: aSelector) = value ] ifNone: [ nil ]. 
1✔
264
]
1✔
265

266
{ #category : #accessing }
NEW
267
GitlabModelImporter >> glhApi [
×
NEW
268

×
NEW
269
        self
×
NEW
270
                deprecated: 'Use #repoApi instead'
×
NEW
271
                on: '7 October 2024'
×
NEW
272
                in:
×
NEW
273
                'Pharo-11.0.0+build.726.sha.aece1b5473acf3830a0e082c1bc3a15d4ff3522b (64 Bit)'.
×
NEW
274

×
NEW
275
        ^ repoApi
×
NEW
276
]
×
277

278
{ #category : #accessing }
NEW
279
GitlabModelImporter >> glhApi: anObject [
×
NEW
280

×
NEW
281
        self
×
NEW
282
                deprecated: 'Use #repoApi: instead'
×
NEW
283
                on: '7 October 2024'
×
NEW
284
                in:
×
NEW
285
                'Pharo-11.0.0+build.726.sha.aece1b5473acf3830a0e082c1bc3a15d4ff3522b (64 Bit)'.
×
NEW
286

×
NEW
287
        repoApi := anObject
×
NEW
288
]
×
289

290
{ #category : #accessing }
291
GitlabModelImporter >> glhModel [
1✔
292

1✔
293
        ^ glhModel
1✔
294
]
1✔
295

296
{ #category : #accessing }
297
GitlabModelImporter >> glhModel: anObject [
1✔
298

1✔
299
        glhModel := anObject
1✔
300
]
1✔
301

302
{ #category : #'import - users' }
NEW
303
GitlabModelImporter >> importActiveHumanUsers [
×
NEW
304

×
NEW
305
        | params result users |
×
NEW
306
        params := { 
×
NEW
307
                #humans -> 'true'.
×
NEW
308
                #active -> 'true'.
×
NEW
309
                #without_project_bots -> 'true'
×
NEW
310
        } asDictionary.
×
NEW
311
        result := self repoApi users allWithParams: params.
×
NEW
312
        users := (result collect: [ :usersJson | self parseUsersResult: usersJson ]) flattened.
×
NEW
313
        
×
NEW
314
        self glhModel
×
NEW
315
                                 addAll: users
×
NEW
316
                                 unless: self blockOnIdEquality.
×
NEW
317

×
NEW
318
        ^ users
×
NEW
319
]
×
320

321
{ #category : #'import - groups' }
NEW
322
GitlabModelImporter >> importAllGroups [
×
NEW
323

×
NEW
324
        | params results groups |
×
NEW
325
        
×
NEW
326
        params := { 
×
NEW
327
                        #top_level_only -> 'true'
×
NEW
328
        } asDictionary.
×
NEW
329
        results := self repoApi groups getAllWithParams: params.
×
NEW
330
        
×
NEW
331
        groups := (results collect: [ :groupsJson | generalReader
×
NEW
332
                                            on: groupsJson readStream;
×
NEW
333
                                            nextAs: #ArrayOfGroups. ]) flattened.
×
NEW
334
        ^ groups
×
NEW
335
]
×
336

337
{ #category : #'import - commits' }
NEW
338
GitlabModelImporter >> importAndLoadLatestsCommitsOfProject: aGLHProject [
×
NEW
339

×
NEW
340
        | commits completedProject |
×
NEW
341
        completedProject := self completeImportProject: aGLHProject.
×
NEW
342
        commits := self importLastestCommitsOfProject: completedProject.
×
NEW
343
        commits do: [ :commit | self completeImportedCommit: commit ].
×
NEW
344
        self chainsCommitsFrom: commits.
×
NEW
345
        ^ commits
×
NEW
346
]
×
347

348
{ #category : #'import - commits' }
NEW
349
GitlabModelImporter >> importCommit: aCommitID ofProject: aGLHProject [
×
NEW
350

×
NEW
351
        | result parsedResult |
×
NEW
352
        (self glhModel allWithType: GLHCommit) asOrderedCollection
×
NEW
353
                detect: [ :commit | commit id = aCommitID ]
×
NEW
354
                ifFound: [ :commit | ^ commit ].
×
NEW
355
        result := self repoApi commits get: aCommitID inProject: aGLHProject id.
×
NEW
356
        
×
NEW
357
        parsedResult := self parseCommitResult: result.
×
NEW
358
        
×
NEW
359
        self
×
NEW
360
                addCommits: { parsedResult }
×
NEW
361
                toRepository: aGLHProject repository.
×
NEW
362
        ^ parsedResult
×
NEW
363
]
×
364

365
{ #category : #'import - commits' }
366
GitlabModelImporter >> importCommitOfProject: anProject withId: anID [
1✔
367

1✔
368
        | commit result |
1✔
369
        anID ifNil: [ ^ nil ].
1✔
370

1✔
371
        ('looking for commit ' , anID printString , ' in project : '
1✔
372
         , anProject id printString) recordInfo.
1✔
373

1✔
374
        commit := (self
1✔
375
                           detectEntityType: GLHCommit
1✔
376
                           overAttribut: #id
1✔
377
                           equalTo: anID) ifNil: [
1✔
378
                          result := self repoApi commits get: anID inProject: anProject id.
1✔
379
                          commit := (self parseCommitsResult: '[' , result , ']')
1✔
380
                                            first.
1✔
381

1✔
382
                          self glhModel add: commit unless: self blockOnIdEquality.
1✔
383
                          commit repository: anProject repository.
1✔
384

1✔
385
                          commit ].
1✔
386

1✔
387
        self withCommitDiffs ifTrue: [ self importDiffOfCommit: commit ].
1✔
388

1✔
389
        ^ commit
1✔
390
]
1✔
391

392
{ #category : #'import - commits' }
NEW
393
GitlabModelImporter >> importCommits: aGLHProject [
×
NEW
394
        "limited to the last 20 commits"
×
NEW
395

×
NEW
396
        | results parsedResults params |
×
NEW
397
        params := { 
×
NEW
398
         #with_stats -> 'true'
×
NEW
399
        } asDictionary.
×
NEW
400
        results := self repoApi commits getByPage: 1 perPage: 20 inProject: aGLHProject id withParams: params.
×
NEW
401
        
×
NEW
402
        parsedResults := self parseCommitsResult: results.
×
NEW
403
        self glhModel addAll: parsedResults unless: self blockOnIdEquality.
×
NEW
404

×
NEW
405
        parsedResults do: [ :commit |
×
NEW
406
                commit repository: aGLHProject repository ].
×
NEW
407

×
NEW
408
        self withCommitDiffs ifTrue: [
×
NEW
409
                parsedResults do: [ :commit | self importDiffOfCommit: commit ] ].
×
NEW
410
        
×
NEW
411
        ^ parsedResults. 
×
NEW
412
]
×
413

414
{ #category : #'import - commits' }
NEW
415
GitlabModelImporter >> importCommitsFollowing: aCommit upToDays: aNumberOfDay [
×
NEW
416
        "import the 'n' commits of a project starting from an initial 'aCommit' commit. 
×
NEW
417
        Lazy import does not import the entities inside the model"
×
NEW
418

×
NEW
419
        | date |
×
NEW
420
        date := aCommit created_at asDateAndTime.
×
NEW
421

×
NEW
422
        ^ self
×
NEW
423
                  importCommitsOfBranch: aCommit branch
×
NEW
424
                  forRefName: aCommit branch name
×
NEW
425
                  since: date
×
NEW
426
                  until: (date + aNumberOfDay day)
×
NEW
427
]
×
428

429
{ #category : #commit }
NEW
430
GitlabModelImporter >> importCommitsOf: aGLHProject withStats: aBoolean until: toDate [
×
NEW
431

×
NEW
432
        | newlyFoundCommit page |
×
NEW
433
        
×
NEW
434
        self deprecated: [  ] .
×
NEW
435
        
×
NEW
436
        page := 0.
×
NEW
437
        newlyFoundCommit := { true }.
×
NEW
438
        [ newlyFoundCommit isNotEmpty ] whileTrue: [
×
NEW
439
                | results parsedResults existingCommits |
×
NEW
440
                page := page + 1.
×
NEW
441
                ('import commit page ' , page printString) recordInfo.
×
NEW
442
                results := self repoApi
×
NEW
443
                                   commitsOfProject: aGLHProject id
×
NEW
444
                                   forRefName: nil
×
NEW
445
                                   since: nil
×
NEW
446
                                   until: nil
×
NEW
447
                                   path: nil
×
NEW
448
                                   author: nil
×
NEW
449
                                   all: nil
×
NEW
450
                                   with_stats: aBoolean
×
NEW
451
                                   firstParent: nil
×
NEW
452
                                   order: nil
×
NEW
453
                                   trailers: nil
×
NEW
454
                                   perPage: 100
×
NEW
455
                                   page: page.
×
NEW
456
                parsedResults := self parseCommitsResult: results.
×
NEW
457
                existingCommits := aGLHProject mooseModel allWithType: GLHCommit.
×
NEW
458

×
NEW
459
                newlyFoundCommit := parsedResults reject: [ :commitParsed |
×
NEW
460
                                            (toDate isNil or: [
×
NEW
461
                                                     commitParsed committed_date
×
NEW
462
                                                     < toDate asDateAndTime ]) or: [
×
NEW
463
                                                    existingCommits anySatisfy: [ :existingCommit |
×
NEW
464
                                                            existingCommit id = commitParsed id ] ] ].
×
NEW
465
                aGLHProject mooseModel addAll: newlyFoundCommit.
×
NEW
466
                aGLHProject repository commits addAll: newlyFoundCommit ].
×
NEW
467

×
NEW
468

×
NEW
469
        self withCommitDiffs ifTrue: [
×
NEW
470
                aGLHProject repository commits do: [ :commit |
×
NEW
471
                        self importDiffOfCommit: commit ] ]
×
NEW
472
]
×
473

474
{ #category : #'import - commits' }
NEW
475
GitlabModelImporter >> importCommitsOfBranch: aGLHBranch [
×
NEW
476

×
NEW
477
        | commits |
×
NEW
478
        "        result := self glhApi
×
NEW
479
                          commitsOfProject: aGLHBranch repository project id
×
NEW
480
                          forRefName: aGLHBranch name."
×
NEW
481
        commits := self
×
NEW
482
                           importCommitsOfBranch: aGLHBranch
×
NEW
483
                           forRefName: aGLHBranch name
×
NEW
484
                           since: withCommitsSince.
×
NEW
485

×
NEW
486
        self chainsCommitsFrom: commits.
×
NEW
487

×
NEW
488
        commits do: [ :aCommit |
×
NEW
489
                aCommit repository: aGLHBranch repository.
×
NEW
490
                self completeImportedCommit: aCommit. 
×
NEW
491
                 ]
×
NEW
492
]
×
493

494
{ #category : #'import - commits' }
NEW
495
GitlabModelImporter >> importCommitsOfBranch: aGLHBranch forRefName: refName since: fromDate [
×
NEW
496

×
NEW
497
        ^ self
×
NEW
498
                  importCommitsOfBranch: aGLHBranch
×
NEW
499
                  forRefName: aGLHBranch name
×
NEW
500
                  since: fromDate
×
NEW
501
                  until: nil
×
NEW
502
]
×
503

504
{ #category : #'import - commits' }
NEW
505
GitlabModelImporter >> importCommitsOfBranch: aGLHBranch forRefName: refName since: fromDate until: toDate [
×
NEW
506

×
NEW
507
        | params result allCommits |
×
NEW
508
        params := { 
×
NEW
509
          #ref_name -> aGLHBranch name.
×
NEW
510
          #since ->  (fromDate ifNotNil: [ fromDate asDate asDateAndTime asString ] ifNil: [ '' ]).
×
NEW
511
          #until -> (toDate ifNotNil: [ toDate asDate asDateAndTime asString ] ifNil: [ '' ]). 
×
NEW
512

×
NEW
513
        } asDictionary.
×
NEW
514
        result := self repoApi commits getAllInProject: aGLHBranch repository project id withParams: params.
×
NEW
515
        
×
NEW
516
        allCommits := (result collect: [ :commitsJson | self parseCommitsResult: commitsJson ]) flattened.
×
NEW
517
        
×
NEW
518
        aGLHBranch commits
×
NEW
519
                        addAll: allCommits
×
NEW
520
                        unless: self blockOnIdEquality.
×
NEW
521

×
NEW
522
        self glhModel
×
NEW
523
                addAll: aGLHBranch commits
×
NEW
524
                unless: self blockOnIdEquality.
×
NEW
525

×
NEW
526
        ^ allCommits
×
NEW
527
]
×
528

529
{ #category : #'import - commits' }
NEW
530
GitlabModelImporter >> importCommitsOfBranch: aGLHBranch forRefName: refName until: toDate [
×
NEW
531

×
NEW
532
        ^ self
×
NEW
533
                  importCommitsOfBranch: aGLHBranch
×
NEW
534
                  forRefName: aGLHBranch name
×
NEW
535
                  since: nil
×
NEW
536
                  until: toDate
×
NEW
537
]
×
538

539
{ #category : #'import - commits' }
540
GitlabModelImporter >> importCommitsOfProject: aProject since: fromDate until: toDate [
1✔
541

1✔
542
        | params results allCommits |
1✔
543
        params := {
1✔
544
                          (#since
1✔
545
                           ->
1✔
546
                           (fromDate
1✔
547
                                    ifNotNil: [ fromDate asDate asDateAndTime asString ]
1✔
548
                                    ifNil: [ '' ])).
1✔
549
                          (#until
1✔
550
                           ->
1✔
551
                           (toDate
1✔
552
                                    ifNotNil: [ toDate asDate asDateAndTime asString ]
1✔
553
                                    ifNil: [ '' ])).
1✔
554
                          (#with_stats -> 'true').
1✔
555
                          (#all -> 'true') } asDictionary.
1✔
556
        results := self repoApi commits
1✔
557
                           getAllInProject: aProject id
1✔
558
                           withParams: params.
1✔
559

1✔
560
        allCommits := (results collect: [ :commitsJson |
1✔
561
                               self parseCommitsResult: commitsJson ]) flattened.
1✔
562

1✔
563
        allCommits:= aProject repository commits
1✔
564
                addAll: allCommits
1✔
565
                unless: self blockOnIdEquality.
1✔
566

1✔
567
        ^ self glhModel addAll: allCommits unless: self blockOnIdEquality
1✔
568
]
1✔
569

570
{ #category : #'import - projects' }
NEW
571
GitlabModelImporter >> importContributedProjectsOfUser: aGLHUser [
×
NEW
572

×
NEW
573
        | remaningProjects params results projects projectsIds |
×
NEW
574
        params := {
×
NEW
575
                          (#order_by -> 'last_activity_at').
×
NEW
576
                          (#simple -> 'true') } asDictionary.
×
NEW
577
        results := self repoApi projects
×
NEW
578
                           contributedProjectsOfUser: aGLHUser id
×
NEW
579
                           withParams: params.
×
NEW
580

×
NEW
581
        projectsIds := (results collect: [ :projectsJson |
×
NEW
582
                             (NeoJSONReader fromString: projectsJson) collect: [:projectJson | projectJson at: #id ] ]) flattened.
×
NEW
583
        
×
NEW
584
        projects := self importProjects: projectsIds.
×
NEW
585
        remaningProjects := self importProjects:
×
NEW
586
                                    ((projects collect: #id) difference:
×
NEW
587
                                             ((self userCatalogue atId: aGLHUser id) at:
×
NEW
588
                                                      #contributedProjects)).
×
NEW
589

×
NEW
590

×
NEW
591
        aGLHUser contributedProjects
×
NEW
592
                addAll: projects , remaningProjects
×
NEW
593
                unless: self blockOnIdEquality.
×
NEW
594

×
NEW
595
        self userCatalogue
×
NEW
596
                addUser: aGLHUser
×
NEW
597
                withProjects: (aGLHUser contributedProjects collect: #id).
×
NEW
598

×
NEW
599
        ^ projects
×
NEW
600
]
×
601

602
{ #category : #'import - commits' }
603
GitlabModelImporter >> importCreatorOfCommit: aCommit [
1✔
604

1✔
605
        aCommit commitCreator ifNil: [
1✔
606
                aCommit commitCreator:
1✔
607
                        (self importUserByUsername: aCommit author_name) ].
1✔
608
        self userCatalogue
1✔
609
                addUser: aCommit commitCreator
1✔
610
                withProject: aCommit repository project id.
1✔
611
        ^ aCommit commitCreator
1✔
612
]
1✔
613

614
{ #category : #'import - commits' }
615
GitlabModelImporter >> importDiffOfCommit: aCommit [
1✔
616

1✔
617
        | result diffsResult |
1✔
618
        aCommit diffs ifNotEmpty: [
1✔
619
                'Diff already importer: ' , aCommit short_id printString recordInfo.
1✔
620
                ^ aCommit diffs ].
1✔
621
        ('Import diff of commit: ' , aCommit short_id printString) recordInfo.
1✔
622

1✔
623
        result := self repoApi commits
1✔
624
                          diffOf: aCommit id
1✔
625
                          inProject: aCommit repository project id
1✔
626
                          uniDiff: true.
1✔
627

1✔
628
        (self isServerError: result) ifTrue: [ ^ {  } ].
1✔
629
        diffsResult := self newParseDiffResult: result.
1✔
630

1✔
631
        aCommit diffs addAll: diffsResult unless: self blockForDiffEquality.
1✔
632
        
1✔
633
        "changes are added into the model during the import"
1✔
634
        aCommit diffs do: [ :diff | self importDiffRangesForDiff: diff ].
1✔
635

1✔
636
        ^ aCommit diffs
1✔
637
]
1✔
638

639
{ #category : #'import - merge request' }
640
GitlabModelImporter >> importDiffOfMergeRequest: aMergeRequest [
1✔
641

1✔
642
        | result diffsResult |
1✔
643
        aMergeRequest diffs ifNotEmpty: [
1✔
644
                'Diff of already importer: '
1✔
645
                , aMergeRequest iid printString recordInfo.
1✔
646
                ^ aMergeRequest diffs ].
1✔
647
        ('Import diff commits of MR ' , aMergeRequest iid printString)
1✔
648
                recordInfo.
1✔
649
        result := self repoApi mergeRequests diffsOf: aMergeRequest iid inProject: aMergeRequest project_id.
1✔
650

1✔
651
        diffsResult := self newParseDiffResult: result.
1✔
652

1✔
653

1✔
654
        aMergeRequest diffs
1✔
655
                addAll: diffsResult
1✔
656
                unless: self blockForDiffEquality.
1✔
657
        self glhModel
1✔
658
                addAll: aMergeRequest diffs
1✔
659
                unless: self blockForDiffEquality.
1✔
660

1✔
661
        aMergeRequest diffs do: [ :diff | self importDiffRangesForDiff: diff ].
1✔
662

1✔
663
        ^ aMergeRequest diffs
1✔
664
]
1✔
665

666
{ #category : #'import - repositories' }
NEW
667
GitlabModelImporter >> importDirectoryFiles: aDirectoryFile OfBranch: aBranch [
×
NEW
668

×
NEW
669
        | result files apiFiles params |
×
NEW
670
        params := { 
×
NEW
671
                #ref -> aBranch name.
×
NEW
672
                #path -> (aDirectoryFile path , '/')
×
NEW
673
        } asDictionary.
×
NEW
674
        result := self repoApi repositories repositoryTreeOfProject: aBranch repository project id withParams: params.
×
NEW
675
                         " treeOfRepository: aBranch repository project id
×
NEW
676
                          ofBranch: aBranch name
×
NEW
677
                          andPath: aDirectoryFile path , '/'."
×
NEW
678
        apiFiles := (result collect: [ :treeJson | self parseFileTreeResult: treeJson ]) flattened.
×
NEW
679
        files := apiFiles collect: [ :apiFile |
×
NEW
680
                         self convertApiFileAsFile: apiFile ].
×
NEW
681
        
×
NEW
682
        files do: [ :file |
×
NEW
683
                self glhModel add: file.
×
NEW
684
                aDirectoryFile addFile: file ].
×
NEW
685
        
×
NEW
686
        files
×
NEW
687
                select: [ :file | file isKindOf: GLHFileDirectory ]
×
NEW
688
                thenCollect: [ :file |
×
NEW
689
                self importDirectoryFiles: file OfBranch: aBranch ]
×
NEW
690
]
×
691

692
{ #category : #'import - repositories' }
NEW
693
GitlabModelImporter >> importFilesOfBranch: aBranch [
×
NEW
694

×
NEW
695
        | result files apiFiles params |
×
NEW
696
        params := { 
×
NEW
697
                #ref -> aBranch name.
×
NEW
698
        } asDictionary.
×
NEW
699
        
×
NEW
700
        result := self repoApi repositories repositoryTreeOfProject: aBranch repository project id withParams: params.
×
NEW
701
        
×
NEW
702
                          "treeOfRepository: aBranch repository project id
×
NEW
703
                          ofBranch: aBranch name
×
NEW
704
                          andPath: nil."
×
NEW
705
        apiFiles := (result collect: [ :filesJson | self parseFileTreeResult: filesJson  ]) flattened.
×
NEW
706
        files := apiFiles collect: [ :apiFile | 
×
NEW
707
                         self convertApiFileAsFile: apiFile ].
×
NEW
708
        files do: [ :file | 
×
NEW
709
                self glhModel add: file.
×
NEW
710
                aBranch addFile: file ].
×
NEW
711
        files
×
NEW
712
                select: [ :file | file isKindOf: GLHFileDirectory ]
×
NEW
713
                thenCollect: [ :file | 
×
NEW
714
                self importDirectoryFiles: file OfBranch: aBranch ]
×
NEW
715
]
×
716

717
{ #category : #'import - groups' }
718
GitlabModelImporter >> importGroup: aGroupID [
1✔
719

1✔
720
        | result groupResult |
1✔
721
        ('Import group: ' , aGroupID printString) recordInfo.
1✔
722

1✔
723
        result := self repoApi groups get: aGroupID.
1✔
724
        
1✔
725
        "group: aGroupID."
1✔
726
        groupResult := self parseGroupResult: result.
1✔
727
        groupResult := self addGroupResultToModel: groupResult.
1✔
728

1✔
729
        groupResult projects do: [ :project |
1✔
730
                self completeImportProject: project ].
1✔
731

1✔
732
        (self subGroupsOf: aGroupID) do: [ :subGroup |
1✔
733
                
1✔
734
                groupResult subGroups
1✔
735
                        add: (self importGroup: subGroup id)
1✔
736
                        unless: self blockOnIdEquality ].
1✔
737
        ^ groupResult
1✔
738
]
1✔
739

740
{ #category : #'import - jobs' }
NEW
741
GitlabModelImporter >> importJobsOf: aPipeline [
×
NEW
742

×
NEW
743
        | jobs results |
×
NEW
744
        results := self repoApi jobs allForPipeline: aPipeline id inProject: aPipeline project id.
×
NEW
745
                          "jobsOfProject: aPipeline project id
×
NEW
746
                          ofPipelines: aPipeline id."
×
NEW
747
        jobs := (results collect: [ :jobsJson | self parseJobsResult: jobsJson ofProject: aPipeline project ]) flattened.
×
NEW
748
        jobs do: [ :job | aPipeline addJob: job ].
×
NEW
749
        self glhModel addAll: jobs.
×
NEW
750
        
×
NEW
751
        ^jobs
×
NEW
752

×
NEW
753
]
×
754

755
{ #category : #'import - commits' }
756
GitlabModelImporter >> importLastestCommitsOfProject: aGLHProject [
1✔
757
        "limited to the last 50 commits"
1✔
758

1✔
759
        | results parsedResults params |
1✔
760
        params := { 
1✔
761
                #with_stats -> 'true'.
1✔
762
                #all -> true
1✔
763
         } asDictionary.
1✔
764
        results := self repoApi commits getByPage: 1 perPage: 50 inProject: aGLHProject id withParams: params.
1✔
765

1✔
766
        parsedResults := self parseCommitsResult: results.
1✔
767
        parsedResults := self glhModel
1✔
768
                                 addAll: parsedResults
1✔
769
                                 unless: self blockOnIdEquality.
1✔
770

1✔
771
        aGLHProject repository commits
1✔
772
                addAll: parsedResults
1✔
773
                unless: self blockOnIdEquality.
1✔
774

1✔
775
        self withCommitDiffs ifTrue: [
1✔
776
                parsedResults do: [ :commit | self importDiffOfCommit: commit ] ].
1✔
777

1✔
778
        ^ parsedResults
1✔
779
]
1✔
780

781
{ #category : #'import - merge request' }
NEW
782
GitlabModelImporter >> importMergeRequestCommits: aGLPHEMergeRequest [
×
NEW
783

×
NEW
784
        | commits result |
×
NEW
785
        aGLPHEMergeRequest commits ifNotNil: [ ^ aGLPHEMergeRequest commits ].
×
NEW
786
        
×
NEW
787
        result := self repoApi mergeRequests commitsOf: aGLPHEMergeRequest iid inProject: aGLPHEMergeRequest project id.
×
NEW
788
        
×
NEW
789
        commits := (result collect: [ :commitsJson | self parseCommitsResult: commitsJson ]) flattened.
×
NEW
790
        commits := commits collect: [ :commit | self importCommit: commit id ofProject: aGLPHEMergeRequest project ].
×
NEW
791
        aGLPHEMergeRequest commits: commits.
×
NEW
792

×
NEW
793

×
NEW
794
        ^ commits
×
NEW
795
]
×
796

797
{ #category : #'import - merge request' }
798
GitlabModelImporter >> importMergeRequestMergeCommits: aGLPHEMergeRequest [
1✔
799

1✔
800
        | foundCommits |
1✔
801
        foundCommits := OrderedCollection new.
1✔
802

1✔
803
        ('Import commit sha of MR:  ' , aGLPHEMergeRequest iid printString)
1✔
804
                recordInfo.
1✔
805
        "the founds commits are added to the model during their respective import"
1✔
806
        aGLPHEMergeRequest mergeRequestCommit: ((self
1✔
807
                          importCommitOfProject: aGLPHEMergeRequest project
1✔
808
                          withId: aGLPHEMergeRequest sha) ifNotNil: [ :commit |
1✔
809
                         foundCommits add: commit ]).
1✔
810

1✔
811
        ('Import commit merge_commit_sha of MR:  '
1✔
812
         , aGLPHEMergeRequest iid printString) recordInfo.
1✔
813
        aGLPHEMergeRequest mergedCommit: ((self
1✔
814
                          importCommitOfProject: aGLPHEMergeRequest project
1✔
815
                          withId: aGLPHEMergeRequest merge_commit_sha) ifNotNil: [ :commit |
1✔
816
                         foundCommits add: commit ]).
1✔
817

1✔
818
        ('Import commit squash_commit_sha of MR:  '
1✔
819
         , aGLPHEMergeRequest iid printString) recordInfo.
1✔
820
        aGLPHEMergeRequest squashCommit: ((self
1✔
821
                          importCommitOfProject: aGLPHEMergeRequest project
1✔
822
                          withId: aGLPHEMergeRequest squash_commit_sha) ifNotNil: [ :commit |
1✔
823
                         foundCommits add: commit ]).
1✔
824

1✔
825

1✔
826
        self chainsCommitsFrom: foundCommits.
1✔
827
        ^ foundCommits
1✔
828
]
1✔
829

830
{ #category : #'import - merge request' }
831
GitlabModelImporter >> importMergeRequests: aGLHProject [
1✔
832

1✔
833
        | results parsedResults mrs |
1✔
834
        ('Import merge request of Project: ' , aGLHProject id printString)
1✔
835
                recordInfo.
1✔
836

1✔
837
        results := self repoApi mergeRequests allOfProject: aGLHProject id.
1✔
838
        parsedResults := (results collect: [ :projectsJson | self parseMergeRequestResult: projectsJson ]) flattened. 
1✔
839

1✔
840
        aGLHProject mergeRequests
1✔
841
                addAll: parsedResults
1✔
842
                unless: self blockOnIdEquality.
1✔
843

1✔
844
        mrs := self glhModel
1✔
845
                       addAll: aGLHProject mergeRequests
1✔
846
                       unless: self blockOnIdEquality.
1✔
847

1✔
848

1✔
849
        "gets it related commits"
1✔
850
        aGLHProject mergeRequests do: [ :mr |
1✔
851
                self importMergeRequestMergeCommits: mr ].
1✔
852

1✔
853

1✔
854
        self withCommitDiffs ifTrue: [
1✔
855
                aGLHProject mergeRequests do: [ :mr |
1✔
856
                        self importDiffOfMergeRequest: mr ] ].
1✔
857

1✔
858
        ^ mrs
1✔
859
]
1✔
860

861
{ #category : #'import - merge request' }
NEW
862
GitlabModelImporter >> importMergeRequests: aGLHProject since: fromDate until: toDate [
×
NEW
863

×
NEW
864
        | params result mergeRequests |
×
NEW
865
        ('import MR of Project ' , aGLHProject name) recordInfo.
×
NEW
866
        params := {
×
NEW
867
                          (#created_after
×
NEW
868
                           ->
×
NEW
869
                           (fromDate
×
NEW
870
                                    ifNotNil: [ fromDate asDateAndTime asString ]
×
NEW
871
                                    ifNil: [ '' ])).
×
NEW
872
                          (#created_before
×
NEW
873
                           ->
×
NEW
874
                           (toDate
×
NEW
875
                                    ifNotNil: [ toDate asDateAndTime asString ]
×
NEW
876
                                    ifNil: [ '' ])).
×
NEW
877
                          (#scope -> 'all') } asDictionary.
×
NEW
878

×
NEW
879
        result := self repoApi mergeRequests
×
NEW
880
                          allOfProject: aGLHProject id
×
NEW
881
                          withParams: params.
×
NEW
882
        mergeRequests := (result collect: [ :mergeRequestsJson |
×
NEW
883
                                  self parseMergeRequestResult: mergeRequestsJson ])
×
NEW
884
                                 flattened.
×
NEW
885

×
NEW
886
        aGLHProject mergeRequests
×
NEW
887
                addAll: mergeRequests
×
NEW
888
                unless: self blockOnIdEquality.
×
NEW
889

×
NEW
890
        "gets it related commits"
×
NEW
891
        aGLHProject mergeRequests do: [ :mr |
×
NEW
892
                self importMergeRequestMergeCommits: mr ].
×
NEW
893

×
NEW
894
        self withCommitDiffs ifTrue: [
×
NEW
895
                aGLHProject mergeRequests do: [ :mr |
×
NEW
896
                        self importDiffOfMergeRequest: mr ] ].
×
NEW
897

×
NEW
898
        self glhModel
×
NEW
899
                addAll: mergeRequests
×
NEW
900
                unless: (self blockEqualityOn: #iid).
×
NEW
901

×
NEW
902
        ^ mergeRequests
×
NEW
903
]
×
904

905
{ #category : #'import - merge request' }
NEW
906
GitlabModelImporter >> importMergeResquestApprovals: aGLPHEMergeRequest [
×
NEW
907

×
NEW
908
        | results parsedResult |
×
NEW
909
        (String streamContents: [ :str |
×
NEW
910
                 str << 'Check approvals of '.
×
NEW
911
                 aGLPHEMergeRequest printOn: str ]) recordInfo.
×
NEW
912
        results := self repoApi mergeRequests approvalsOf: aGLPHEMergeRequest iid inProject: aGLPHEMergeRequest project id.
×
NEW
913

×
NEW
914
        parsedResult := generalReader
×
NEW
915
                                on: results readStream;
×
NEW
916
                                next.
×
NEW
917

×
NEW
918
        (parsedResult at: #approved_by) do: [ :approvedUser |
×
NEW
919
                aGLPHEMergeRequest addApproved_by:
×
NEW
920
                        (self importUser: ((approvedUser at: #user) at: #id)) ].
×
NEW
921
        aGLPHEMergeRequest approved: (parsedResult at: #approved).
×
NEW
922
        ^ aGLPHEMergeRequest
×
NEW
923
]
×
924

925
{ #category : #'import - merge request' }
926
GitlabModelImporter >> importMergeResquestAuthor: aGLPHEMergeRequest [
1✔
927

1✔
928
        | authorID |
1✔
929
        aGLPHEMergeRequest author ifNotNil: [ ^ aGLPHEMergeRequest author ].
1✔
930
        authorID := aGLPHEMergeRequest cacheAt: #authorID ifAbsent: [
1✔
931
                            | result |
1✔
932
                            result := self repoApi mergeRequests
1✔
933
                                              get: aGLPHEMergeRequest iid
1✔
934
                                              inProject: aGLPHEMergeRequest project_id.
1✔
935

1✔
936
                            (generalReader
1✔
937
                                     on: result readStream;
1✔
938
                                     next) at: #author at: #id ].
1✔
939
        ^aGLPHEMergeRequest author: (self importUser: authorID)
1✔
940
]
1✔
941

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

1✔
945
        | authorID |
1✔
946
        aGLPHEMergeRequest merge_user ifNotNil: [
1✔
947
                ^ aGLPHEMergeRequest merge_user ].
1✔
948
        authorID := aGLPHEMergeRequest cacheAt: #mergeUserID ifAbsent: [
1✔
949
                            | result |
1✔
950
                            result := self repoApi mergeRequests
1✔
951
                                              get: aGLPHEMergeRequest iid
1✔
952
                                              inProject: aGLPHEMergeRequest project_id.
1✔
953
                            (generalReader
1✔
954
                                     on: result readStream;
1✔
955
                                     next)
1✔
956
                                    at: #merge_user
1✔
957
                                    ifPresent: [ :mergeUser |
1✔
958
                                    mergeUser ifNotNil: [ :mruser | mruser at: #id ] ] ].
1✔
959
        ^aGLPHEMergeRequest merge_user: (self importUser: authorID)
1✔
960
]
1✔
961

962
{ #category : #'import - notes' }
NEW
963
GitlabModelImporter >> importNotesfromMergeRequest: mergeRequest [
×
NEW
964
        | results notes |
×
NEW
965
        
×
NEW
966
        results := self repoApi notes allInMergeRequest: mergeRequest iid ofProject: mergeRequest project id.
×
NEW
967
        
×
NEW
968
        notes := results collect: [ :note | 
×
NEW
969
                self parseNoteJson: note ].
×
NEW
970
        "notes := self parseNoteJson: results."
×
NEW
971
        notes do: [ :tabNotes | tabNotes do: [ :note |
×
NEW
972
                        note author: (self importUser: (note author at: #id)).
×
NEW
973
                        note name: note id asString]. ].
×
NEW
974
        notes := notes flattened.
×
NEW
975
        notes := self glhModel addAll: notes unless: self blockOnIdEquality. 
×
NEW
976
        notes := mergeRequest note addAll: notes unless: self blockOnIdEquality. 
×
NEW
977
        ^notes
×
NEW
978
        
×
NEW
979
]
×
980

981
{ #category : #'import - notes' }
NEW
982
GitlabModelImporter >> importNotesfromMergeRequest: mergeRequest ofProject: projectId [
×
NEW
983

×
NEW
984
        self
×
NEW
985
                deprecated:
×
NEW
986
                'Use importNotesfromMergeRequest: instead of current one'
×
NEW
987
                on: '20 March 2025'
×
NEW
988
                in:
×
NEW
989
                'Pharo-12.0.0+SNAPSHOT.build.1567.sha.ee47bfdbe3db3390b952b3c0277d9d1f46162275 (64 Bit)'.
×
NEW
990

×
NEW
991
        ^ self importNotesfromMergeRequest: mergeRequest
×
NEW
992
]
×
993

994
{ #category : #'import - commits' }
NEW
995
GitlabModelImporter >> importParentCommitsOfCommit: aGLHCommit since: aDate [
×
NEW
996

×
NEW
997
        | parentsIds commits |
×
NEW
998
        commits := OrderedCollection new.
×
NEW
999
        aGLHCommit created_at asDateAndTime < aDate asDateAndTime ifTrue: [
×
NEW
1000
                 
×
NEW
1001
                ^ commits
×
NEW
1002
                          add: aGLHCommit;
×
NEW
1003
                          yourself ].
×
NEW
1004

×
NEW
1005
        parentsIds := aGLHCommit parent_ids.
×
NEW
1006

×
NEW
1007
        commits addAll: (parentsIds collect: [ :id |
×
NEW
1008
                         self
×
NEW
1009
                                 importCommitOfProject: aGLHCommit repository project
×
NEW
1010
                                 withId: id ]).
×
NEW
1011

×
NEW
1012

×
NEW
1013
        ^ (commits collect: [ :parentCommit |
×
NEW
1014
                   self importParentCommitsOfCommit: parentCommit since: aDate ])
×
NEW
1015
                  flatten
×
NEW
1016
]
×
1017

1018
{ #category : #'imports - pipelines' }
1019
GitlabModelImporter >> importPipelinesOfProject: aGLHProject [
1✔
1020

1✔
1021
        (self pipelinesOf: aGLHProject id) do: [ :pipeline |
1✔
1022
                self glhModel add: pipeline unless: self blockOnIdEquality .
1✔
1023
                aGLHProject pipelines add: pipeline unless: self blockOnIdEquality]
1✔
1024
]
1✔
1025

1026
{ #category : #'import - projects' }
1027
GitlabModelImporter >> importProject: aProjectID [
1✔
1028

1✔
1029
        | result projectResult |
1✔
1030
        ('Import project with id:  ' , aProjectID printString) recordInfo.
1✔
1031

1✔
1032
        (glhModel allWithType: GLHProject)
1✔
1033
                detect: [ :project | project id = aProjectID ]
1✔
1034
                ifFound: [ :project | ^ project ].
1✔
1035

1✔
1036
        result := self repoApi projects get: aProjectID.
1✔
1037
        projectResult := self parseProjectResult: result.
1✔
1038

1✔
1039
        ^ self completeImportProject: projectResult
1✔
1040
]
1✔
1041

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

×
NEW
1045
        | result projects |
×
NEW
1046
        ('import all Projects') recordInfo.
×
NEW
1047

×
NEW
1048

×
NEW
1049
        result := self repoApi projects all.
×
NEW
1050
        projects := (result collect: [ :projectsJson | self parseArrayOfProject: projectsJson ]) flattened.
×
NEW
1051
        
×
NEW
1052
        self glhModel addAll: projects unless: self blockOnIdEquality.
×
NEW
1053

×
NEW
1054
        ^ projects
×
NEW
1055
]
×
1056

1057
{ #category : #'import - projects' }
NEW
1058
GitlabModelImporter >> importProjects: aCollectionOfProjectID [
×
NEW
1059

×
NEW
1060

×
NEW
1061
        ^ aCollectionOfProjectID collect: [ :id | self importProject: id ]
×
NEW
1062
]
×
1063

1064
{ #category : #imports }
NEW
1065
GitlabModelImporter >> importProjectsSince: since [
×
NEW
1066
        "heavy import of all projects"
×
NEW
1067

×
NEW
1068
        "copy import from commits"
×
NEW
1069

×
NEW
1070
        | newlyFoundProjects page foundProject amount |
×
NEW
1071
        ('import all Projects since: ' , since printString) recordInfo.
×
NEW
1072

×
NEW
1073
        "number of projects per page"
×
NEW
1074
        amount := 100.
×
NEW
1075
        page := 0.
×
NEW
1076
        foundProject := OrderedCollection new.
×
NEW
1077
        newlyFoundProjects := { true }.
×
NEW
1078
        [ newlyFoundProjects isNotEmpty ] whileTrue: [
×
NEW
1079
                | results |
×
NEW
1080
                page := page + 1.
×
NEW
1081
                ('import projects page #' , page printString) recordInfo.
×
NEW
1082

×
NEW
1083
                results := self repoApi projects: amount since: since page: page.
×
NEW
1084

×
NEW
1085
                newlyFoundProjects := self glhModel
×
NEW
1086
                                              addAll: (self parseArrayOfProject: results)
×
NEW
1087
                                              unless: self blockOnIdEquality.
×
NEW
1088
                foundProject addAll: newlyFoundProjects ].
×
NEW
1089
]
×
1090

1091
{ #category : #'import - repositories' }
1092
GitlabModelImporter >> importRepository: aGLHRepository [
1✔
1093

1✔
1094
        | resultBranches branches |
1✔
1095
        [
1✔
1096
        ('import the repository of project ' , aGLHRepository project name)
1✔
1097
                recordInfo.
1✔
1098

1✔
1099
        resultBranches := self repoApi branches getAllFromProject:
1✔
1100
                                  aGLHRepository project id.
1✔
1101

1✔
1102
        branches := (resultBranches collect: [ :branchesJson |
1✔
1103
                             self parseBranchesResult: branchesJson ]) flattened.
1✔
1104

1✔
1105
        'import the branches of project ' recordInfo.
1✔
1106

1✔
1107
        branches := aGLHRepository branches
1✔
1108
                            addAll: branches
1✔
1109
                            unless: self blockOnNameEquality.
1✔
1110
        branches := self glhModel
1✔
1111
                            addAll: branches
1✔
1112
                            unless: self blockOnNameEquality.
1✔
1113

1✔
1114

1✔
1115
        self withFiles ifTrue: [
1✔
1116
                branches do: [ :branch | self importFilesOfBranch: branch ] ] ]
1✔
1117
                on: NeoJSONParseError
1✔
1118
                do: [
1✔
1119
                self inform: aGLHRepository project name , ' has no repository' ].
1✔
1120
        
1✔
1121
        withInitialCommits ifTrue: [
1✔
1122
                aGLHRepository branches do: [ :branch |
1✔
1123
                        self importCommitsOfBranch: branch ] ]
1✔
1124
]
1✔
1125

1126
{ #category : #'import - users' }
1127
GitlabModelImporter >> importUser: aUserID [
1✔
1128

1✔
1129
        | result userResult |
1✔
1130
        (self glhModel allWithType: GLHUser)
1✔
1131
                detect: [ :user | user id = aUserID ]
1✔
1132
                ifFound: [ :user | ^ user ].
1✔
1133
        ('Import user: ' , aUserID printString) recordInfo.
1✔
1134
        
1✔
1135
        result := self repoApi users get: aUserID.
1✔
1136
        userResult := self parseUserResult: result.
1✔
1137
        
1✔
1138
        userResult := self glhModel add: userResult unless: self blockOnIdEquality.
1✔
1139
        userCatalogue addUser: userResult.
1✔
1140
        ^ userResult 
1✔
1141
]
1✔
1142

1143
{ #category : #'import - users' }
1144
GitlabModelImporter >> importUserByUsername: anUsername [
1✔
1145

1✔
1146
        | dicUsername resultUser |
1✔
1147
        dicUsername := ((self glhModel allWithType: GLHUser) collect: [ :user |
1✔
1148
                                user username -> user ]) asSet asDictionary.
1✔
1149

1✔
1150
        dicUsername addAll: self userCatalogue collectUsernames.
1✔
1151

1✔
1152

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

1✔
1193
        self userCatalogue addUser: resultUser withName: anUsername.
1✔
1194

1✔
1195
        ^ resultUser
1✔
1196
]
1✔
1197

1198
{ #category : #initialization }
1199
GitlabModelImporter >> initReader [
1✔
1200

1✔
1201
        generalReader := NeoJSONReader new.
1✔
1202
        self configureReaderForCommit: generalReader.
1✔
1203
        self configureReaderForGroup: generalReader.
1✔
1204
        self configureReaderForDiffs: generalReader.
1✔
1205
        self configureReaderForMergeRequest: generalReader
1✔
1206
]
1✔
1207

1208
{ #category : #initialization }
1209
GitlabModelImporter >> initialize [
1✔
1210

1✔
1211
        super initialize.
1✔
1212
        withCommitDiffs := true.
1✔
1213
        withInitialCommits := false.
1✔
1214
        withInitialMergeRequest := false.
1✔
1215

1✔
1216
        self withCommitsSince: 1 week.
1✔
1217

1✔
1218
        self initReader
1✔
1219
]
1✔
1220

1221
{ #category : #private }
1222
GitlabModelImporter >> isServerError: aString [
1✔
1223
        ^ aString = '{"message":"500 Internal Server Error"}'
1✔
1224
]
1✔
1225

1226
{ #category : #'import - projects' }
NEW
1227
GitlabModelImporter >> loadAllProjectsFromRepositorySoftware [
×
NEW
1228
        "heavy import that load all the active project inside the model. Only import the project entities"
×
NEW
1229
        |projects|
×
NEW
1230
        
×
NEW
1231
        projects := self repoApi projects. 
×
NEW
1232
]
×
1233

1234
{ #category : #'private - parsing' }
NEW
1235
GitlabModelImporter >> newParseCommitResult: result [
×
NEW
1236

×
NEW
1237
        generalReader  on: result readStream.
×
NEW
1238

×
NEW
1239
        ^ generalReader nextAs: GLHCommit
×
NEW
1240
]
×
1241

1242
{ #category : #'private - parsing' }
1243
GitlabModelImporter >> newParseDiffResult: result [
1✔
1244

1✔
1245
        generalReader on: result readStream.
1✔
1246
        ^ generalReader nextAs: #ArrayOfDiffs
1✔
1247
]
1✔
1248

1249
{ #category : #'private - parsing' }
NEW
1250
GitlabModelImporter >> parseArrayOfProject: arrayOfProjects [
×
NEW
1251

×
NEW
1252
        | reader |
×
NEW
1253
        reader := NeoJSONReader on: arrayOfProjects readStream.
×
NEW
1254
        reader
×
NEW
1255
                for: #ArrayOfProjects
×
NEW
1256
                customDo: [ :customMappting |
×
NEW
1257
                customMappting listOfElementSchema: GLHProject ].
×
NEW
1258
        reader for: GLHProject do: [ :mapping |
×
NEW
1259
                mapping mapInstVar: #name to: #name.
×
NEW
1260
                mapping mapInstVar: #description to: #description.
×
NEW
1261
                mapping mapInstVar: #id to: #id.
×
NEW
1262
                mapping mapInstVar: #archived to: #archived.
×
NEW
1263
                mapping mapInstVar: #web_url to: #html_url.
×
NEW
1264
                mapping mapInstVar: #topics to: #topics ].
×
NEW
1265
        ^ reader nextAs: #ArrayOfProjects
×
NEW
1266
]
×
1267

1268
{ #category : #'private - parsing' }
1269
GitlabModelImporter >> parseBranchesResult: result [
1✔
1270

1✔
1271
        | reader |
1✔
1272
        reader := NeoJSONReader on: result readStream.
1✔
1273
        reader mapInstVarsFor: GLHBranch.
1✔
1274
        reader
1✔
1275
                for: #ArrayOfBranch
1✔
1276
                customDo: [ :customMappting | 
1✔
1277
                customMappting listOfElementSchema: GLHBranch ].
1✔
1278
        ^ reader nextAs: #ArrayOfBranch
1✔
1279
]
1✔
1280

1281
{ #category : #'private - parsing' }
NEW
1282
GitlabModelImporter >> parseCommitResult: result [
×
NEW
1283

×
NEW
1284
        | reader |
×
NEW
1285
        reader := NeoJSONReader on: result readStream.
×
NEW
1286

×
NEW
1287
        reader for: GLHCommit do: [ :mapping |
×
NEW
1288
                mapping mapInstVars:
×
NEW
1289
                        #( id short_id title author_name author_email committer_name
×
NEW
1290
                           committer_email message web_url ).
×
NEW
1291
                (mapping mapInstVar: #authored_date) valueSchema: DateAndTime.
×
NEW
1292
                (mapping mapInstVar: #committed_date) valueSchema: DateAndTime.
×
NEW
1293
                (mapping mapInstVar: #created_at) valueSchema: DateAndTime.
×
NEW
1294
                (mapping mapInstVar: #parent_ids) valueSchema: #ArrayOfIds.
×
NEW
1295
                mapping
×
NEW
1296
                        mapProperty: 'stats'
×
NEW
1297
                        getter: [ :el | "Not used" ]
×
NEW
1298
                        setter: [ :commit :value |
×
NEW
1299
                                commit deletions: (value at: #deletions).
×
NEW
1300
                                commit additions: (value at: #additions) ] ].
×
NEW
1301

×
NEW
1302
        reader for: DateAndTime customDo: [ :mapping |
×
NEW
1303
                mapping decoder: [ :string | DateAndTime fromString: string ] ].
×
NEW
1304

×
NEW
1305
        reader
×
NEW
1306
                for: #ArrayOfIds
×
NEW
1307
                customDo: [ :mapping | mapping decoder: [ :string | string ] ].
×
NEW
1308

×
NEW
1309

×
NEW
1310
        ^ reader nextAs: GLHCommit
×
NEW
1311
]
×
1312

1313
{ #category : #'private - parsing' }
1314
GitlabModelImporter >> parseCommitsResult: result [
1✔
1315

1✔
1316
        | reader |
1✔
1317
        reader := NeoJSONReader on: result readStream.
1✔
1318

1✔
1319
          reader for: GLHCommit do: [ :mapping |
1✔
1320
                mapping mapInstVars:
1✔
1321
                        #( id short_id title author_name author_email committer_name
1✔
1322
                           committer_email message web_url ).
1✔
1323
                (mapping mapInstVar: #authored_date) valueSchema: DateAndTime.
1✔
1324
                (mapping mapInstVar: #committed_date) valueSchema: DateAndTime.
1✔
1325
                (mapping mapInstVar: #created_at) valueSchema: DateAndTime.
1✔
1326
                (mapping mapInstVar: #parent_ids) valueSchema: #ArrayOfIds.
1✔
1327
                mapping
1✔
1328
                        mapProperty: 'stats'
1✔
1329
                        getter: [ :el | "Not used" ]
1✔
1330
                        setter: [ :commit :value |
1✔
1331
                                commit deletions: (value at: #deletions).
1✔
1332
                                commit additions: (value at: #additions) ] ].
1✔
1333

1✔
1334
        reader for: DateAndTime customDo: [ :mapping |
1✔
1335
                mapping decoder: [ :string | DateAndTime fromString: string ] ].
1✔
1336

1✔
1337
        reader
1✔
1338
                for: #ArrayOfIds
1✔
1339
                customDo: [ :mapping | mapping decoder: [ :string | string ] ].
1✔
1340
  
1✔
1341
        reader
1✔
1342
                for: #ArrayOfCommit
1✔
1343
                customDo: [ :customMappting |
1✔
1344
                customMappting listOfElementSchema: GLHCommit ].
1✔
1345

1✔
1346
        ^ reader nextAs: #ArrayOfCommit
1✔
1347
]
1✔
1348

1349
{ #category : #private }
NEW
1350
GitlabModelImporter >> parseDiffResult: result [
×
NEW
1351

×
NEW
1352
        | reader |
×
NEW
1353
        self
×
NEW
1354
                deprecated: 'Use #newParseDiffResult: instead'
×
NEW
1355
                on: '28 June 2024'
×
NEW
1356
                in:
×
NEW
1357
                'Pharo-11.0.0+build.726.sha.aece1b5473acf3830a0e082c1bc3a15d4ff3522b (64 Bit)'.
×
NEW
1358
        reader := NeoJSONReader on: result readStream.
×
NEW
1359
        reader for: GLHDiff do: [ :mapping |
×
NEW
1360
                mapping mapInstVars:
×
NEW
1361
                        #( deleted_file new_file new_path old_path renamed_file ).
×
NEW
1362
                mapping mapInstVar: #diffString to: #diff ].
×
NEW
1363

×
NEW
1364
        reader
×
NEW
1365
                for: #ArrayOfDiffs
×
NEW
1366
                customDo: [ :customMappting |
×
NEW
1367
                customMappting listOfElementSchema: GLHDiff ].
×
NEW
1368
        ^ reader nextAs: #ArrayOfDiffs
×
NEW
1369
]
×
1370

1371
{ #category : #'private - parsing' }
NEW
1372
GitlabModelImporter >> parseFileTreeResult: aResult [
×
NEW
1373

×
NEW
1374
        | reader |
×
NEW
1375
        reader := NeoJSONReader on: aResult readStream.
×
NEW
1376
        reader mapInstVarsFor: GLHApiFile.
×
NEW
1377
        reader
×
NEW
1378
                for: #ArrayOfFile
×
NEW
1379
                customDo: [ :customMappting | 
×
NEW
1380
                customMappting listOfElementSchema: GLHApiFile ].
×
NEW
1381
        ^ reader nextAs: #ArrayOfFile
×
NEW
1382
]
×
1383

1384
{ #category : #'private - parsing' }
1385
GitlabModelImporter >> parseGroupResult: aResult [
1✔
1386

1✔
1387
        | reader |
1✔
1388

1✔
1389
        reader := NeoJSONReader on: aResult readStream.
1✔
1390
        reader for: GLHGroup do: [ :mapping |
1✔
1391
                mapping mapInstVars.
1✔
1392
                (mapping mapInstVar: #projects) valueSchema: #ArrayOfProjects ].
1✔
1393
        reader mapInstVarsFor: GLHProject.
1✔
1394
        reader
1✔
1395
                for: #ArrayOfProjects
1✔
1396
                customDo: [ :customMappting |
1✔
1397
                customMappting listOfElementSchema: GLHProject ].
1✔
1398
        ^ reader nextAs: GLHGroup
1✔
1399
]
1✔
1400

1401
{ #category : #'private - parsing' }
NEW
1402
GitlabModelImporter >> parseJobsResult: result ofProject: aProject [
×
NEW
1403

×
NEW
1404
        | reader |
×
NEW
1405
        reader := NeoJSONReader on: result readStream.
×
NEW
1406
        reader for: GLHJob do: [ :mapping |
×
NEW
1407
                mapping mapInstVars: #( id allow_failure web_url name ).
×
NEW
1408

×
NEW
1409
                mapping
×
NEW
1410
                        mapProperty: #user
×
NEW
1411
                        getter: [ :object | #ignore ]
×
NEW
1412
                        setter: [ :object :value |
×
NEW
1413
                        object user: (self importUser: (value at: #id)) ].
×
NEW
1414

×
NEW
1415
                mapping
×
NEW
1416
                        mapProperty: #commit
×
NEW
1417
                        getter: [ :object | #ignore ]
×
NEW
1418
                        setter: [ :object :value |
×
NEW
1419
                                value ifNotNil: [
×
NEW
1420
                                        object commit:
×
NEW
1421
                                                (self importCommit: (value at: #id) ofProject: aProject) ] ].
×
NEW
1422

×
NEW
1423
                mapping
×
NEW
1424
                        mapProperty: #duration
×
NEW
1425
                        getter: [ :object | #ignore ]
×
NEW
1426
                        setter: [ :object :value |
×
NEW
1427
                        value ifNotNil: [ object duration: value seconds ] ] ].
×
NEW
1428

×
NEW
1429
        reader
×
NEW
1430
                for: #ArrayOfGLHJob
×
NEW
1431
                customDo: [ :customMappting |
×
NEW
1432
                customMappting listOfElementSchema: GLHJob ].
×
NEW
1433
        ^ reader nextAs: #ArrayOfGLHJob
×
NEW
1434
]
×
1435

1436
{ #category : #'private - parsing' }
1437
GitlabModelImporter >> parseMergeRequestResult: result [
1✔
1438

1✔
1439
        generalReader on: result readStream.
1✔
1440
        ^ generalReader nextAs: #ArrayOfMergeRequest
1✔
1441
]
1✔
1442

1443
{ #category : #'private - parsing' }
1444
GitlabModelImporter >> parseNoteJson: results [  
1✔
1445
    | reader |  
1✔
1446

1✔
1447
    "Créer un lecteur JSON"
1✔
1448
    reader := NeoJSONReader on: results readStream.    
1✔
1449

1✔
1450
    "Définir le mapping pour l'objet GLHNote"
1✔
1451
    reader for: GLHNote do: [ :mapping |  
1✔
1452
        mapping mapInstVars: #(id noteable_id attachment system confidential internal  
1✔
1453
                               noteable_iid resolvable imported imported_from  
1✔
1454
                               author body project_id noteable_type).  
1✔
1455

1✔
1456
        (mapping mapInstVar: #created_at) valueSchema: DateAndTime.  
1✔
1457
        (mapping mapInstVar: #updated_at) valueSchema: DateAndTime.  
1✔
1458
    ].    
1✔
1459

1✔
1460
    "Corriger la conversion des dates"
1✔
1461
    reader for: DateAndTime customDo: [ :mapping |  
1✔
1462
        mapping decoder: [ :string | DateAndTime readFrom: string readStream ] ].
1✔
1463

1✔
1464
        reader
1✔
1465
                for: #ArrayOfNote
1✔
1466
                customDo: [ :customMappting | 
1✔
1467
                customMappting listOfElementSchema: GLHNote ].
1✔
1468
         ^ reader nextAs: #ArrayOfNote
1✔
1469

1✔
1470
    "Retourner la Note"
1✔
1471
    "^ reader nextAs: GLHNote"
1✔
1472

1✔
1473

1✔
1474
]
1✔
1475

1476
{ #category : #'private - parsing' }
NEW
1477
GitlabModelImporter >> parsePipelinesResult: result [
×
NEW
1478

×
NEW
1479
        | reader |
×
NEW
1480
        
×
NEW
1481
        (result includesSubstring: '{"message":"40' )ifTrue: [ ^ {  } ].
×
NEW
1482
        
×
NEW
1483
        reader := NeoJSONReader on: result readStream.
×
NEW
1484
        reader mapInstVarsFor: GLHPipeline.
×
NEW
1485
        reader for: GLHPipeline do: [ :mapping |
×
NEW
1486
                mapping
×
NEW
1487
                        mapProperty: #created_at
×
NEW
1488
                        getter: [ :object | #ignore ]
×
NEW
1489
                        setter: [ :object :value |
×
NEW
1490
                        object runDate: (DateAndTime fromString: value) ] ].
×
NEW
1491
        reader
×
NEW
1492
                for: #ArrayOfPipelines
×
NEW
1493
                customDo: [ :customMappting |
×
NEW
1494
                customMappting listOfElementSchema: GLHPipeline ].
×
NEW
1495
        ^ reader nextAs: #ArrayOfPipelines
×
NEW
1496
]
×
1497

1498
{ #category : #'private - parsing' }
1499
GitlabModelImporter >> parseProjectResult: aResult [ 
1✔
1500
                | reader |
1✔
1501
        reader := NeoJSONReader on: aResult readStream.
1✔
1502
        reader for: GLHProject do: [ :mapping |
1✔
1503
                mapping mapInstVars. ].
1✔
1504
"        reader mapInstVarsFor: GLHProject."
1✔
1505

1✔
1506
        ^ reader nextAs: GLHProject
1✔
1507
]
1✔
1508

1✔
1509
{ #category : #'private - parsing' }
1✔
1510
GitlabModelImporter >> parseSubGroupResult: aResult [
1✔
1511

1✔
1512
        | reader |
1✔
1513
        reader := NeoJSONReader on: aResult readStream.
1✔
1514
        self configureReaderForGroup: reader.
1✔
1515
        ^ reader nextAs: #ArrayOfGroups
1✔
1516
]
1✔
1517

1✔
1518
{ #category : #'private - parsing' }
1✔
1519
GitlabModelImporter >> parseUserResult: result [
1✔
1520

1✔
1521
        | reader |
1✔
1522
        reader := NeoJSONReader on: result readStream.
1✔
1523
        reader mapInstVarsFor: GLHUser.
1✔
1524
        ^ reader nextAs: GLHUser
1✔
1525
]
1✔
1526

1✔
1527
{ #category : #'private - parsing' }
1✔
1528
GitlabModelImporter >> parseUsersResult: result [
1✔
1529

1✔
1530
        | reader |
1✔
1531
        reader := NeoJSONReader on: result readStream.
1✔
1532

1✔
1533
        reader mapInstVarsFor: GLHUser.
1✔
1534

1✔
1535
        reader
1✔
1536
                for: #ArrayOfUser
1✔
1537
                customDo: [ :customMappting |
1✔
1538
                customMappting listOfElementSchema: GLHUser ].
1✔
1539

1✔
1540
        ^ reader nextAs: #ArrayOfUser
1✔
1541
]
1✔
1542

1✔
1543
{ #category : #'imports - pipelines' }
1✔
1544
GitlabModelImporter >> pipelinesOf: aProjectID [
1✔
1545

1✔
1546
        | result |
1✔
1547
        ('Search pipelines of: ' , aProjectID printString) recordInfo.
1✔
1548
        result := self repoApi pipelines getAllInProject: aProjectID.
1✔
1549
        result isString ifTrue: [ ^ self parsePipelinesResult: result ].
1✔
1550

1✔
1551
        ^ (result collect: [ :pipelinesJson |
1✔
1552
                           self parsePipelinesResult: pipelinesJson ]) flattened
1✔
1553
]
1✔
1554

1✔
1555
{ #category : #private }
1✔
1556
GitlabModelImporter >> selectEntityType: aType overAttribut: aSelector equalTo: value [
1✔
1557

1✔
1558
        ^ (self glhModel allWithType: aType)
1✔
1559
                select: [ :entity | (entity perform: aSelector) = value ]
1✔
1560
]
1✔
1561

1✔
1562
{ #category : #'import - groups' }
1✔
1563
GitlabModelImporter >> subGroupsOf: aGroupID [
1✔
1564

1✔
1565
        | results subgroups |
1✔
1566
        ('Search subgroup of: ' , aGroupID printString) recordInfo.
1✔
1567
        results := self repoApi groups subgroupsOf: aGroupID.
1✔
1568
        subgroups := (results collect: [ :subgroupsJson | self parseSubGroupResult: subgroupsJson ]) flattened.
1✔
1569
        
1✔
1570
        ^ subgroups
1✔
1571
]
1✔
1572

1✔
1573
{ #category : #accessing }
1✔
1574
GitlabModelImporter >> withInitialCommits: boolean [
1✔
1575
        withInitialCommits := boolean 
1✔
1576
]
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