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

moosetechnology / GitProjectHealth / 13386705041

18 Feb 2025 08:53AM UTC coverage: 61.942% (-0.09%) from 62.03%
13386705041

Pull #132

github

web-flow
Merge e4e56b9c1 into 8ff2bbfd9
Pull Request #132: renaming all importer

965 of 2138 new or added lines in 18 files covered. (45.14%)

3 existing lines in 1 file now uncovered.

9624 of 15537 relevant lines covered (61.94%)

0.62 hits per line

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

42.82
/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 - 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 }
NEW
168
GitlabModelImporter >> convertApiFileAsFile: aAPIFile [
×
NEW
169

×
NEW
170
        aAPIFile type = 'tree' ifTrue: [ 
×
NEW
171
                ^ GLHFileDirectory new
×
NEW
172
                          name: aAPIFile name;
×
NEW
173
                          yourself ].
×
NEW
174
        ^ GLHFileBlob new
×
NEW
175
                  name: aAPIFile name;
×
NEW
176
                  yourself
×
NEW
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 }
NEW
187
GitlabModelImporter >> glhApi [
×
NEW
188

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

×
NEW
195
        ^ repoApi
×
NEW
196
]
×
197

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

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

×
NEW
207
        repoApi := anObject
×
NEW
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' }
NEW
223
GitlabModelImporter >> importActiveHumanUsers [
×
NEW
224

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

×
NEW
238
        ^ users
×
NEW
239
]
×
240

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

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

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

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

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

×
NEW
271
        | result parsedResult |
×
NEW
272
        (self glhModel allWithType: GLHCommit) asOrderedCollection
×
NEW
273
                detect: [ :commit | commit id = aCommitID ]
×
NEW
274
                ifFound: [ :commit | ^ commit ].
×
NEW
275
        result := self repoApi commits get: aCommitID inProject: aGLHProject id.
×
NEW
276
        
×
NEW
277
        parsedResult := self parseCommitResult: result.
×
NEW
278
        
×
NEW
279
        self
×
NEW
280
                addCommits: { parsedResult }
×
NEW
281
                toRepository: aGLHProject repository.
×
NEW
282
        ^ parsedResult
×
NEW
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' }
NEW
313
GitlabModelImporter >> importCommits: aGLHProject [
×
NEW
314
        "limited to the last 20 commits"
×
NEW
315

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

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

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

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

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

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

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

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

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

×
NEW
388

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

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

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

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

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

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

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

×
NEW
426
        ^ allCommits
×
NEW
427
]
×
428

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

×
NEW
432
        ^ self
×
NEW
433
                  importCommitsOfBranch: aGLHBranch
×
NEW
434
                  forRefName: aGLHBranch name
×
NEW
435
                  since: nil
×
NEW
436
                  until: toDate
