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

moosetechnology / GitProjectHealth / 13925120269

18 Mar 2025 02:01PM UTC coverage: 67.495% (+0.01%) from 67.481%
13925120269

Pull #157

github

web-flow
Merge 2f23ea585 into c1fd31de3
Pull Request #157: new Note entity

0 of 293 new or added lines in 6 files covered. (0.0%)

56 existing lines in 8 files now uncovered.

12874 of 19074 relevant lines covered (67.5%)

0.67 hits per line

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

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

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

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

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

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

39
{ #category : #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 - projects' }
62
GitlabModelImporter >> completeImportProject: aGLHProject [
1✔
63

1✔
64
        | importedProject |
1✔
65
        ('Complete import of project: ' , aGLHProject id printString)
1✔
66
                recordInfo.
1✔
67
        aGLHProject repository ifNotNil: [ ^ aGLHProject ].
1✔
68

1✔
69
        importedProject := self glhModel
1✔
70
                                   add: aGLHProject
1✔
71
                                   unless: self blockOnIdEquality.
1✔
72

1✔
73
        self importPipelinesOfProject: importedProject.
1✔
74

1✔
75
        "aGLHProject creator: (self importUser: aGLHProject creator_id)."
1✔
76

1✔
77
        (self importUser: importedProject creator_id) addCreatedProject:
1✔
78
                importedProject.
1✔
79

1✔
80

1✔
81
        importedProject repository: GLHRepository new.
1✔
82
        self glhModel add: importedProject repository.
1✔
83
        self importRepository: importedProject repository.
1✔
84

1✔
85
        ^ importedProject
1✔
86
]
1✔
87

88
{ #category : #'import - commits' }
89
GitlabModelImporter >> completeImportedCommit: aCommit [
1✔
90

1✔
91
        ('completing commit: ' , aCommit short_id printString) recordInfo.
1✔
92
        self importCreatorOfCommit: aCommit.
1✔
93

1✔
94
        self withCommitDiffs ifTrue: [
1✔
95
                | diffs |
1✔
96
                aCommit diffs ifEmpty: [
1✔
97
                        diffs := self importDiffOfCommit: aCommit.
1✔
98
                        self glhModel addAll: diffs unless: self blockForDiffEquality ] ].
1✔
99

1✔
100
        ^ aCommit
1✔
101
]
1✔
102

103
{ #category : #'private - configure reader' }
104
GitlabModelImporter >> configureReaderForCommit: reader [
1✔
105

1✔
106
          reader for: GLHCommit do: [ :mapping |
1✔
107
                mapping mapInstVars:
1✔
108
                        #( id short_id title author_name author_email committer_name
1✔
109
                           committer_email message web_url ).
1✔
110
                (mapping mapInstVar: #authored_date) valueSchema: DateAndTime.
1✔
111
                (mapping mapInstVar: #committed_date) valueSchema: DateAndTime.
1✔
112
                (mapping mapInstVar: #created_at) valueSchema: DateAndTime.
1✔
113
                (mapping mapInstVar: #parent_ids) valueSchema: #ArrayOfIds.
1✔
114
                mapping
1✔
115
                        mapProperty: 'stats'
1✔
116
                        getter: [ :el | "Not used" ]
1✔
117
                        setter: [ :commit :value |
1✔
118
                                commit deletions: (value at: #deletions).
1✔
119
                                commit additions: (value at: #additions) ] ].
1✔
120

1✔
121
        reader for: DateAndTime customDo: [ :mapping |
1✔
122
                mapping decoder: [ :string | DateAndTime fromString: string ] ].
1✔
123

1✔
124
        reader
1✔
125
                for: #ArrayOfIds
1✔
126
                customDo: [ :mapping | mapping decoder: [ :string | string ] ].
1✔
127
  
1✔
128
        reader
1✔
129
                for: #ArrayOfCommit
1✔
130
                customDo: [ :customMappting |
1✔
131
                customMappting listOfElementSchema: GLHCommit ].
1✔
132

1✔
133
]
1✔
134

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

1✔
138
        reader for: GLHDiff do: [ :mapping |
1✔
139
                mapping mapInstVars:
1✔
140
                        #( deleted_file new_file new_path old_path renamed_file ).
1✔
141
                mapping mapInstVar: #diffString to: #diff ].
1✔
142

1✔
143
        reader
1✔
144
                for: #ArrayOfDiffs
1✔
145
                customDo: [ :customMappting |
1✔
146
                customMappting listOfElementSchema: GLHDiff ].
1✔
147
        ^ reader
1✔
148
]
1✔
149

150
{ #category : #'private - configure reader' }
151
GitlabModelImporter >> configureReaderForGroup: reader [
1✔
152

1✔
153
        reader for: GLHGroup do: [ :mapping |
1✔
154
                mapping mapInstVars.
1✔
155
                (mapping mapInstVar: #projects) valueSchema: #ArrayOfProjects ].
1✔
156
        reader mapInstVarsFor: GLHProject.
1✔
157
        reader
1✔
158
                for: #ArrayOfProjects
1✔
159
                customDo: [ :customMappting |
1✔
160
                customMappting listOfElementSchema: GLHProject ].
1✔
161
        reader
1✔
162
                for: #ArrayOfGroups
1✔
163
                customDo: [ :customMappting |
1✔
164
                customMappting listOfElementSchema: GLHGroup ]
1✔
165
]
1✔
166

167
{ #category : #private }
168
GitlabModelImporter >> convertApiFileAsFile: aAPIFile [
×
169

×
170
        aAPIFile type = 'tree' ifTrue: [ 
×
171
                ^ GLHFileDirectory new
×
172
                          name: aAPIFile name;
×
173
                          yourself ].
×
174
        ^ GLHFileBlob new
×
175
                  name: aAPIFile name;
×
176
                  yourself
×
177
]
×
178

179
{ #category : #private }
180
GitlabModelImporter >> detectEntityType: aType overAttribut: aSelector equalTo: value [
1✔
181

1✔
182
        ^ (self glhModel allWithType: aType) detect: [ :entity |
1✔
183
                  (entity perform: aSelector) = value ] ifNone: [ nil ]. 
1✔
184
]
1✔
185

186
{ #category : #accessing }
187
GitlabModelImporter >> glhApi [
×
188

×
189
        self
×
190
                deprecated: 'Use #repoApi instead'
×
191
                on: '7 October 2024'
×
192
                in:
×
193
                'Pharo-11.0.0+build.726.sha.aece1b5473acf3830a0e082c1bc3a15d4ff3522b (64 Bit)'.
×
194

×
195
        ^ repoApi
×
196
]
×
197

198
{ #category : #accessing }
199
GitlabModelImporter >> glhApi: anObject [
×
200

×
201
        self
×
202
                deprecated: 'Use #repoApi: instead'
×
203
                on: '7 October 2024'
×
204
                in:
×
205
                'Pharo-11.0.0+build.726.sha.aece1b5473acf3830a0e082c1bc3a15d4ff3522b (64 Bit)'.
×
206

×
207
        repoApi := anObject
×
208
]
×
209

210
{ #category : #accessing }
211
GitlabModelImporter >> glhModel [
1✔
212

1✔
213
        ^ glhModel
1✔
214
]
1✔
215

216
{ #category : #accessing }
217
GitlabModelImporter >> glhModel: anObject [
1✔
218

1✔
219
        glhModel := anObject
1✔
220
]
1✔
221

222
{ #category : #'import - users' }
223
GitlabModelImporter >> importActiveHumanUsers [
×
224

×
225
        | params result users |
×
226
        params := { 
×
227
                #humans -> 'true'.
×
228
                #active -> 'true'.
×
229
                #without_project_bots -> 'true'
×
230
        } asDictionary.
×
231
        result := self repoApi users allWithParams: params.
×
232
        users := (result collect: [ :usersJson | self parseUsersResult: usersJson ]) flattened.
×
233
        
×
234
        self glhModel
×
235
                                 addAll: users
×
236
                                 unless: self blockOnIdEquality.
×
237

×
238
        ^ users
×
239
]
×
240

241
{ #category : #'import - groups' }
242
GitlabModelImporter >> importAllGroups [
×
243

×
244
        | params results groups |
×
245
        
×
246
        params := { 
×
247
                        #top_level_only -> 'true'
×
248
        } asDictionary.
×
249
        results := self repoApi groups getAllWithParams: params.
×
250
        
×
251
        groups := (results collect: [ :groupsJson | generalReader
×
252
                                            on: groupsJson readStream;
×
253
                                            nextAs: #ArrayOfGroups. ]) flattened.
×
254
        ^ groups
×
255
]
×
256

257
{ #category : #'import - commits' }
258
GitlabModelImporter >> importAndLoadLatestsCommitsOfProject: aGLHProject [
×
259

×
260
        | commits completedProject |
×
261
        completedProject := self completeImportProject: aGLHProject.
×
262
        commits := self importLastestCommitsOfProject: completedProject.
×
263
        commits do: [ :commit | self completeImportedCommit: commit ].
×
264
        self chainsCommitsFrom: commits.
×
265
        ^ commits
×
266
]
×
267

268
{ #category : #'import - commits' }
269
GitlabModelImporter >> importCommit: aCommitID ofProject: aGLHProject [
×
270

×
271
        | result parsedResult |
×
272
        (self glhModel allWithType: GLHCommit) asOrderedCollection
×
273
                detect: [ :commit | commit id = aCommitID ]
×
274
                ifFound: [ :commit | ^ commit ].
×
275
        result := self repoApi commits get: aCommitID inProject: aGLHProject id.
×
276
        
×
277
        parsedResult := self parseCommitResult: result.
×
278
        
×
279
        self
×
280
                addCommits: { parsedResult }
×
281
                toRepository: aGLHProject repository.
×
282
        ^ parsedResult
×
283
]
×
284

285
{ #category : #'import - commits' }
286
GitlabModelImporter >> importCommitOfProject: anProject withId: anID [
1✔
287

1✔
288
        | commit result |
1✔
289
        anID ifNil: [ ^ nil ].
1✔
290

1✔
291
        ('looking for commit ' , anID printString , ' in project : '
1✔
292
         , anProject id printString) recordInfo.
1✔
293

1✔
294
        commit := (self
1✔
295
                           detectEntityType: GLHCommit
1✔
296
                           overAttribut: #id
1✔
297
                           equalTo: anID) ifNil: [
1✔
298
                          result := self repoApi commits get: anID inProject: anProject id.
1✔
299
                          commit := (self parseCommitsResult: '[' , result , ']')
1✔
300
                                            first.
1✔
301

1✔
302
                          self glhModel add: commit unless: self blockOnIdEquality.
1✔
303
                          commit repository: anProject repository.
1✔
304

1✔
305
                          commit ].
1✔
306

1✔
307
        self withCommitDiffs ifTrue: [ self importDiffOfCommit: commit ].
1✔
308

1✔
309
        ^ commit
1✔
310
]
1✔
311

312
{ #category : #'import - commits' }
313
GitlabModelImporter >> importCommits: aGLHProject [
×
314
        "limited to the last 20 commits"
×
315

×
316
        | results parsedResults params |
×
317
        params := { 
×
318
         #with_stats -> 'true'
×
319
        } asDictionary.
×
320
        results := self repoApi commits getByPage: 1 perPage: 20 inProject: aGLHProject id withParams: params.
×
321
        
×
322
        parsedResults := self parseCommitsResult: results.
×
323
        self glhModel addAll: parsedResults unless: self blockOnIdEquality.
×
324

×
325
        parsedResults do: [ :commit |
×
326
                commit repository: aGLHProject repository ].
×
327

×
328
        self withCommitDiffs ifTrue: [
×
329
                parsedResults do: [ :commit | self importDiffOfCommit: commit ] ].
×
330
        
×
331
        ^ parsedResults. 
×
332
]
×
333

334
{ #category : #'import - commits' }
335
GitlabModelImporter >> importCommitsFollowing: aCommit upToDays: aNumberOfDay [
×
336
        "import the 'n' commits of a project starting from an initial 'aCommit' commit. 
×
337
        Lazy import does not import the entities inside the model"
×
338

×
339
        | date |
×
340
        date := aCommit created_at asDateAndTime.
×
341

×
342
        ^ self
×
343
                  importCommitsOfBranch: aCommit branch
×
344
                  forRefName: aCommit branch name
×
345
                  since: date
×
346
                  until: (date + aNumberOfDay day)
×
347
]
×
348

349
{ #category : #commit }
350
GitlabModelImporter >> importCommitsOf: aGLHProject withStats: aBoolean until: toDate [
×
351

×
352
        | newlyFoundCommit page |
×
353
        
×
354
        self deprecated: [  ] .
×
355
        
×
356
        page := 0.
×
357
        newlyFoundCommit := { true }.
×
358
        [ newlyFoundCommit isNotEmpty ] whileTrue: [
×
359
                | results parsedResults existingCommits |
×
360
                page := page + 1.
×
361
                ('import commit page ' , page printString) recordInfo.
×
362
                results := self repoApi
×
363
                                   commitsOfProject: aGLHProject id
×
364
                                   forRefName: nil
×
365
                                   since: nil
×
366
                                   until: nil
×
367
                                   path: nil
×
368
                                   author: nil
×
369
                                   all: nil
×
370
                                   with_stats: aBoolean
×
371
                                   firstParent: nil
×
372
                                   order: nil
×
373
                                   trailers: nil
×
374
                                   perPage: 100
×
375
                                   page: page.
×
376
                parsedResults := self parseCommitsResult: results.
×
377
                existingCommits := aGLHProject mooseModel allWithType: GLHCommit.
×
378

×
379
                newlyFoundCommit := parsedResults reject: [ :commitParsed |
×
380
                                            (toDate isNil or: [
×
381
                                                     commitParsed committed_date
×
382
                                                     < toDate asDateAndTime ]) or: [
×
383
                                                    existingCommits anySatisfy: [ :existingCommit |
×
384
                                                            existingCommit id = commitParsed id ] ] ].
×
385
                aGLHProject mooseModel addAll: newlyFoundCommit.
×
386
                aGLHProject repository commits addAll: newlyFoundCommit ].
×
387

×
388

×
389
        self withCommitDiffs ifTrue: [
×
390
                aGLHProject repository commits do: [ :commit |
×
391
                        self importDiffOfCommit: commit ] ]
×
392
]
×
393

394
{ #category : #'import - commits' }
395
GitlabModelImporter >> importCommitsOfBranch: aGLHBranch forRefName: refName since: fromDate [
×
396

×
397
        ^ self
×
398
                  importCommitsOfBranch: aGLHBranch
×
399
                  forRefName: aGLHBranch name
×
400
                  since: fromDate
×
401
                  until: nil
×
402
]
×
403

404
{ #category : #'import - commits' }
405
GitlabModelImporter >> importCommitsOfBranch: aGLHBranch forRefName: refName since: fromDate until: toDate [
×
406

×
407
        | params result allCommits |
×
408
        params := { 
×
409
          #ref_name -> aGLHBranch name.
×
410
          #since ->  (fromDate ifNotNil: [ fromDate asDate asDateAndTime asString ] ifNil: [ '' ]).
×
411
          #until -> (toDate ifNotNil: [ toDate asDate asDateAndTime asString ] ifNil: [ '' ]). 
×
412

×
413
        } asDictionary.
×
414
        result := self repoApi commits getAllInProject: aGLHBranch repository project id withParams: params.
×
415
        
×
416
        allCommits := (result collect: [ :commitsJson | self parseCommitsResult: commitsJson ]) flattened.
×
417
        
×
418
        aGLHBranch commits
×
419
                        addAll: allCommits
×
420
                        unless: self blockOnIdEquality.
×
421

×
422
        self glhModel
×
423
                addAll: aGLHBranch commits
×
424
                unless: self blockOnIdEquality.
×
425

×
426
        ^ allCommits
×
427
]
×
428

429
{ #category : #'import - commits' }
430
GitlabModelImporter >> importCommitsOfBranch: aGLHBranch forRefName: refName until: toDate [
×
431

×
432
        ^ self
×
433
                  importCommitsOfBranch: aGLHBranch
×
434
                  forRefName: aGLHBranch name
×
435
                  since: nil
×
436
                  until: toDate
×
437
]
×
438

439
{ #category : #'import - commits' }
440
GitlabModelImporter >> importCommitsOfProject: aProject since: fromDate until: toDate [
1✔
441

1✔
442
        | params results allCommits |
1✔
443
        params := {
1✔
444
                          (#since
1✔
445
                           ->
1✔
446
                           (fromDate
1✔
447
                                    ifNotNil: [ fromDate asDate asDateAndTime asString ]
1✔
448
                                    ifNil: [ '' ])).
1✔
449
                          (#until
1✔
450
                           ->
1✔
451
                           (toDate
1✔
452
                                    ifNotNil: [ toDate asDate asDateAndTime asString ]
1✔
453
                                    ifNil: [ '' ])).
1✔
454
                          (#with_stats -> 'true').
1✔
455
                          (#all -> 'true') } asDictionary.
1✔
456
        results := self repoApi commits
1✔
457
                           getAllInProject: aProject id
1✔
458
                           withParams: params.
1✔
459

1✔
460
        allCommits := (results collect: [ :commitsJson |
1✔
461
                               self parseCommitsResult: commitsJson ]) flattened.
1✔
462

1✔
463
        allCommits:= aProject repository commits
1✔
464
                addAll: allCommits
1✔
465
                unless: self blockOnIdEquality.
1✔
466

1✔
467
        ^ self glhModel addAll: allCommits unless: self blockOnIdEquality
1✔
468
]
1✔
469

470
{ #category : #'import - projects' }
471
GitlabModelImporter >> importContributedProjectsOfUser: aGLHUser [
×
472

×
473
        | remaningProjects params results projects projectsIds |
×
474
        params := {
×
475
                          (#order_by -> 'last_activity_at').
×
476
                          (#simple -> 'true') } asDictionary.
×
477
        results := self repoApi projects
×
478
                           contributedProjectsOfUser: aGLHUser id
×
479
                           withParams: params.
×
480

×
481
        projectsIds := (results collect: [ :projectsJson |
×
482
                             (NeoJSONReader fromString: projectsJson) collect: [:projectJson | projectJson at: #id ] ]) flattened.
×
483
        
×
484
        projects := self importProjects: projectsIds.
×
485
        remaningProjects := self importProjects:
×
486
                                    ((projects collect: #id) difference:
×
487
                                             ((self userCatalogue atId: aGLHUser id) at:
×
488
                                                      #contributedProjects)).
×
489

×
490

×
491
        aGLHUser contributedProjects
×
492
                addAll: projects , remaningProjects
×
493
                unless: self blockOnIdEquality.
×
494

×
495
        self userCatalogue
×
496
                addUser: aGLHUser
×
497
                withProjects: (aGLHUser contributedProjects collect: #id).
×
498

×
499
        ^ projects
×
500
]
×
501

502
{ #category : #'import - commits' }
503
GitlabModelImporter >> importCreatorOfCommit: aCommit [
1✔
504

1✔
505
        aCommit commitCreator ifNil: [
1✔
506
                aCommit commitCreator:
1✔
507
                        (self importUserByUsername: aCommit author_name) ].
1✔
508
        self userCatalogue
1✔
509
                addUser: aCommit commitCreator
1✔
510
                withProject: aCommit repository project id.
1✔
511
        ^ aCommit commitCreator
1✔
512
]
1✔
513

514
{ #category : #'import - commits' }
515
GitlabModelImporter >> importDiffOfCommit: aCommit [
1✔
516

1✔
517
        | result diffsResult |
1✔
518
        aCommit diffs ifNotEmpty: [
1✔
519
                'Diff already importer: ' , aCommit short_id printString recordInfo.
1✔
520
                ^ aCommit diffs ].
1✔
521
        ('Import diff of commit: ' , aCommit short_id printString) recordInfo.
1✔
522
        
1✔
523
        result := self repoApi commits diffOf: aCommit id inProject: aCommit repository project id  uniDiff: true.
1✔
524
        
1✔
525
        (self isServerError: result) ifTrue: [ ^ {  } ].
1✔
526
        diffsResult := self newParseDiffResult: result.
1✔
527

1✔
528
        ^ aCommit diffs addAll: diffsResult unless: self blockForDiffEquality.
1✔
529

1✔
530
]
1✔
531

532
{ #category : #'import - repositories' }
533
GitlabModelImporter >> importDirectoryFiles: aDirectoryFile OfBranch: aBranch [
×
534

×
535
        | result files apiFiles params |
×
536
        params := { 
×
537
                #ref -> aBranch name.
×
538
                #path -> (aDirectoryFile path , '/')
×
539
        } asDictionary.
×
540
        result := self repoApi repositories repositoryTreeOfProject: aBranch repository project id withParams: params.
×
541
                         " treeOfRepository: aBranch repository project id
×
542
                          ofBranch: aBranch name
×
543
                          andPath: aDirectoryFile path , '/'."
×
544
        apiFiles := (result collect: [ :treeJson | self parseFileTreeResult: treeJson ]) flattened.
×
545
        files := apiFiles collect: [ :apiFile |
×
546
                         self convertApiFileAsFile: apiFile ].
×
547
        
×
548
        files do: [ :file |
×
549
                self glhModel add: file.
×
550
                aDirectoryFile addFile: file ].
×
551
        
×
552
        files
×
553
                select: [ :file | file isKindOf: GLHFileDirectory ]
×
554
                thenCollect: [ :file |
×
555
                self importDirectoryFiles: file OfBranch: aBranch ]
×
556
]
×
557

558
{ #category : #'import - repositories' }
559
GitlabModelImporter >> importFilesOfBranch: aBranch [
×
560

×
561
        | result files apiFiles params |
×
562
        params := { 
×
563
                #ref -> aBranch name.
×
564
        } asDictionary.
×
565
        
×
566
        result := self repoApi repositories repositoryTreeOfProject: aBranch repository project id withParams: params.
×
567
        
×
568
                          "treeOfRepository: aBranch repository project id
×
569
                          ofBranch: aBranch name
×
570
                          andPath: nil."
×
571
        apiFiles := (result collect: [ :filesJson | self parseFileTreeResult: filesJson  ]) flattened.
×
572
        files := apiFiles collect: [ :apiFile | 
×
573
                         self convertApiFileAsFile: apiFile ].
×
574
        files do: [ :file | 
×
575
                self glhModel add: file.
×
576
                aBranch addFile: file ].
×
577
        files
×
578
                select: [ :file | file isKindOf: GLHFileDirectory ]
×
579
                thenCollect: [ :file | 
×
580
                self importDirectoryFiles: file OfBranch: aBranch ]
×
581
]
×
582

583
{ #category : #'import - groups' }
584
GitlabModelImporter >> importGroup: aGroupID [
1✔
585

1✔
586
        | result groupResult |
1✔
587
        ('Import group: ' , aGroupID printString) recordInfo.
1✔
588

1✔
589
        result := self repoApi groups get: aGroupID.
1✔
590
        
1✔
591
        "group: aGroupID."
1✔
592
        groupResult := self parseGroupResult: result.
1✔
593
        groupResult := self addGroupResultToModel: groupResult.
1✔
594

1✔
595
        groupResult projects do: [ :project |
1✔
596
                self completeImportProject: project ].
1✔
597

1✔
598
        (self subGroupsOf: aGroupID) do: [ :subGroup |
1✔
599
                
1✔
600
                groupResult subGroups
1✔
601
                        add: (self importGroup: subGroup id)
1✔
602
                        unless: self blockOnIdEquality ].
1✔
603
        ^ groupResult
1✔
604
]
1✔
605

606
{ #category : #'import - jobs' }
607
GitlabModelImporter >> importJobsOf: aPipeline [
×
608

×
609
        | jobs results |
×
610
        results := self repoApi jobs allForPipeline: aPipeline id inProject: aPipeline project id.
×
611
                          "jobsOfProject: aPipeline project id
×
612
                          ofPipelines: aPipeline id."
×
613
        jobs := (results collect: [ :jobsJson | self parseJobsResult: jobsJson ofProject: aPipeline project ]) flattened.
×
614
        jobs do: [ :job | aPipeline addJob: job ].
×
615
        self glhModel addAll: jobs.
×
616
        
×
617
        ^jobs
×
618

×
619
]
×
620

621
{ #category : #'import - commits' }
622
GitlabModelImporter >> importLastestCommitsOfProject: aGLHProject [
1✔
623
        "limited to the last 50 commits"
1✔
624

1✔
625
        | results parsedResults params |
1✔
626
        params := { 
1✔
627
                #with_stats -> 'true'.
1✔
628
                #all -> true
1✔
629
         } asDictionary.
1✔
630
        results := self repoApi commits getByPage: 1 perPage: 50 inProject: aGLHProject id withParams: params.
1✔
631

1✔
632
        parsedResults := self parseCommitsResult: results.
1✔
633
        parsedResults := self glhModel
1✔
634
                                 addAll: parsedResults
1✔
635
                                 unless: self blockOnIdEquality.
1✔
636

1✔
637
        aGLHProject repository commits
1✔
638
                addAll: parsedResults
1✔
639
                unless: self blockOnIdEquality.
1✔
640

1✔
641
        self withCommitDiffs ifTrue: [
1✔
642
                parsedResults do: [ :commit | self importDiffOfCommit: commit ] ].
1✔
643

1✔
644
        ^ parsedResults
1✔
645
]
1✔
646

647
{ #category : #'import - notes' }
NEW
648
GitlabModelImporter >> importNotesfromMergeRequest: mergeRequestIID ofProject: projectId [
×
NEW
649
        | results notes |
×
NEW
650
        
×
NEW
651
        results := self repoApi notes allInMergeRequest: mergeRequestIID ofProject: projectId.
×
NEW
652
        
×
NEW
653
        notes := results collect: [ :note | 
×
NEW
654
                self parseNoteJson: note ].
×
NEW
655
        "notes := self parseNoteJson: results."
×
NEW
656
        notes := notes collect: [ :tabNotes | tabNotes collect: [ :note |
×
NEW
657
                        note author: (self importUser: (note author at: #id)).]. ].
×
NEW
658
        
×
NEW
659
        notes do: [:note | self glhModel addAll: note unless: self blockOnIdEquality.]
×
NEW
660
        
×
NEW
661

×
NEW
662
        
×
NEW
663
]
×
664

665
{ #category : #'import - commits' }
666
GitlabModelImporter >> importParentCommitsOfCommit: aGLHCommit since: aDate [
×
667

×
668
        | parentsIds commits |
×
669
        commits := OrderedCollection new.
×
670
        aGLHCommit created_at asDateAndTime < aDate asDateAndTime ifTrue: [
×
671
                 
×
672
                ^ commits
×
673
                          add: aGLHCommit;
×
674
                          yourself ].
×
675

×
676
        parentsIds := aGLHCommit parent_ids.
×
677

×
678
        commits addAll: (parentsIds collect: [ :id |
×
679
                         self
×
680
                                 importCommitOfProject: aGLHCommit repository project
×
681
                                 withId: id ]).
×
682

×
683

×
684
        ^ (commits collect: [ :parentCommit |
×
685
                   self importParentCommitsOfCommit: parentCommit since: aDate ])
×
686
                  flatten
×
687
]
×
688

689
{ #category : #'imports - pipelines' }
690
GitlabModelImporter >> importPipelinesOfProject: aGLHProject [
1✔
691

1✔
692
        (self pipelinesOf: aGLHProject id) do: [ :pipeline |
1✔
693
                self glhModel add: pipeline unless: self blockOnIdEquality .
1✔
694
                aGLHProject pipelines add: pipeline unless: self blockOnIdEquality]
1✔
695
]
1✔
696

697
{ #category : #'import - projects' }
698
GitlabModelImporter >> importProject: aProjectID [
×
699

×
700
        | result projectResult |
×
701
        ('Import project with id: ' , aProjectID printString) recordInfo.
×
702

×
703
        result := self repoApi projects get: aProjectID.
×
704
        projectResult := self parseProjectResult: result.
×
705

×
706
        ^ self completeImportProject: projectResult
×
707
]
×
708

709
{ #category : #'import - projects' }
710
GitlabModelImporter >> importProjects [
×
711

×
712
        | result projects |
×
713
        ('import all Projects') recordInfo.
×
714

×
715

×
716
        result := self repoApi projects all.
×
717
        projects := (result collect: [ :projectsJson | self parseArrayOfProject: projectsJson ]) flattened.
×
718
        
×
719
        self glhModel addAll: projects unless: self blockOnIdEquality.
×
720

×
721
        ^ projects
×
722
]
×
723

724
{ #category : #'import - projects' }
725
GitlabModelImporter >> importProjects: aCollectionOfProjectID [
×
726

×
727

×
728
        ^ aCollectionOfProjectID collect: [ :id | self importProject: id ]
×
729
]
×
730

731
{ #category : #imports }
732
GitlabModelImporter >> importProjectsSince: since [
×
733
        "heavy import of all projects"
×
734

×
735
        "copy import from commits"
×
736

×
737
        | newlyFoundProjects page foundProject amount |
×
738
        ('import all Projects since: ' , since printString) recordInfo.
×
739

×
740
        "number of projects per page"
×
741
        amount := 100.
×
742
        page := 0.
×
743
        foundProject := OrderedCollection new.
×
744
        newlyFoundProjects := { true }.
×
745
        [ newlyFoundProjects isNotEmpty ] whileTrue: [
×
746
                | results |
×
747
                page := page + 1.
×
748
                ('import projects page #' , page printString) recordInfo.
×
749

×
750
                results := self repoApi projects: amount since: since page: page.
×
751

×
752
                newlyFoundProjects := self glhModel
×
753
                                              addAll: (self parseArrayOfProject: results)
×
754
                                              unless: self blockOnIdEquality.
×
755
                foundProject addAll: newlyFoundProjects ].
×
756
]
×
757

758
{ #category : #'import - repositories' }
759
GitlabModelImporter >> importRepository: aGLHRepository [
1✔
760

1✔
761
        | resultBranches branches |
1✔
762
        [
1✔
763
        ('import the repository of project ' , aGLHRepository project name)
1✔
764
                recordInfo.
1✔
765

1✔
766
        resultBranches := self repoApi branches getAllFromProject: aGLHRepository project id.
1✔
767
        
1✔
768
        branches := (resultBranches collect: [ :branchesJson | self parseBranchesResult: branchesJson ]) flattened.
1✔
769

1✔
770
        'import the branches of project ' recordInfo.
1✔
771

1✔
772
        branches := aGLHRepository branches
1✔
773
                            addAll: branches
1✔
774
                            unless: self blockOnNameEquality.
1✔
775
        branches := self glhModel
1✔
776
                            addAll: branches
1✔
777
                            unless: self blockOnNameEquality.
1✔
778

1✔
779

1✔
780
        self withFiles ifTrue: [
1✔
781
                branches do: [ :branch | self importFilesOfBranch: branch ] ] ]
1✔
782
                on: NeoJSONParseError
1✔
783
                do: [
1✔
784
                self inform: aGLHRepository project name , ' has no repository' ]
1✔
785
]
1✔
786

787
{ #category : #'import - users' }
788
GitlabModelImporter >> importUser: aUserID [
1✔
789

1✔
790
        | result userResult |
1✔
791
        (self glhModel allWithType: GLHUser)
1✔
792
                detect: [ :user | user id = aUserID ]
1✔
793
                ifFound: [ :user | ^ user ].
1✔
794
        ('Import user: ' , aUserID printString) recordInfo.
1✔
795
        
1✔
796
        result := self repoApi users get: aUserID.
1✔
797
        userResult := self parseUserResult: result.
1✔
798
        
1✔
799
        userResult := self glhModel add: userResult unless: self blockOnIdEquality.
1✔
800
        userCatalogue addUser: userResult.
1✔
801
        ^ userResult 
1✔
802
]
1✔
803

804
{ #category : #'import - users' }
805
GitlabModelImporter >> importUserByUsername: anUsername [
1✔
806

1✔
807
        | dicUsername resultUser |
1✔
808
        dicUsername := ((self glhModel allWithType: GLHUser) collect: [ :user |
1✔
809
                                user username -> user ]) asSet asDictionary.
1✔
810

1✔
811
        dicUsername addAll: self userCatalogue collectUsernames.
1✔
812

1✔
813

1✔
814
        resultUser := dicUsername
1✔
815
                              at: anUsername
1✔
816
                              ifAbsent: [ "thus we have to import this new user"
1✔
817
                                      | result userId searchResult params |
1✔
818
                                      ('Import user with username: '
1✔
819
                                       , anUsername printString) recordInfo.
1✔
820
                                      params := { (#search -> anUsername) } asDictionary.
1✔
821
                                      result := self repoApi users allWithParams: params.
1✔
822
                                                        
1✔
823
                                                         "when result is an error"
1✔
824
                                                         (result isString) ifTrue: [ result := { result } ].
1✔
825
                                                        
1✔
826
                                      searchResult := result ifEmpty: [ result ] ifNotEmpty: [(result collect: [ :usersJson |
1✔
827
                                                               NeoJSONReader fromString: usersJson ]) first].
1✔
828
                                                         
1✔
829
                                      (searchResult class = Dictionary and: [
1✔
830
                                               (searchResult at: #message) includesSubstring:
1✔
831
                                                       '403 Forbidden' ])
1✔
832
                                              ifTrue: [ "if the result is an 403 error we fake a new user"
1✔
833
                                                      self glhModel
1✔
834
                                                              add: (GLHUser new
1✔
835
                                                                               username: anUsername;
1✔
836
                                                                               name: anUsername;
1✔
837
                                                                               yourself)
1✔
838
                                                              unless: [ :nu :ou | nu username = ou username ] ]
1✔
839
                                              ifFalse: [
1✔
840
                                                      searchResult
1✔
841
                                                              ifEmpty: [ "results can be empty thus we force a new user with the info we have "
1✔
842
                                                                      self glhModel
1✔
843
                                                                              add: (GLHUser new
1✔
844
                                                                                               username: anUsername;
1✔
845
                                                                                               name: anUsername;
1✔
846
                                                                                               yourself)
1✔
847
                                                                              unless: [ :nu :ou | nu username = ou username ] ]
1✔
848
                                                              ifNotEmpty: [ "because we may already have the researched user, we look by ID in the model"
1✔
849
                                                                      userId := searchResult first at: #id.
1✔
850
                                                                      (self glhModel allWithType: GLHUser)
1✔
851
                                                                              detect: [ :user | user id = userId ]
1✔
852
                                                                              ifNone: [ self importUser: userId ] ] ] ].
1✔
853

1✔
854
        self userCatalogue addUser: resultUser withName: anUsername.
1✔
855

1✔
856
        ^ resultUser
1✔
857
]
1✔
858

859
{ #category : #initialization }
860
GitlabModelImporter >> initReader [
1✔
861

1✔
862
        generalReader := NeoJSONReader new.
1✔
863
        self configureReaderForCommit: generalReader.
1✔
864
        self configureReaderForGroup: generalReader.
1✔
865
        self configureReaderForDiffs: generalReader. 
1✔
866
]
1✔
867

868
{ #category : #initialization }
869
GitlabModelImporter >> initialize [
1✔
870

1✔
871
        super initialize.
1✔
872
        withCommitDiffs := false.
1✔
873
        withInitialCommits := false.
1✔
874
        withInitialMergeRequest := false.
1✔
875

1✔
876
        withCommitsSince := (Date today - 1 week) asDateAndTime.
1✔
877

1✔
878
        self initReader.
1✔
879

1✔
880
]
1✔
881

882
{ #category : #private }
883
GitlabModelImporter >> isServerError: aString [
1✔
884
        ^ aString = '{"message":"500 Internal Server Error"}'
1✔
885
]
1✔
886

887
{ #category : #'import - projects' }
888
GitlabModelImporter >> loadAllProjectsFromRepositorySoftware [
×
889
        "heavy import that load all the active project inside the model. Only import the project entities"
×
890
        |projects|
×
891
        
×
892
        projects := self repoApi projects. 
×
893
]
×
894

895
{ #category : #'private - parsing' }
896
GitlabModelImporter >> newParseCommitResult: result [
×
897

×
898
        generalReader  on: result readStream.
×
899

×
900
        ^ generalReader nextAs: GLHCommit
×
901
]
×
902

903
{ #category : #'private - parsing' }
904
GitlabModelImporter >> newParseDiffResult: result [
1✔
905

1✔
906
        generalReader on: result readStream.
1✔
907
        ^ generalReader nextAs: #ArrayOfDiffs
1✔
908
]
1✔
909

910
{ #category : #'private - parsing' }
911
GitlabModelImporter >> parseArrayOfProject: arrayOfProjects [
×
912

×
913
        | reader |
×
914
        reader := NeoJSONReader on: arrayOfProjects readStream.
×
915
        reader
×
916
                for: #ArrayOfProjects
×
917
                customDo: [ :customMappting |
×
918
                customMappting listOfElementSchema: GLHProject ].
×
919
        reader for: GLHProject do: [ :mapping |
×
920
                mapping mapInstVar: #name to: #name.
×
921
                mapping mapInstVar: #description to: #description.
×
922
                mapping mapInstVar: #id to: #id.
×
923
                mapping mapInstVar: #archived to: #archived.
×
924
                mapping mapInstVar: #web_url to: #html_url.
×
925
                mapping mapInstVar: #topics to: #topics ].
×
926
        ^ reader nextAs: #ArrayOfProjects
×
927
]
×
928

929
{ #category : #'private - parsing' }
930
GitlabModelImporter >> parseBranchesResult: result [
1✔
931

1✔
932
        | reader |
1✔
933
        reader := NeoJSONReader on: result readStream.
1✔
934
        reader mapInstVarsFor: GLHBranch.
1✔
935
        reader
1✔
936
                for: #ArrayOfBranch
1✔
937
                customDo: [ :customMappting | 
1✔
938
                customMappting listOfElementSchema: GLHBranch ].
1✔
939
        ^ reader nextAs: #ArrayOfBranch
1✔
940
]
1✔
941

942
{ #category : #'private - parsing' }
943
GitlabModelImporter >> parseCommitResult: result [
×
944

×
945
        | reader |
×
946
        reader := NeoJSONReader on: result readStream.
×
947

×
948
        reader for: GLHCommit do: [ :mapping |
×
949
                mapping mapInstVars:
×
950
                        #( id short_id title author_name author_email committer_name
×
951
                           committer_email message web_url ).
×
952
                (mapping mapInstVar: #authored_date) valueSchema: DateAndTime.
×
953
                (mapping mapInstVar: #committed_date) valueSchema: DateAndTime.
×
954
                (mapping mapInstVar: #created_at) valueSchema: DateAndTime.
×
955
                (mapping mapInstVar: #parent_ids) valueSchema: #ArrayOfIds.
×
956
                mapping
×
957
                        mapProperty: 'stats'
×
958
                        getter: [ :el | "Not used" ]
×
959
                        setter: [ :commit :value |
×
960
                                commit deletions: (value at: #deletions).
×
961
                                commit additions: (value at: #additions) ] ].
×
962

×
963
        reader for: DateAndTime customDo: [ :mapping |
×
964
                mapping decoder: [ :string | DateAndTime fromString: string ] ].
×
965

×
966
        reader
×
967
                for: #ArrayOfIds
×
968
                customDo: [ :mapping | mapping decoder: [ :string | string ] ].
×
969

×
970

×
971
        ^ reader nextAs: GLHCommit
×
972
]
×
973

974
{ #category : #'private - parsing' }
975
GitlabModelImporter >> parseCommitsResult: result [
1✔
976

1✔
977
        | reader |
1✔
978
        reader := NeoJSONReader on: result readStream.
1✔
979

1✔
980
          reader for: GLHCommit do: [ :mapping |
1✔
981
                mapping mapInstVars:
1✔
982
                        #( id short_id title author_name author_email committer_name
1✔
983
                           committer_email message web_url ).
1✔
984
                (mapping mapInstVar: #authored_date) valueSchema: DateAndTime.
1✔
985
                (mapping mapInstVar: #committed_date) valueSchema: DateAndTime.
1✔
986
                (mapping mapInstVar: #created_at) valueSchema: DateAndTime.
1✔
987
                (mapping mapInstVar: #parent_ids) valueSchema: #ArrayOfIds.
1✔
988
                mapping
1✔
989
                        mapProperty: 'stats'
1✔
990
                        getter: [ :el | "Not used" ]
1✔
991
                        setter: [ :commit :value |
1✔
992
                                commit deletions: (value at: #deletions).
1✔
993
                                commit additions: (value at: #additions) ] ].
1✔
994

1✔
995
        reader for: DateAndTime customDo: [ :mapping |
1✔
996
                mapping decoder: [ :string | DateAndTime fromString: string ] ].
1✔
997

1✔
998
        reader
1✔
999
                for: #ArrayOfIds
1✔
1000
                customDo: [ :mapping | mapping decoder: [ :string | string ] ].
1✔
1001
  
1✔
1002
        reader
1✔
1003
                for: #ArrayOfCommit
1✔
1004
                customDo: [ :customMappting |
1✔
1005
                customMappting listOfElementSchema: GLHCommit ].
1✔
1006

1✔
1007
        ^ reader nextAs: #ArrayOfCommit
1✔
1008
]
1✔
1009

1010
{ #category : #private }
1011
GitlabModelImporter >> parseDiffResult: result [
×
1012

×
1013
        | reader |
×
1014
        self
×
1015
                deprecated: 'Use #newParseDiffResult: instead'
×
1016
                on: '28 June 2024'
×
1017
                in:
×
1018
                'Pharo-11.0.0+build.726.sha.aece1b5473acf3830a0e082c1bc3a15d4ff3522b (64 Bit)'.
×
1019
        reader := NeoJSONReader on: result readStream.
×
1020
        reader for: GLHDiff do: [ :mapping |
×
1021
                mapping mapInstVars:
×
1022
                        #( deleted_file new_file new_path old_path renamed_file ).
×
1023
                mapping mapInstVar: #diffString to: #diff ].
×
1024

×
1025
        reader
×
1026
                for: #ArrayOfDiffs
×
1027
                customDo: [ :customMappting |
×
1028
                customMappting listOfElementSchema: GLHDiff ].
×
1029
        ^ reader nextAs: #ArrayOfDiffs
×
1030
]
×
1031

1032
{ #category : #'private - parsing' }
1033
GitlabModelImporter >> parseFileTreeResult: aResult [
×
1034

×
1035
        | reader |
×
1036
        reader := NeoJSONReader on: aResult readStream.
×
1037
        reader mapInstVarsFor: GLHApiFile.
×
1038
        reader
×
1039
                for: #ArrayOfFile
×
1040
                customDo: [ :customMappting | 
×
1041
                customMappting listOfElementSchema: GLHApiFile ].
×
1042
        ^ reader nextAs: #ArrayOfFile
×
1043
]
×
1044

1045
{ #category : #'private - parsing' }
1046
GitlabModelImporter >> parseGroupResult: aResult [
1✔
1047

1✔
1048
        | reader |
1✔
1049

1✔
1050
        reader := NeoJSONReader on: aResult readStream.
1✔
1051
        reader for: GLHGroup do: [ :mapping |
1✔
1052
                mapping mapInstVars.
1✔
1053
                (mapping mapInstVar: #projects) valueSchema: #ArrayOfProjects ].
1✔
1054
        reader mapInstVarsFor: GLHProject.
1✔
1055
        reader
1✔
1056
                for: #ArrayOfProjects
1✔
1057
                customDo: [ :customMappting |
1✔
1058
                customMappting listOfElementSchema: GLHProject ].
1✔
1059
        ^ reader nextAs: GLHGroup
1✔
1060
]
1✔
1061

1062
{ #category : #'private - parsing' }
1063
GitlabModelImporter >> parseJobsResult: result ofProject: aProject [
×
1064

×
1065
        | reader |
×
1066
        reader := NeoJSONReader on: result readStream.
×
1067
        reader for: GLHJob do: [ :mapping |
×
1068
                mapping mapInstVars: #( id allow_failure web_url name ).
×
1069

×
1070
                mapping
×
1071
                        mapProperty: #user
×
1072
                        getter: [ :object | #ignore ]
×
1073
                        setter: [ :object :value |
×
1074
                        object user: (self importUser: (value at: #id)) ].
×
1075

×
1076
                mapping
×
1077
                        mapProperty: #commit
×
1078
                        getter: [ :object | #ignore ]
×
1079
                        setter: [ :object :value |
×
1080
                                value ifNotNil: [
×
1081
                                        object commit:
×
1082
                                                (self importCommit: (value at: #id) ofProject: aProject) ] ].
×
1083

×
1084
                mapping
×
1085
                        mapProperty: #duration
×
1086
                        getter: [ :object | #ignore ]
×
1087
                        setter: [ :object :value |
×
1088
                        value ifNotNil: [ object duration: value seconds ] ] ].
×
1089

×
1090
        reader
×
1091
                for: #ArrayOfGLHJob
×
1092
                customDo: [ :customMappting |
×
1093
                customMappting listOfElementSchema: GLHJob ].
×
1094
        ^ reader nextAs: #ArrayOfGLHJob
×
1095
]
×
1096

1097
{ #category : #'private - parsing' }
NEW
1098
GitlabModelImporter >> parseNoteJson: results [  
×
NEW
1099
    | reader |  
×
NEW
1100

×
NEW
1101
    "Créer un lecteur JSON"
×
NEW
1102
    reader := NeoJSONReader on: results readStream.    
×
NEW
1103

×
NEW
1104
    "Définir le mapping pour l'objet GLHNote"
×
NEW
1105
    reader for: GLHNote do: [ :mapping |  
×
NEW
1106
        mapping mapInstVars: #(id noteable_id attachment system confidential internal  
×
NEW
1107
                               noteable_iid resolvable imported imported_from  
×
NEW
1108
                               author body project_id noteable_type).  
×
NEW
1109

×
NEW
1110
        (mapping mapInstVar: #created_at) valueSchema: DateAndTime.  
×
NEW
1111
        (mapping mapInstVar: #updated_at) valueSchema: DateAndTime.  
×
NEW
1112
    ].    
×
NEW
1113

×
NEW
1114
    "Corriger la conversion des dates"
×
NEW
1115
    reader for: DateAndTime customDo: [ :mapping |  
×
NEW
1116
        mapping decoder: [ :string | DateAndTime readFrom: string readStream ] ].
×
NEW
1117

×
NEW
1118
        reader
×
NEW
1119
                for: #ArrayOfNote
×
NEW
1120
                customDo: [ :customMappting | 
×
NEW
1121
                customMappting listOfElementSchema: GLHNote ].
×
NEW
1122
         ^ reader nextAs: #ArrayOfNote
×
NEW
1123

×
NEW
1124
    "Retourner la Note"
×
NEW
1125
    "^ reader nextAs: GLHNote"
×
NEW
1126

×
NEW
1127

×
NEW
1128
]
×
1129

1130
{ #category : #'private - parsing' }
1131
GitlabModelImporter >> parsePipelinesResult: result [
×
1132

×
1133
        | reader |
×
1134
        
×
1135
        (result includesSubstring: '{"message":"40' )ifTrue: [ ^ {  } ].
×
1136
        
×
1137
        reader := NeoJSONReader on: result readStream.
×
1138
        reader mapInstVarsFor: GLHPipeline.
×
1139
        reader for: GLHPipeline do: [ :mapping |
×
1140
                mapping
×
1141
                        mapProperty: #created_at
×
1142
                        getter: [ :object | #ignore ]
×
1143
                        setter: [ :object :value |
×
1144
                        object runDate: (DateAndTime fromString: value) ] ].
×
1145
        reader
×
1146
                for: #ArrayOfPipelines
×
1147
                customDo: [ :customMappting |
×
1148
                customMappting listOfElementSchema: GLHPipeline ].
×
1149
        ^ reader nextAs: #ArrayOfPipelines
×
1150
]
×
1151

1152
{ #category : #'private - parsing' }
1153
GitlabModelImporter >> parseProjectResult: aResult [ 
×
1154
                | reader |
×
1155
        reader := NeoJSONReader on: aResult readStream.
×
1156
        reader for: GLHProject do: [ :mapping |
×
1157
                mapping mapInstVars. ].
×
1158
"        reader mapInstVarsFor: GLHProject."
×
1159

×
1160
        ^ reader nextAs: GLHProject
×
1161
]
×
1162

×
1163
{ #category : #'private - parsing' }
×
1164
GitlabModelImporter >> parseSubGroupResult: aResult [
×
1165

×
1166
        | reader |
×
1167
        reader := NeoJSONReader on: aResult readStream.
×
1168
        self configureReaderForGroup: reader.
×
1169
        ^ reader nextAs: #ArrayOfGroups
×
1170
]
×
1171

×
1172
{ #category : #'private - parsing' }
×
1173
GitlabModelImporter >> parseUserResult: result [
×
1174

×
1175
        | reader |
×
1176
        reader := NeoJSONReader on: result readStream.
×
1177
        reader mapInstVarsFor: GLHUser.
×
1178
        ^ reader nextAs: GLHUser
×
1179
]
×
1180

×
1181
{ #category : #'private - parsing' }
×
1182
GitlabModelImporter >> parseUsersResult: result [
×
1183

×
1184
        | reader |
×
1185
        reader := NeoJSONReader on: result readStream.
×
1186

×
1187
        reader mapInstVarsFor: GLHUser.
×
1188

×
1189
        reader
×
1190
                for: #ArrayOfUser
×
1191
                customDo: [ :customMappting |
×
1192
                customMappting listOfElementSchema: GLHUser ].
×
1193

×
1194
        ^ reader nextAs: #ArrayOfUser
×
1195
]
×
1196

×
1197
{ #category : #'imports - pipelines' }
×
1198
GitlabModelImporter >> pipelinesOf: aProjectID [
×
1199

×
1200
        | result |
×
1201
        ('Search pipelines of: ' , aProjectID printString) recordInfo.
×
1202
        result := self repoApi pipelines getAllInProject: aProjectID.
×
1203
        result isString ifTrue: [ ^ self parsePipelinesResult: result ].
×
1204

×
1205
        ^ (result collect: [ :pipelinesJson |
×
1206
                           self parsePipelinesResult: pipelinesJson ]) flattened
×
1207
]
×
1208

×
1209
{ #category : #private }
×
1210
GitlabModelImporter >> selectEntityType: aType overAttribut: aSelector equalTo: value [
×
1211

×
1212
        ^ (self glhModel allWithType: aType)
×
1213
                select: [ :entity | (entity perform: aSelector) = value ]
×
1214
]
×
1215

×
1216
{ #category : #'import - groups' }
×
1217
GitlabModelImporter >> subGroupsOf: aGroupID [
×
1218

×
1219
        | results subgroups |
×
1220
        ('Search subgroup of: ' , aGroupID printString) recordInfo.
×
1221
        results := self repoApi groups subgroupsOf: aGroupID.
×
1222
        subgroups := (results collect: [ :subgroupsJson | self parseSubGroupResult: subgroupsJson ]) flattened.
×
1223
        
×
1224
        ^ subgroups
×
1225
]
×
1226

×
1227
{ #category : #accessing }
×
1228
GitlabModelImporter >> withInitialCommits: boolean [
×
1229
        withInitialCommits := boolean 
×
1230
]
×
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