×
NEW
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' }
NEW
471
GitlabModelImporter >> importContributedProjectsOfUser: aGLHUser [
×
NEW
472

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

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

×
NEW
490

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

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

×
NEW
499
        ^ projects
×
NEW
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' }
NEW
533
GitlabModelImporter >> importDirectoryFiles: aDirectoryFile OfBranch: aBranch [
×
NEW
534

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

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

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

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

×
NEW
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 - commits' }
NEW
648
GitlabModelImporter >> importParentCommitsOfCommit: aGLHCommit since: aDate [
×
NEW
649

×
NEW
650
        | parentsIds commits |
×
NEW
651
        commits := OrderedCollection new.
×
NEW
652
        aGLHCommit created_at asDateAndTime < aDate asDateAndTime ifTrue: [
×
NEW
653
                 
×
NEW
654
                ^ commits
×
NEW
655
                          add: aGLHCommit;
×
NEW
656
                          yourself ].
×
NEW
657

×
NEW
658
        parentsIds := aGLHCommit parent_ids.
×
NEW
659

×
NEW
660
        commits addAll: (parentsIds collect: [ :id |
×
NEW
661
                         self
×
NEW
662
                                 importCommitOfProject: aGLHCommit repository project
×
NEW
663
                                 withId: id ]).
×
NEW
664

×
NEW
665

×
NEW
666
        ^ (commits collect: [ :parentCommit |
×
NEW
667
                   self importParentCommitsOfCommit: parentCommit since: aDate ])
×
NEW
668
                  flatten
×
NEW
669
]
×
670

671
{ #category : #'imports - pipelines' }
672
GitlabModelImporter >> importPipelinesOfProject: aGLHProject [
1✔
673

1✔
674
        (self pipelinesOf: aGLHProject id) do: [ :pipeline |
1✔
675
                self glhModel add: pipeline unless: self blockOnIdEquality .
1✔
676
                aGLHProject pipelines add: pipeline unless: self blockOnIdEquality]
1✔
677
]
1✔
678

679
{ #category : #'import - projects' }
NEW
680
GitlabModelImporter >> importProject: aProjectID [
×
NEW
681

×
NEW
682
        | result projectResult |
×
NEW
683
        ('Import project with id: ' , aProjectID printString) recordInfo.
×
NEW
684

×
NEW
685
        result := self repoApi projects get: aProjectID.
×
NEW
686
        projectResult := self parseProjectResult: result.
×
NEW
687

×
NEW
688
        ^ self completeImportProject: projectResult
×
NEW
689
]
×
690

691
{ #category : #'import - projects' }
NEW
692
GitlabModelImporter >> importProjects [
×
NEW
693

×
NEW
694
        | result projects |
×
NEW
695
        ('import all Projects') recordInfo.
×
NEW
696

×
NEW
697

×
NEW
698
        result := self repoApi projects all.
×
NEW
699
        projects := (result collect: [ :projectsJson | self parseArrayOfProject: projectsJson ]) flattened.
×
NEW
700
        
×
NEW
701
        self glhModel addAll: projects unless: self blockOnIdEquality.
×
NEW
702

×
NEW
703
        ^ projects
×
NEW
704
]
×
705

706
{ #category : #'import - projects' }
NEW
707
GitlabModelImporter >> importProjects: aCollectionOfProjectID [
×
NEW
708

×
NEW
709

×
NEW
710
        ^ aCollectionOfProjectID collect: [ :id | self importProject: id ]
×
NEW
711
]
×
712

713
{ #category : #imports }
NEW
714
GitlabModelImporter >> importProjectsSince: since [
×
NEW
715
        "heavy import of all projects"
×
NEW
716

×
NEW
717
        "copy import from commits"
×
NEW
718

×
NEW
719
        | newlyFoundProjects page foundProject amount |
×
NEW
720
        ('import all Projects since: ' , since printString) recordInfo.
×
NEW
721

×
NEW
722
        "number of projects per page"
×
NEW
723
        amount := 100.
×
NEW
724
        page := 0.
×
NEW
725
        foundProject := OrderedCollection new.
×
NEW
726
        newlyFoundProjects := { true }.
×
NEW
727
        [ newlyFoundProjects isNotEmpty ] whileTrue: [
×
NEW
728
                | results |
×
NEW
729
                page := page + 1.
×
NEW
730
                ('import projects page #' , page printString) recordInfo.
×
NEW
731

×
NEW
732
                results := self repoApi projects: amount since: since page: page.
×
NEW
733

×
NEW
734
                newlyFoundProjects := self glhModel
×
NEW
735
                                              addAll: (self parseArrayOfProject: results)
×
NEW
736
                                              unless: self blockOnIdEquality.
×
NEW
737
                foundProject addAll: newlyFoundProjects ].
×
NEW
738
]
×
739

740
{ #category : #'import - repositories' }
741
GitlabModelImporter >> importRepository: aGLHRepository [
1✔
742

1✔
743
        | resultBranches branches |
1✔
744
        [
1✔
745
        ('import the repository of project ' , aGLHRepository project name)
1✔
746
                recordInfo.
1✔
747

1✔
748
        resultBranches := self repoApi branches getAllFromProject: aGLHRepository project id.
1✔
749
        
1✔
750
        branches := (resultBranches collect: [ :branchesJson | self parseBranchesResult: branchesJson ]) flattened.
1✔
751

1✔
752
        'import the branches of project ' recordInfo.
1✔
753

1✔
754
        branches := aGLHRepository branches
1✔
755
                            addAll: branches
1✔
756
                            unless: self blockOnNameEquality.
1✔
757
        branches := self glhModel
1✔
758
                            addAll: branches
1✔
759
                            unless: self blockOnNameEquality.
1✔
760

1✔
761

1✔
762
        self withFiles ifTrue: [
1✔
763
                branches do: [ :branch | self importFilesOfBranch: branch ] ] ]
1✔
764
                on: NeoJSONParseError
1✔
765
                do: [
1✔
766
                self inform: aGLHRepository project name , ' has no repository' ]
1✔
767
]
1✔
768

769
{ #category : #'import - users' }
770
GitlabModelImporter >> importUser: aUserID [
1✔
771

1✔
772
        | result userResult |
1✔
773
        (self glhModel allWithType: GLHUser)
1✔
774
                detect: [ :user | user id = aUserID ]
1✔
775
                ifFound: [ :user | ^ user ].
1✔
776
        ('Import user: ' , aUserID printString) recordInfo.
1✔
777
        
1✔
778
        result := self repoApi users get: aUserID.
1✔
779
        userResult := self parseUserResult: result.
1✔
780
        
1✔
781
        userResult := self glhModel add: userResult unless: self blockOnIdEquality.
1✔
782
        userCatalogue addUser: userResult.
1✔
783
        ^ userResult 
1✔
784
]
1✔
785

786
{ #category : #'import - users' }
787
GitlabModelImporter >> importUserByUsername: anUsername [
1✔
788

1✔
789
        | dicUsername resultUser |
1✔
790
        dicUsername := ((self glhModel allWithType: GLHUser) collect: [ :user |
1✔
791
                                user username -> user ]) asSet asDictionary.
1✔
792

1✔
793
        dicUsername addAll: self userCatalogue collectUsernames.
1✔
794

1✔
795

1✔
796
        resultUser := dicUsername
1✔
797
                              at: anUsername
1✔
798
                              ifAbsent: [ "thus we have to import this new user"
1✔
799
                                      | result userId searchResult params |
1✔
800
                                      ('Import user with username: '
1✔
801
                                       , anUsername printString) recordInfo.
1✔
802
                                      params := { (#search -> anUsername) } asDictionary.
1✔
803
                                      result := self repoApi users allWithParams: params.
1✔
804
                                                        
1✔
805
                                                         "when result is an error"
1✔
806
                                                         (result isString) ifTrue: [ result := { result } ].
1✔
807
                                                        
1✔
808
                                      searchResult := result ifEmpty: [ result ] ifNotEmpty: [(result collect: [ :usersJson |
1✔
809
                                                               NeoJSONReader fromString: usersJson ]) first].
1✔
810
                                                         
1✔
811
                                      (searchResult class = Dictionary and: [
1✔
812
                                               (searchResult at: #message) includesSubstring:
1✔
813
                                                       '403 Forbidden' ])
1✔
814
                                              ifTrue: [ "if the result is an 403 error we fake a new user"
1✔
815
                                                      self glhModel
1✔
816
                                                              add: (GLHUser new
1✔
817
                                                                               username: anUsername;
1✔
818
                                                                               name: anUsername;
1✔
819
                                                                               yourself)
1✔
820
                                                              unless: [ :nu :ou | nu username = ou username ] ]
1✔
821
                                              ifFalse: [
1✔
822
                                                      searchResult
1✔
823
                                                              ifEmpty: [ "results can be empty thus we force a new user with the info we have "
1✔
824
                                                                      self glhModel
1✔
825
                                                                              add: (GLHUser new
1✔
826
                                                                                               username: anUsername;
1✔
827
                                                                                               name: anUsername;
1✔
828
                                                                                               yourself)
1✔
829
                                                                              unless: [ :nu :ou | nu username = ou username ] ]
1✔
830
                                                              ifNotEmpty: [ "because we may already have the researched user, we look by ID in the model"
1✔
831
                                                                      userId := searchResult first at: #id.
1✔
832
                                                                      (self glhModel allWithType: GLHUser)
1✔
833
                                                                              detect: [ :user | user id = userId ]
1✔
834
                                                                              ifNone: [ self importUser: userId ] ] ] ].
1✔
835

1✔
836
        self userCatalogue addUser: resultUser withName: anUsername.
1✔
837

1✔
838
        ^ resultUser
1✔
839
]
1✔
840

841
{ #category : #initialization }
842
GitlabModelImporter >> initReader [
1✔
843

1✔
844
        generalReader := NeoJSONReader new.
1✔
845
        self configureReaderForCommit: generalReader.
1✔
846
        self configureReaderForGroup: generalReader.
1✔
847
        self configureReaderForDiffs: generalReader. 
1✔
848
]
1✔
849

850
{ #category : #initialization }
851
GitlabModelImporter >> initialize [
1✔
852

1✔
853
        super initialize.
1✔
854
        withCommitDiffs := false.
1✔
855
        withInitialCommits := false.
1✔
856
        withInitialMergeRequest := false.
1✔
857

1✔
858
        withCommitsSince := (Date today - 1 week) asDateAndTime.
1✔
859

1✔
860
        self initReader.
1✔
861

1✔
862
]
1✔
863

864
{ #category : #private }
865
GitlabModelImporter >> isServerError: aString [
1✔
866
        ^ aString = '{"message":"500 Internal Server Error"}'
1✔
867
]
1✔
868

869
{ #category : #'import - projects' }
NEW
870
GitlabModelImporter >> loadAllProjectsFromRepositorySoftware [
×
NEW
871
        "heavy import that load all the active project inside the model. Only import the project entities"
×
NEW
872
        |projects|
×
NEW
873
        
×
NEW
874
        projects := self repoApi projects. 
×
NEW
875
]
×
876

877
{ #category : #'private - parsing' }
NEW
878
GitlabModelImporter >> newParseCommitResult: result [
×
NEW
879

×
NEW
880
        generalReader  on: result readStream.
×
NEW
881

×
NEW
882
        ^ generalReader nextAs: GLHCommit
×
NEW
883
]
×
884

885
{ #category : #'private - parsing' }
886
GitlabModelImporter >> newParseDiffResult: result [
1✔
887

1✔
888
        generalReader on: result readStream.
1✔
889
        ^ generalReader nextAs: #ArrayOfDiffs
1✔
890
]
1✔
891

892
{ #category : #'private - parsing' }
NEW
893
GitlabModelImporter >> parseArrayOfProject: arrayOfProjects [
×
NEW
894

×
NEW
895
        | reader |
×
NEW
896
        reader := NeoJSONReader on: arrayOfProjects readStream.
×
NEW
897
        reader
×
NEW
898
                for: #ArrayOfProjects
×
NEW
899
                customDo: [ :customMappting |
×
NEW
900
                customMappting listOfElementSchema: GLHProject ].
×
NEW
901
        reader for: GLHProject do: [ :mapping |
×
NEW
902
                mapping mapInstVar: #name to: #name.
×
NEW
903
                mapping mapInstVar: #description to: #description.
×
NEW
904
                mapping mapInstVar: #id to: #id.
×
NEW
905
                mapping mapInstVar: #archived to: #archived.
×
NEW
906
                mapping mapInstVar: #web_url to: #html_url.
×
NEW
907
                mapping mapInstVar: #topics to: #topics ].
×
NEW
908
        ^ reader nextAs: #ArrayOfProjects
×
NEW
909
]
×
910

911
{ #category : #'private - parsing' }
912
GitlabModelImporter >> parseBranchesResult: result [
1✔
913

1✔
914
        | reader |
1✔
915
        reader := NeoJSONReader on: result readStream.
1✔
916
        reader mapInstVarsFor: GLHBranch.
1✔
917
        reader
1✔
918
                for: #ArrayOfBranch
1✔
919
                customDo: [ :customMappting | 
1✔
920
                customMappting listOfElementSchema: GLHBranch ].
1✔
921
        ^ reader nextAs: #ArrayOfBranch
1✔
922
]
1✔
923

924
{ #category : #'private - parsing' }
NEW
925
GitlabModelImporter >> parseCommitResult: result [
×
NEW
926

×
NEW
927
        | reader |
×
NEW
928
        reader := NeoJSONReader on: result readStream.
×
NEW
929

×
NEW
930
        reader for: GLHCommit do: [ :mapping |
×
NEW
931
                mapping mapInstVars:
×
NEW
932
                        #( id short_id title author_name author_email committer_name
×
NEW
933
                           committer_email message web_url ).
×
NEW
934
                (mapping mapInstVar: #authored_date) valueSchema: DateAndTime.
×
NEW
935
                (mapping mapInstVar: #committed_date) valueSchema: DateAndTime.
×
NEW
936
                (mapping mapInstVar: #created_at) valueSchema: DateAndTime.
×
NEW
937
                (mapping mapInstVar: #parent_ids) valueSchema: #ArrayOfIds.
×
NEW
938
                mapping
×
NEW
939
                        mapProperty: 'stats'
×
NEW
940
                        getter: [ :el | "Not used" ]
×
NEW
941
                        setter: [ :commit :value |
×
NEW
942
                                commit deletions: (value at: #deletions).
×
NEW
943
                                commit additions: (value at: #additions) ] ].
×
NEW
944

×
NEW
945
        reader for: DateAndTime customDo: [ :mapping |
×
NEW
946
                mapping decoder: [ :string | DateAndTime fromString: string ] ].
×
NEW
947

×
NEW
948
        reader
×
NEW
949
                for: #ArrayOfIds
×
NEW
950
                customDo: [ :mapping | mapping decoder: [ :string | string ] ].
×
NEW
951

×
NEW
952

×
NEW
953
        ^ reader nextAs: GLHCommit
×
NEW
954
]
×
955

956
{ #category : #'private - parsing' }
957
GitlabModelImporter >> parseCommitsResult: result [
1✔
958

1✔
959
        | reader |
1✔
960
        reader := NeoJSONReader on: result readStream.
1✔
961

1✔
962
          reader for: GLHCommit do: [ :mapping |
1✔
963
                mapping mapInstVars:
1✔
964
                        #( id short_id title author_name author_email committer_name
1✔
965
                           committer_email message web_url ).
1✔
966
                (mapping mapInstVar: #authored_date) valueSchema: DateAndTime.
1✔
967
                (mapping mapInstVar: #committed_date) valueSchema: DateAndTime.
1✔
968
                (mapping mapInstVar: #created_at) valueSchema: DateAndTime.
1✔
969
                (mapping mapInstVar: #parent_ids) valueSchema: #ArrayOfIds.
1✔
970
                mapping
1✔
971
                        mapProperty: 'stats'
1✔
972
                        getter: [ :el | "Not used" ]
1✔
973
                        setter: [ :commit :value |
1✔
974
                                commit deletions: (value at: #deletions).
1✔
975
                                commit additions: (value at: #additions) ] ].
1✔
976

1✔
977
        reader for: DateAndTime customDo: [ :mapping |
1✔
978
                mapping decoder: [ :string | DateAndTime fromString: string ] ].
1✔
979

1✔
980
        reader
1✔
981
                for: #ArrayOfIds
1✔
982
                customDo: [ :mapping | mapping decoder: [ :string | string ] ].
1✔
983
  
1✔
984
        reader
1✔
985
                for: #ArrayOfCommit
1✔
986
                customDo: [ :customMappting |
1✔
987
                customMappting listOfElementSchema: GLHCommit ].
1✔
988

1✔
989
        ^ reader nextAs: #ArrayOfCommit
1✔
990
]
1✔
991

992
{ #category : #private }
NEW
993
GitlabModelImporter >> parseDiffResult: result [
×
NEW
994

×
NEW
995
        | reader |
×
NEW
996
        self
×
NEW
997
                deprecated: 'Use #newParseDiffResult: instead'
×
NEW
998
                on: '28 June 2024'
×
NEW
999
                in:
×
NEW
1000
                'Pharo-11.0.0+build.726.sha.aece1b5473acf3830a0e082c1bc3a15d4ff3522b (64 Bit)'.
×
NEW
1001
        reader := NeoJSONReader on: result readStream.
×
NEW
1002
        reader for: GLHDiff do: [ :mapping |
×
NEW
1003
                mapping mapInstVars:
×
NEW
1004
                        #( deleted_file new_file new_path old_path renamed_file ).
×
NEW
1005
                mapping mapInstVar: #diffString to: #diff ].
×
NEW
1006

×
NEW
1007
        reader
×
NEW
1008
                for: #ArrayOfDiffs
×
NEW
1009
                customDo: [ :customMappting |
×
NEW
1010
                customMappting listOfElementSchema: GLHDiff ].
×
NEW
1011
        ^ reader nextAs: #ArrayOfDiffs
×
NEW
1012
]
×
1013

1014
{ #category : #'private - parsing' }
NEW
1015
GitlabModelImporter >> parseFileTreeResult: aResult [
×
NEW
1016

×
NEW
1017
        | reader |
×
NEW
1018
        reader := NeoJSONReader on: aResult readStream.
×
NEW
1019
        reader mapInstVarsFor: GLHApiFile.
×
NEW
1020
        reader
×
NEW
1021
                for: #ArrayOfFile
×
NEW
1022
                customDo: [ :customMappting | 
×
NEW
1023
                customMappting listOfElementSchema: GLHApiFile ].
×
NEW
1024
        ^ reader nextAs: #ArrayOfFile
×
NEW
1025
]
×
1026

1027
{ #category : #'private - parsing' }
1028
GitlabModelImporter >> parseGroupResult: aResult [
1✔
1029

1✔
1030
        | reader |
1✔
1031

1✔
1032
        reader := NeoJSONReader on: aResult readStream.
1✔
1033
        reader for: GLHGroup do: [ :mapping |
1✔
1034
                mapping mapInstVars.
1✔
1035
                (mapping mapInstVar: #projects) valueSchema: #ArrayOfProjects ].
1✔
1036
        reader mapInstVarsFor: GLHProject.
1✔
1037
        reader
1✔
1038
                for: #ArrayOfProjects
1✔
1039
                customDo: [ :customMappting |
1✔
1040
                customMappting listOfElementSchema: GLHProject ].
1✔
1041
        ^ reader nextAs: GLHGroup
1✔
1042
]
1✔
1043

1044
{ #category : #'private - parsing' }
NEW
1045
GitlabModelImporter >> parseJobsResult: result ofProject: aProject [
×
NEW
1046

×
NEW
1047
        | reader |
×
NEW
1048
        reader := NeoJSONReader on: result readStream.
×
NEW
1049
        reader for: GLHJob do: [ :mapping |
×
NEW
1050
                mapping mapInstVars: #( id allow_failure web_url name ).
×
NEW
1051

×
NEW
1052
                mapping
×
NEW
1053
                        mapProperty: #user
×
NEW
1054
                        getter: [ :object | #ignore ]
×
NEW
1055
                        setter: [ :object :value |
×
NEW
1056
                        object user: (self importUser: (value at: #id)) ].
×
NEW
1057

×
NEW
1058
                mapping
×
NEW
1059
                        mapProperty: #commit
×
NEW
1060
                        getter: [ :object | #ignore ]
×
NEW
1061
                        setter: [ :object :value |
×
NEW
1062
                                value ifNotNil: [
×
NEW
1063
                                        object commit:
×
NEW
1064
                                                (self importCommit: (value at: #id) ofProject: aProject) ] ].
×
NEW
1065

×
NEW
1066
                mapping
×
NEW
1067
                        mapProperty: #duration
×
NEW
1068
                        getter: [ :object | #ignore ]
×
NEW
1069
                        setter: [ :object :value |
×
NEW
1070
                        value ifNotNil: [ object duration: value seconds ] ] ].
×
NEW
1071

×
NEW
1072
        reader
×
NEW
1073
                for: #ArrayOfGLHJob
×
NEW
1074
                customDo: [ :customMappting |
×
NEW
1075
                customMappting listOfElementSchema: GLHJob ].
×
NEW
1076
        ^ reader nextAs: #ArrayOfGLHJob
×
NEW
1077
]
×
1078

1079
{ #category : #'private - parsing' }
NEW
1080
GitlabModelImporter >> parsePipelinesResult: result [
×
NEW
1081

×
NEW
1082
        | reader |
×
NEW
1083
        
×
NEW
1084
        (result includesSubstring: '{"message":"40' )ifTrue: [ ^ {  } ].
×
NEW
1085
        
×
NEW
1086
        reader := NeoJSONReader on: result readStream.
×
NEW
1087
        reader mapInstVarsFor: GLHPipeline.
×
NEW
1088
        reader for: GLHPipeline do: [ :mapping |
×
NEW
1089
                mapping
×
NEW
1090
                        mapProperty: #created_at
×
NEW
1091
                        getter: [ :object | #ignore ]
×
NEW
1092
                        setter: [ :object :value |
×
NEW
1093
                        object runDate: (DateAndTime fromString: value) ] ].
×
NEW
1094
        reader
×
NEW
1095
                for: #ArrayOfPipelines
×
NEW
1096
                customDo: [ :customMappting |
×
NEW
1097
                customMappting listOfElementSchema: GLHPipeline ].
×
NEW
1098
        ^ reader nextAs: #ArrayOfPipelines
×
NEW
1099
]
×
1100

1101
{ #category : #'private - parsing' }
NEW
1102
GitlabModelImporter >> parseProjectResult: aResult [ 
×
NEW
1103
                | reader |
×
NEW
1104
        reader := NeoJSONReader on: aResult readStream.
×
NEW
1105
        reader for: GLHProject do: [ :mapping |
×
NEW
1106
                mapping mapInstVars. ].
×
NEW
1107
"        reader mapInstVarsFor: GLHProject."
×
NEW
1108

×
NEW
1109
        ^ reader nextAs: GLHProject
×
NEW
1110
]
×
NEW
1111

×
NEW
1112
{ #category : #'private - parsing' }
×
NEW
1113
GitlabModelImporter >> parseSubGroupResult: aResult [
×
NEW
1114

×
NEW
1115
        | reader |
×
NEW
1116
        reader := NeoJSONReader on: aResult readStream.
×
NEW
1117
        self configureReaderForGroup: reader.
×
NEW
1118
        ^ reader nextAs: #ArrayOfGroups
×
NEW
1119
]
×
NEW
1120

×
NEW
1121
{ #category : #'private - parsing' }
×
NEW
1122
GitlabModelImporter >> parseUserResult: result [
×
NEW
1123

×
NEW
1124
        | reader |
×
NEW
1125
        reader := NeoJSONReader on: result readStream.
×
NEW
1126
        reader mapInstVarsFor: GLHUser.
×
NEW
1127
        ^ reader nextAs: GLHUser
×
NEW
1128
]
×
NEW
1129

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

×
NEW
1133
        | reader |
×
NEW
1134
        reader := NeoJSONReader on: result readStream.
×
NEW
1135

×
NEW
1136
        reader mapInstVarsFor: GLHUser.
×
NEW
1137

×
NEW
1138
        reader
×
NEW
1139
                for: #ArrayOfUser
×
NEW
1140
                customDo: [ :customMappting |
×
NEW
1141
                customMappting listOfElementSchema: GLHUser ].
×
NEW
1142

×
NEW
1143
        ^ reader nextAs: #ArrayOfUser
×
NEW
1144
]
×
NEW
1145

×
NEW
1146
{ #category : #'imports - pipelines' }
×
NEW
1147
GitlabModelImporter >> pipelinesOf: aProjectID [
×
NEW
1148

×
NEW
1149
        | result |
×
NEW
1150
        ('Search pipelines of: ' , aProjectID printString) recordInfo.
×
NEW
1151
        result := self repoApi pipelines getAllInProject: aProjectID.
×
NEW
1152
        result isString ifTrue: [ ^ self parsePipelinesResult: result ].
×
NEW
1153

×
NEW
1154
        ^ (result collect: [ :pipelinesJson |
×
NEW
1155
                           self parsePipelinesResult: pipelinesJson ]) flattened
×
NEW
1156
]
×
NEW
1157

×
NEW
1158
{ #category : #private }
×
NEW
1159
GitlabModelImporter >> selectEntityType: aType overAttribut: aSelector equalTo: value [
×
NEW
1160

×
NEW
1161
        ^ (self glhModel allWithType: aType)
×
NEW
1162
                select: [ :entity | (entity perform: aSelector) = value ]
×
NEW
1163
]
×
NEW
1164

×
NEW
1165
{ #category : #'import - groups' }
×
NEW
1166
GitlabModelImporter >> subGroupsOf: aGroupID [
×
NEW
1167

×
NEW
1168
        | results subgroups |
×
NEW
1169
        ('Search subgroup of: ' , aGroupID printString) recordInfo.
×
NEW
1170
        results := self repoApi groups subgroupsOf: aGroupID.
×
NEW
1171
        subgroups := (results collect: [ :subgroupsJson | self parseSubGroupResult: subgroupsJson ]) flattened.
×
NEW
1172
        
×
NEW
1173
        ^ subgroups
×
NEW
1174
]
×
NEW
1175

×
NEW
1176
{ #category : #accessing }
×
NEW
1177
GitlabModelImporter >> withInitialCommits: boolean [
×
NEW
1178
        withInitialCommits := boolean 
×
NEW
1179
]
×
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