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

moosetechnology / GitProjectHealth / 18457073104

13 Oct 2025 06:25AM UTC coverage: 77.946% (+4.6%) from 73.342%
18457073104

push

github

web-flow
Merge pull request #233 from moosetechnology/importer-refactoring

V2.0.0 : Refactoring importers

4743 of 5132 new or added lines in 45 files covered. (92.42%)

32 existing lines in 8 files now uncovered.

23068 of 29595 relevant lines covered (77.95%)

0.78 hits per line

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

68.85
/src/GitHubHealth-Model-Importer/GithubModelImporter.class.st
1
Class {
2
        #name : #GithubModelImporter,
3
        #superclass : #GitModelImporter,
4
        #category : #'GitHubHealth-Model-Importer'
5
}
6

7
{ #category : #api }
8
GithubModelImporter >> api [
×
9

×
10
        self
×
11
                deprecated: 'Use #repoApi instead'
×
12
                on: '7 October 2024'
×
13
                in:
×
14
                'Pharo-11.0.0+build.726.sha.aece1b5473acf3830a0e082c1bc3a15d4ff3522b (64 Bit)'.
×
15

×
16
        ^ repoApi
×
17
]
×
18

19
{ #category : #api }
20
GithubModelImporter >> api: anObject [
×
21

×
22
        self
×
23
                deprecated: 'Use #repoApi: instead'
×
24
                on: '7 October 2024'
×
25
                in:
×
26
                'Pharo-11.0.0+build.726.sha.aece1b5473acf3830a0e082c1bc3a15d4ff3522b (64 Bit)'.
×
27

×
28
        repoApi := anObject
×
29
]
×
30

31
{ #category : #'import - commits' }
32
GithubModelImporter >> completeImportedCommit: aGLHCommit [
×
33

×
34
        | result |
×
35
        ('completing commit: ' , aGLHCommit short_id printString) recordInfo.
×
36
        "link commit to user"
×
37
        self importCreatorOfCommit: aGLHCommit.
×
38

×
39
        "import deletion and addition"
×
40
        result := self repoApi
×
41
                          commit: aGLHCommit id
×
42
                          ofOrganisation: aGLHCommit repository project group name
×
43
                          ofProject: aGLHCommit repository project name.
×
44
        aGLHCommit deletions:
×
45
                ((result at: #files) collect: [ :file | file at: #deletions ]) sum.
×
46
        aGLHCommit additions:
×
47
                ((result at: #files) collect: [ :file | file at: #additions ]) sum.
×
48

×
49

×
50
        "import diffs of this commits"
×
51
        self withCommitDiffs ifTrue: [
×
52
                | diffs |
×
53
                aGLHCommit diffs ifEmpty: [
×
54
                        diffs := self parseDiffresult: result.
×
55
                        diffs := aGLHCommit diffs
×
56
                                         addAll: diffs
×
57
                                         unless: self blockForDiffEquality.
×
58
                        self glhModel addAll: diffs unless: self blockForDiffEquality.
×
59
                        diffs do: [ :diff | self importDiffRangesForDiff: diff ] ] ].
×
60

×
61
        ^ aGLHCommit 
×
62
]
×
63

64
{ #category : #'import - projects' }
65
GithubModelImporter >> completeImportedProject: aGLHProject [
1✔
66

1✔
67
        ('Complete import of project: ' , aGLHProject id printString)
1✔
68
                recordInfo.
1✔
69
        aGLHProject repository ifNotNil: [ ^ aGLHProject ].
1✔
70

1✔
71
        aGLHProject repository: GLHRepository new.
1✔
72
        self glhModel add: aGLHProject repository.
1✔
73

1✔
74
        self importPipelinesOfProject: aGLHProject.
1✔
75
        self importBranchesOf: aGLHProject.
1✔
76
        self withCommitsSince ifNotNil: [ :withCommitSince | "If not nil, it means we have to import commit"
1✔
77
                | commits |
1✔
78
                commits := self importCommitsOfProject: aGLHProject.
1✔
79
                self chainsCommitsFrom: commits ]
1✔
80
]
1✔
81

82
{ #category : #'private - configure reader' }
83
GithubModelImporter >> configureReaderForBranch: reader [
1✔
84

1✔
85
        super configureReaderForBranch: reader.
1✔
86

1✔
87
        reader for: GLHBranch do: [ :mapping |
1✔
88
                mapping
1✔
89
                        mapProperty: #sha
1✔
90
                        getter: [ :branch | #ignore ]
1✔
91
                        setter: [ :branch :value | branch sha: (value at: #sha) ] ]
1✔
92
]
1✔
93

94
{ #category : #'private - configure reader' }
95
GithubModelImporter >> configureReaderForCommit: reader [
1✔
96

1✔
97
        super configureReaderForCommit: reader.
1✔
98

1✔
99
        reader for: GLHCommit do: [ :mapping |
1✔
100
                mapping mapInstVar: #id to: #sha.
1✔
101
                mapping mapInstVar: #web_url to: #html_url.
1✔
102

1✔
103
                mapping
1✔
104
                        mapProperty: #commit
1✔
105
                        getter: [ :object | #ignore ]
1✔
106
                        setter: [ :glhCommit :value |
1✔
107
                                glhCommit message: (value at: #message).
1✔
108
                                glhCommit authored_date:
1✔
109
                                        (DateAndTime fromString: (value at: #author at: #date)).
1✔
110
                                glhCommit committed_date:
1✔
111
                                        (DateAndTime fromString: (value at: #committer at: #date)) ].
1✔
112

1✔
113
                mapping
1✔
114
                        mapProperty: #author
1✔
115
                        getter: [ :object | #ignore ]
1✔
116
                        setter: [ :glhCommit :value |
1✔
117
                                value ifNotNil: [
1✔
118
                                        glhCommit author_name: (value at: #login).
1✔
119
                                        value
1✔
120
                                                at: #id
1✔
121
                                                ifPresent: [ :authorId |
1✔
122
                                                glhCommit cacheAt: #authorID put: (value at: #id) ] ] ].
1✔
123

1✔
124
                mapping
1✔
125
                        mapProperty: #committer
1✔
126
                        getter: [ :object | #ignore ]
1✔
127
                        setter: [ :glhCommit :value |
1✔
128
                                value ifNotNil: [ glhCommit committer_name: (value at: #login) ] ].
1✔
129

1✔
130
                (mapping mapInstVar: #parent_ids to: #parents) valueSchema:
1✔
131
                        #ArrayOfId.
1✔
132
                        
1✔
133
                (mapping mapInstVar: #diffs to: #files) valueSchema: #ArrayOfDiff. 
1✔
134
                        
1✔
135
                         ].
1✔
136

1✔
137
        reader for: DateAndTime customDo: [ :mapping |
1✔
138
                mapping decoder: [ :string | DateAndTime fromString: string ] ].
1✔
139

1✔
140
        reader for: #ArrayOfId customDo: [ :mapping |
1✔
141
                mapping decoder: [ :parents |
1✔
142
                        parents collect: [ :parent | parent at: #sha ] ] ]
1✔
143
]
1✔
144

145
{ #category : #'private - configure reader' }
146
GithubModelImporter >> configureReaderForDiff: reader [
1✔
147

1✔
148
        super configureReaderForDiff: reader.
1✔
149

1✔
150
        reader for: GLHDiff do: [ :mapping |
1✔
151
                mapping mapInstVar: #new_path to: #filename.
1✔
152
                mapping mapInstVar: #old_path to: #filename.
1✔
153
                mapping mapInstVar: #diffString to: #patch. ]
1✔
154
]
1✔
155

156
{ #category : #'private - configure reader' }
157
GithubModelImporter >> configureReaderForGroup: reader [
1✔
158

1✔
159
        super configureReaderForGroup: reader.
1✔
160
        
1✔
161
        reader
1✔
162
                for: GLHGroup
1✔
163
                do: [ :mapping | mapping mapInstVar: #web_url to: #html_url ]
1✔
164
]
1✔
165

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

1✔
169
        super configureReaderForIssue: reader.
1✔
170

1✔
171
        reader
1✔
172
                for: GLHIssue
1✔
173
                do: [ :mapping | "mapping mapInstVar: #status to: #conclusion."
1✔
174
                        (mapping mapInstVar: #created_at) valueSchema: DateAndTime.
1✔
175
                        (mapping mapInstVar: #updated_at) valueSchema: DateAndTime.
1✔
176
                        mapping mapInstVar: #name to: #title.
1✔
177
                        mapping mapInstVar: #description to: #body.
1✔
178

1✔
179

1✔
180
                        mapping
1✔
181
                                mapProperty: #assignees
1✔
182
                                getter: [ :object | #ignore ]
1✔
183
                                setter: [ :issue :values |
1✔
184
                                        values do: [ :item |
1✔
185
                                                issue
1✔
186
                                                        cacheAt: #assigneesID
1✔
187
                                                        ifPresent: [ :v | v add: (item at: #id) ]
1✔
188
                                                        ifAbsentPut: [
1✔
189
                                                                Set new
1✔
190
                                                                        add: (item at: #id);
1✔
191
                                                                        yourself ] ] ].
1✔
192

1✔
193

1✔
194
                        mapping
1✔
195
                                mapProperty: #user
1✔
196
                                getter: [ :object | #ignore ]
1✔
197
                                setter: [ :issue :value |
1✔
198
                                        value ifNotNil: [
1✔
199
                                                value
1✔
200
                                                        at: #id
1✔
201
                                                        ifPresent: [ :authorId |
1✔
202
                                                        issue cacheAt: #authorID put: (value at: #id) ] ] ] ]
1✔
203
]
1✔
204

205
{ #category : #'private - configure reader' }
206
GithubModelImporter >> configureReaderForJob: reader [
1✔
207

1✔
208
        super configureReaderForJob: reader.
1✔
209

1✔
210
        reader for: GLHJob do: [ :mapping |
1✔
211
                
1✔
212
                mapping mapInstVar: #web_url to: #html_url.
1✔
213
                
1✔
214
                mapping
1✔
215
                        mapProperty: #pipeline
1✔
216
                        getter: [  ]
1✔
217
                        setter: [ :job :rawPipeline |
1✔
218
                                job cacheAt: #pipelineID put: (rawPipeline at: #head_sha) ].
1✔
219

1✔
220
                mapping
1✔
221
                        mapProperty: #commit
1✔
222
                        getter: [  ]
1✔
223
                        setter: [ :job :rawCommit |
1✔
224
                        job cacheAt: #commitID put: (rawCommit at: #id) ].
1✔
225

1✔
226
                mapping
1✔
227
                        mapProperty: #completed_at
1✔
228
                        getter: [ :object | #ignore ]
1✔
229
                        setter: [ :job :value |
1✔
230
                                value ifNotNil: [ job cacheAt: #completed_at put: (value asDateAndTime ) ] ].
1✔
231
                        
1✔
232
                        mapping
1✔
233
                        mapProperty: #started_at
1✔
234
                        getter: [ :object | #ignore ]
1✔
235
                        setter: [ :job :value |
1✔
236
                                value ifNotNil: [ job cacheAt: #started_at put: (value asDateAndTime ) ] ] ]
1✔
237
]
1✔
238

239
{ #category : #'private - configure reader' }
240
GithubModelImporter >> configureReaderForMergeRequest: reader [
1✔
241

1✔
242
        super configureReaderForMergeRequest: reader.
1✔
243
        
1✔
244
        reader for: GLHMergeRequest do: [ :mapping |
1✔
245
                (mapping mapInstVar: #created_at) valueSchema: DateAndTime.
1✔
246
                (mapping mapInstVar: #updated_at) valueSchema: DateAndTime.
1✔
247
                (mapping mapInstVar: #merged_at) valueSchema: DateAndTime.
1✔
248
                (mapping mapInstVar: #closed_at) valueSchema: DateAndTime.
1✔
249

1✔
250
                mapping
1✔
251
                        mapProperty: #author
1✔
252
                        getter: [  ]
1✔
253
                        setter: [ :object :value |
1✔
254
                        object cacheAt: #authorID put: (value at: #id) ].
1✔
255
                mapping
1✔
256
                        mapProperty: #merge_user
1✔
257
                        getter: [  ]
1✔
258
                        setter: [ :object :value |
1✔
259
                                value ifNotNil: [
1✔
260
                                        object cacheAt: #mergeUserID put: (value at: #id) ] ] ].
1✔
261

1✔
262

1✔
263

1✔
264
]
1✔
265

266
{ #category : #'private - configure reader' }
267
GithubModelImporter >> configureReaderForPipeline: reader [
1✔
268

1✔
269
        super configureReaderForPipeline: reader.
1✔
270

1✔
271
        reader
1✔
272
                for: GLHPipeline
1✔
273
                do: [ :mapping | "mapping mapInstVar: #status to: #conclusion."
1✔
274
                        
1✔
275
                (mapping mapInstVar: #created_at) valueSchema: DateAndTime.
1✔
276
                (mapping mapInstVar: #updated_at) valueSchema: DateAndTime.
1✔
277
                        
1✔
278
                        mapping
1✔
279
                                mapProperty: #status
1✔
280
                                getter: [ :object | #ignore ]
1✔
281
                                setter: [ :object :value |
1✔
282
                                        (object status isNil and: [ value isNotNil ]) ifTrue: [
1✔
283
                                                object status: value ] ].
1✔
284

1✔
285
                        mapping
1✔
286
                                mapProperty: #conclusion
1✔
287
                                getter: [ :object | #ignore ]
1✔
288
                                setter: [ :object :value |
1✔
289
                                        (object status isNil and: [ value isNotNil ]) ifTrue: [
1✔
290
                                                object status: value ] ].
1✔
291

1✔
292
                        mapping
1✔
293
                                mapProperty: #run_started_at
1✔
294
                                getter: [ :object | #ignore ]
1✔
295
                                setter: [ :object :value |
1✔
296
                                object runDate: (DateAndTime fromString: value) ] ]
1✔
297
]
1✔
298

299
{ #category : #'private - configure reader' }
300
GithubModelImporter >> configureReaderForProject: reader [
1✔
301

1✔
302
        super configureReaderForProject: reader.
1✔
303
        
1✔
304
        reader for: GLHProject do: [ :mapping |
1✔
305
                mapping mapInstVar: #web_url to: #html_url.
1✔
306
         ].
1✔
307

1✔
308
]
1✔
309

310
{ #category : #'private - configure reader' }
311
GithubModelImporter >> configureReaderForUser: reader [
1✔
312
        super configureReaderForUser: reader.
1✔
313
        
1✔
314
        
1✔
315
                reader for: GLHUser do: [ :mapping |
1✔
316
                mapping mapInstVar: #public_email to: #email.
1✔
317
                mapping mapInstVar: #username to: #login.
1✔
318
                mapping mapInstVar: #bio to: #bio.
1✔
319
                mapping mapInstVar: #organization to: #company.
1✔
320
                mapping mapInstVar: #web_url to: #html_url.
1✔
321
 ].
1✔
322
]
1✔
323

324
{ #category : #private }
325
GithubModelImporter >> convertApiFileAsFile: aAPIFile [
×
326

×
327
        aAPIFile type = 'dir' ifTrue: [ 
×
328
                ^ GLHFileDirectory new
×
329
                          name: aAPIFile name;
×
330
                          yourself ].
×
331
        ^ GLHFileBlob new
×
332
                  name: aAPIFile name;
×
333
                  yourself
×
334
]
×
335

336
{ #category : #'import - groups' }
337
GithubModelImporter >> ensureGroupNamed: aGroupName [
×
338

×
NEW
339
        self flag: 'WARNING: group from different platform (github vs gitlab) can share the same name, thus being confused here'. 
×
340
        ^ self glhModel
×
341
                  detect: [ :a |
×
342
                  (a isKindOf: GLHGroup) and: [ a name = aGroupName ] ]
×
343
                  ifNone: [ self glhModel newGroupNamed: aGroupName ]
×
344
]
×
345

346
{ #category : #'import - branches' }
347
GithubModelImporter >> importBranchesOf: aGLHProject [
1✔
348
        "add the pipeline (actions runs) in the project"
1✔
349

1✔
350
        | branchesResults foundBranches branches |
1✔
351
        self
1✔
352
                deprecated: 'Use importBranchesOfProject: instead of current one'
1✔
353
                on: '26 September 2025'
1✔
354
                in:
1✔
355
                'Pharo-12.0.0+SNAPSHOT.build.1571.sha.cf5fcd22e66957962c97dffc58b0393b7f368147 (64 Bit)'.
1✔
356
        branchesResults := self repoApi branches
1✔
357
                                   getAllForRepo: aGLHProject name
1✔
358
                                   ofOwner: aGLHProject group name.
1✔
359

1✔
360
        foundBranches := (branchesResults collect: [ :branchesResult |
1✔
361
                                  self parseBranchesResult: branchesResult ])
1✔
362
                                 flattened.
1✔
363

1✔
364

1✔
365
        "WARNING: always add branch first into repository, than into model !"
1✔
366
        branches := aGLHProject repository branches
1✔
367
                            addAll: foundBranches
1✔
368
                            unless: self blockOnNameEquality.
1✔
369

1✔
370
        "branch HEAD commit is not imported by default. use branch ref (sha) to import it specifically"
1✔
371

1✔
372
        branches := self glhModel
1✔
373
                            addAll: branches
1✔
374
                            unless: self blockForBranchEquality.
1✔
375

1✔
376
        self withFiles ifTrue: [
1✔
377
                branches do: [ :branch | self importFilesOfBranch: branch ] ].
1✔
378

1✔
379
        ^ branches
1✔
380
]
1✔
381

382
{ #category : #'import - repositories' }
NEW
383
GithubModelImporter >> importBranchesOfProject: aGLHProject [
×
384
        "add the pipeline (actions runs) in the project"
×
385

×
NEW
386
        | branchesResults foundBranches branches |
×
NEW
387
        branchesResults := self repoApi branches
×
NEW
388
                                   getAllForRepo: aGLHProject name
×
NEW
389
                                   ofOwner: aGLHProject group name.
×
NEW
390

×
NEW
391
        foundBranches := (branchesResults collect: [ :branchesResult |
×
NEW
392
                                  self parseBranchesResult: branchesResult ])
×
NEW
393
                                 flattened.
×
NEW
394

×
NEW
395

×
NEW
396
        "WARNING: always add branch first into repository, than into model !"
×
NEW
397
        branches := aGLHProject repository branches
×
NEW
398
                            addAll: foundBranches
×
NEW
399
                            unless: self blockOnNameEquality.
×
NEW
400

×
NEW
401
        "branch HEAD commit is not imported by default. use branch ref (sha) to import it specifically"
×
NEW
402

×
NEW
403
        branches := self glhModel
×
NEW
404
                            addAll: branches
×
NEW
405
                            unless: self blockForBranchEquality.
×
NEW
406

×
NEW
407
        self withFiles ifTrue: [
×
NEW
408
                branches do: [ :branch | self importFilesOfBranch: branch ] ].
×
NEW
409

×
NEW
410
        ^ branches
×
UNCOV
411
]
×
412

413
{ #category : #'import - commits' }
414
GithubModelImporter >> importCommit: aCommitID ofProject: aGLHProject [
1✔
415

1✔
416
        | result parsedResult |
1✔
417
        (self glhModel allWithType: GLHCommit) asOrderedCollection
1✔
418
                detect: [ :commit | commit id = aCommitID ]
1✔
419
                ifFound: [ :commit | ^ commit ].
1✔
420

1✔
421
        result := self repoApi commits
1✔
422
                          get: aCommitID
1✔
423
                          inProject: aGLHProject id.
1✔
424

1✔
425
        parsedResult := self parseCommitResult: result.
1✔
426

1✔
427
        parsedResult := self glhModel
1✔
428
                                add: parsedResult
1✔
429
                                unless: self blockOnIdEquality.
1✔
430
        parsedResult := aGLHProject repository commits
1✔
431
                                add: parsedResult
1✔
432
                                unless: self blockOnIdEquality.
1✔
433

1✔
434
        self withCommitDiffs ifTrue: [ self importDiffOfCommit: parsedResult ].
1✔
435

1✔
436
        ^ parsedResult
1✔
437
]
1✔
438

439
{ #category : #'import - commits' }
440
GithubModelImporter >> importCommitsOfProject: aGLHProject [
1✔
441

1✔
442
        | itemByPage foundCommits tmp pageNumber |
1✔
443
        itemByPage := 100.
1✔
444
        pageNumber := 1.
1✔
445
        ('Extract all commits of ' , aGLHProject name) recordInfo.
1✔
446
        foundCommits := OrderedCollection new.
1✔
447
        ('Extract commits from ' , foundCommits size printString , ' to '
1✔
448
         , (foundCommits size + itemByPage) printString) recordInfo.
1✔
449
        "also check that there is at least one commit with the error handling"
1✔
450
        [
1✔
451
        tmp := self parseCommitsResult: (self repoApi commits
1✔
452
                                getForRepo: aGLHProject name
1✔
453
                                ofOwner: aGLHProject group name
1✔
454
                                withParms: {
1✔
455
                                                (#since -> self withCommitsSince).
1✔
456
                                                (#perPage -> itemByPage).
1✔
457
                                                (#page -> pageNumber) } asDictionary) ]
1✔
458
                on: GHRepositoryEmptyError
1✔
459
                do: [ ^ {  } ].
1✔
460

1✔
461
        foundCommits addAll: tmp.
1✔
462
        [ tmp size = itemByPage ] whileTrue: [
1✔
463
                pageNumber := pageNumber + 1.
1✔
464
                ('Extract issues from ' , foundCommits size printString , ' to '
1✔
465
                 , (foundCommits size + itemByPage) printString) recordInfo.
1✔
466
                tmp := self parseCommitsResult: (self repoApi commits
1✔
467
                                        getForRepo: aGLHProject name
1✔
468
                                        ofOwner: aGLHProject group name
1✔
469
                                        withParms: {
1✔
470
                                                        (#sine -> self withCommitsSince).
1✔
471
                                                        (#perPage -> itemByPage).
1✔
472
                                                        (#page -> pageNumber) } asDictionary).
1✔
473
                foundCommits addAll: tmp ].
1✔
474

1✔
475
        "add the imported commits (unless they are already added to this repository)"
1✔
476
        aGLHProject repository commits
1✔
477
                addAll: foundCommits
1✔
478
                unless: [ :existing :new | existing id = new id ].
1✔
479
        "add the imported commits to the model unles they are already added to the model"
1✔
480
        ^ self glhModel
1✔
481
                  addAll: foundCommits
1✔
482
                  unless: [ :existing :new | existing id = new id ]
1✔
483
]
1✔
484

485
{ #category : #'import - commits' }
486
GithubModelImporter >> importCreatorOfCommit: aGLHCommit [
×
487

×
488
        | creator |
×
489
        (self glhModel allWithType: GLHUser)
×
490
                detect: [ :user | user username = aGLHCommit author_name ]
×
491
                ifFound: [ :user |
×
492
                        aGLHCommit commitCreator: user.
×
493
                        ^ user ].
×
494

×
495
        aGLHCommit author_name ifNotNil: [ :author_name |
×
496
                creator := self importUserByUsername: author_name.
×
497
                aGLHCommit commitCreator: creator ].
×
498
        ^ creator
×
499
]
×
500

501
{ #category : #'import - diffs' }
502
GithubModelImporter >> importDiffOfCommit: aGLHCommit [
1✔
503

1✔
504
        | result diffs |
1✔
505
        aGLHCommit diffs ifNotEmpty: [
1✔
506
                'Diff already importer: '
1✔
507
                , aGLHCommit short_id printString recordInfo.
1✔
508
                ^ aGLHCommit diffs ].
1✔
509
        ('Import diff of commit: ' , aGLHCommit short_id printString)
1✔
510
                recordInfo.
1✔
511

1✔
512
        result := self repoApi commits
1✔
513
                          getCommit: aGLHCommit id
1✔
514
                          ForRepo: aGLHCommit repository project name
1✔
515
                          ofOwner: aGLHCommit repository project group name.
1✔
516
                
1✔
517
        diffs := (self parseCommitResult: result) diffs.
1✔
518
        
1✔
519
        diffs do: [ :diff | 
1✔
520
                self parseDiffString: diff.
1✔
521
                ].        
1✔
522

1✔
523
        diffs := aGLHCommit diffs
1✔
524
                         addAll: diffs
1✔
525
                         unless: self blockForDiffRangeEquality.
1✔
526
        glhModel
1✔
527
                         addAll: diffs
1✔
528
                         unless: self blockForDiffRangeEquality.
1✔
529

1✔
530
        ^ aGLHCommit diffs
1✔
531
]
1✔
532

533
{ #category : #'import - merge-requests' }
534
GithubModelImporter >> importDiffOfMergeRequest: aGLHMergeRequest [ 
1✔
535
        |diffsResult|
1✔
536
        
1✔
537
        diffsResult := self importDiffOfCommit: aGLHMergeRequest mergedCommit.
1✔
538
        
1✔
539
        diffsResult := aGLHMergeRequest diffs
1✔
540
                addAll: diffsResult
1✔
541
                unless: self blockForDiffEquality.
1✔
542
        self glhModel
1✔
543
                addAll: diffsResult
1✔
544
                unless: self blockForDiffEquality.
1✔
545

1✔
546
        aGLHMergeRequest diffs do: [ :diff | self importDiffRangesForDiff: diff ].
1✔
547
        ^ aGLHMergeRequest diffs
1✔
548
]
1✔
549

550
{ #category : #'import - files' }
551
GithubModelImporter >> importDirectoryFiles: aDirectoryFile OfBranch: aBranch [
×
552

×
553
        | result files apiFiles |
×
554
        ('Explore ' , aDirectoryFile name) recordInfo.
×
555
        result := self api
×
556
                          contentsOfRepo: aBranch repository project name
×
557
                          ofOrganization: aBranch repository project group name
×
558
                          inBranch: aBranch name
×
559
                          withPath: aDirectoryFile path.
×
560
        apiFiles := self parseFileTreeResult: result.
×
561
        files := apiFiles collect: [ :apiFile | 
×
562
                         self convertApiFileAsFile: apiFile ].
×
563
        files do: [ :file | 
×
564
                self glhModel add: file.
×
565
                aDirectoryFile addFile: file ].
×
566
        files
×
567
                select: [ :file | file isKindOf: GLHFileDirectory ]
×
568
                thenCollect: [ :file | 
×
569
                self importDirectoryFiles: file OfBranch: aBranch ]
×
570
]
×
571

572
{ #category : #'import - files' }
573
GithubModelImporter >> importFilesOfBranch: aBranch [
×
574

×
575
        | result files apiFiles |
×
576
        result := self api
×
577
                          contentsOfRepo: aBranch repository project name
×
578
                          ofOrganization: aBranch repository project group name
×
579
                          inBranch: aBranch name
×
580
                          withPath: nil.
×
581
        apiFiles := self parseFileTreeResult: result.
×
582
        files := apiFiles collect: [ :apiFile | 
×
583
                         self convertApiFileAsFile: apiFile ].
×
584
        files do: [ :file | 
×
585
                self glhModel add: file.
×
586
                aBranch addFile: file ].
×
587
        files
×
588
                select: [ :file | file isKindOf: GLHFileDirectory ]
×
589
                thenCollect: [ :file | 
×
NEW
590
                self importDirectoryFiles: file OfBranch: aBranch ].
×
NEW
591
        ^ files
×
UNCOV
592
]
×
593

594
{ #category : #'import - groups' }
595
GithubModelImporter >> importGroup: aGroupName [
1✔
596

1✔
597
        | result groupResult |
1✔
598
        result := self repoApi organizations get: aGroupName.
1✔
599
        groupResult := self parseGroupResult: result.
1✔
600
        self glhModel add: groupResult.
1✔
601
        self importRepositoriesOfGroup: groupResult.
1✔
602
        ^ groupResult
1✔
603
]
1✔
604

605
{ #category : #'import - issues' }
NEW
606
GithubModelImporter >> importIssuesOfProject: aGLHProject [
×
NEW
607

×
NEW
608
        | results issues foundIssues |
×
NEW
609
        results := self repoApi issues
×
NEW
610
                           getAllForRepo: aGLHProject name
×
NEW
611
                           ofOwner: aGLHProject group name
×
NEW
612
                           withParms: Dictionary new.
×
NEW
613
        foundIssues := (results collect: [ :result |
×
NEW
614
                                self parseIssuesResult: result ]) flattened.
×
NEW
615

×
NEW
616

×
NEW
617
        issues := OrderedCollection new.
×
NEW
618
        issues := foundIssues collect: [ :issue | 
×
NEW
619
                
×
NEW
620
                issue author:
×
NEW
621
                        (self importUser: (issue cacheAt: #authorID ifAbsent: [ '' ])).
×
NEW
622

×
NEW
623
                issue assignees
×
NEW
624
                        addAll:
×
NEW
625
                                ((issue cacheAt: #assigneesID ifAbsent: [ {  } ]) collect: [
×
NEW
626
                                         :assigneeID | self importUser: assigneeID ])
×
NEW
627
                        unless: self blockOnIdEquality. 
×
NEW
628
                        issue. 
×
NEW
629
                        
×
NEW
630
                ].
×
NEW
631

×
NEW
632
        
×
NEW
633
        issues := aGLHProject issues
×
NEW
634
                          addAll: issues
×
NEW
635
                          unless: self blockOnIdEquality.
×
NEW
636
        
×
NEW
637
        glhModel addAll: issues unless: self blockOnIdEquality.
×
NEW
638

×
NEW
639

×
NEW
640
        ^ aGLHProject issues
×
NEW
641
]
×
642

643
{ #category : #'import - jobs' }
NEW
644
GithubModelImporter >> importJobsOfPipeline: aGLHPipeline [
×
NEW
645

×
NEW
646
        | result jobs |
×
NEW
647
        result := self repoApi actions
×
NEW
648
                          getAllJobsForRun: aGLHPipeline id
×
NEW
649
                          forRepo: aGLHPipeline project name
×
NEW
650
                          ofOwner: aGLHPipeline project group name.
×
NEW
651

×
NEW
652
        jobs := (self parsePipelinesResult: result) jobs.
×
NEW
653

×
NEW
654
        jobs do: [ :job |
×
NEW
655
                |stop start|
×
NEW
656
                stop := job cacheAt: #completed_at ifAbsent: [ nil ].
×
NEW
657
                start := job cacheAt: #started_at ifAbsent: [ nil ].
×
NEW
658
                job duration: (stop - start) asDuration . 
×
NEW
659
        ].
×
NEW
660

×
NEW
661
        jobs := glhModel addAll: jobs unless: self blockOnIdEquality.
×
NEW
662
        aGLHPipeline jobs addAll: jobs unless: self blockOnIdEquality.
×
NEW
663

×
NEW
664

×
NEW
665
        ^ aGLHPipeline jobs
×
NEW
666
]
×
667

668
{ #category : #'import - commits' }
669
GithubModelImporter >> importLatestCommitsOfProject: aGLHProject [
1✔
670
        "limited to the last 50 commits"
1✔
671

1✔
672
        | results parsedResults |
1✔
673
        results := self repoApi commits
1✔
674
                           getLatestForRepo: aGLHProject name
1✔
675
                           ofOwner: aGLHProject group name.
1✔
676
        parsedResults := self parseCommitsResult: results.
1✔
677
        
1✔
678
        
1✔
679
        parsedResults := self glhModel
1✔
680
                                 addAll: parsedResults
1✔
681
                                 unless: self blockOnIdEquality.
1✔
682

1✔
683
        aGLHProject repository commits
1✔
684
                addAll: parsedResults
1✔
685
                unless: self blockOnIdEquality.
1✔
686

1✔
687
        self withCommitDiffs ifTrue: [
1✔
688
                parsedResults do: [ :commit | 
1✔
689
                        self importDiffOfCommit: commit. 
1✔
690
                        
1✔
691
                         ] ].
1✔
692

1✔
693
        ^ parsedResults
1✔
694
]
1✔
695

696
{ #category : #'import - merge-requests' }
697
GithubModelImporter >> importLatestMergeRequestsOfProject: aGLHProject [ 
1✔
698
        
1✔
699
        | results parsedResults |
1✔
700
        results := self repoApi pullRequests getLatestForRepo: aGLHProject name ofOwner:  aGLHProject group name.
1✔
701
        parsedResults := self parseMergeRequestsResult: results.
1✔
702

1✔
703
        parsedResults := aGLHProject mergeRequests
1✔
704
                                 addAll: parsedResults
1✔
705
                                 unless: self blockOnIdEquality.
1✔
706
        parsedResults := glhModel
1✔
707
                                 addAll: parsedResults
1✔
708
                                 unless: self blockOnIdEquality.
1✔
709
        ^ parsedResults
1✔
710
]
1✔
711

712
{ #category : #'import - merge-requests' }
NEW
713
GithubModelImporter >> importLatestPullRequestsOfProject: aGLHProject [
×
NEW
714
        "alias method since PullRequest = MergeRequest in model"
×
NEW
715
        ^ self importLatestMergeRequestsOfProject: aGLHProject 
×
NEW
716
]
×
717

718
{ #category : #'import - merge-requests' }
719
GithubModelImporter >> importMergeRequestMergeCommits: aGLHMergeRequest [
1✔
720

1✔
721
        | foundCommits |
1✔
722
        foundCommits := OrderedCollection new.
1✔
723

1✔
724
        ('Import commit sha of MR:  ' , aGLHMergeRequest iid printString)
1✔
725
                recordInfo.
1✔
726
        "the founds commits are added to the model during their respective import"
1✔
727
        aGLHMergeRequest mergeRequestCommit: ((self
1✔
728
                          importCommit: aGLHMergeRequest sha
1✔
729
                          ofProject: aGLHMergeRequest project) ifNotNil: [ :commit |
1✔
730
                         foundCommits add: commit ]).
1✔
731

1✔
732
        ('Import commit merge_commit_sha of MR:  '
1✔
733
         , aGLHMergeRequest iid printString) recordInfo.
1✔
734
        aGLHMergeRequest mergedCommit: ((self
1✔
735
                          importCommit: aGLHMergeRequest merge_commit_sha
1✔
736
                          ofProject: aGLHMergeRequest project) ifNotNil: [ :commit |
1✔
737
                         foundCommits add: commit ]).
1✔
738

1✔
739
        ('Import commit squash_commit_sha of MR:  '
1✔
740
         , aGLHMergeRequest iid printString) recordInfo.
1✔
741
        aGLHMergeRequest squashCommit: ((self
1✔
742
                          importCommit: aGLHMergeRequest squash_commit_sha
1✔
743
                          ofProject: aGLHMergeRequest project) ifNotNil: [ :commit |
1✔
744
                         foundCommits add: commit ]).
1✔
745

1✔
746

1✔
747
        self chainsCommitsFrom: foundCommits.
1✔
748
        ^ foundCommits
1✔
749
]
1✔
750

751
{ #category : #'import - merge-requests' }
752
GithubModelImporter >> importMergeRequestsOfProject: aGLHProject [
1✔
753

1✔
754
        | response mergeRequests |
1✔
755
        response := self repoApi pullRequests
1✔
756
                            getLatestForRepo: aGLHProject name
1✔
757
                            ofOwner: aGLHProject group name.
1✔
758
        mergeRequests := self parseMergeRequestsResult: response.
1✔
759

1✔
760
        mergeRequests := aGLHProject mergeRequests
1✔
761
                                 addAll: mergeRequests
1✔
762
                                 unless: self blockOnIdEquality.
1✔
763
                
1✔
764
        "gets it related commits"
1✔
765
        aGLHProject mergeRequests do: [ :mr |
1✔
766
                self importMergeRequestMergeCommits: mr ].
1✔
767

1✔
768

1✔
769
        self withCommitDiffs ifTrue: [
1✔
770
                aGLHProject mergeRequests do: [ :mr |
1✔
771
                        self importDiffOfMergeRequest: mr ] ].
1✔
772
        
1✔
773
        ^ mergeRequests
1✔
774
]
1✔
775

776
{ #category : #'import - pipelines' }
777
GithubModelImporter >> importPipeline: aPipelineId OfProject: aGLHProject [
1✔
778

1✔
779
        "import specific actions' run "
1✔
780
        | reponse result |
1✔
781
        aGLHProject pipelines
1✔
782
                detect: [ :p | p id = aPipelineId ]
1✔
783
                ifFound: [ :p | ^ p ]
1✔
784
                ifNone: [  ].
1✔
785

1✔
786
        reponse := self repoApi actions
1✔
787
                           getRun: aPipelineId
1✔
788
                           forRepo: aGLHProject name
1✔
789
                           ofOwner: aGLHProject group name.
1✔
790
        result := self parsePipelineResult: reponse.
1✔
791

1✔
792
        result := self glhModel add: result unless: self blockOnIdEquality.
1✔
793
        result := aGLHProject pipelines
1✔
794
                          add: result
1✔
795
                          unless: self blockOnIdEquality.
1✔
796

1✔
797
        ^ result
1✔
798
]
1✔
799

800
{ #category : #'import - pipelines' }
801
GithubModelImporter >> importPipelinesOfMergeRequest: aGLHMergeRequest [ 
1✔
802
        |result pipelines|
1✔
803
        result := self repoApi actions getAllRunsForRepo: aGLHMergeRequest project name ofOwner: aGLHMergeRequest project group name withParms: { #event->'pull_request' . #head_sha -> aGLHMergeRequest sha } asDictionary .
1✔
804
        
1✔
805
        
1✔
806
        pipelines := (self parsePipelinesResult: result) workflow_runs .
1✔
807
        
1✔
808
        pipelines := aGLHMergeRequest project pipelines addAll: pipelines unless: self blockOnIdEquality.
1✔
809
        
1✔
810
        pipelines := glhModel addAll: pipelines unless:  self blockOnIdEquality. 
1✔
811
        pipelines := aGLHMergeRequest pipelines addAll: pipelines unless: self blockOnIdEquality. 
1✔
812
        
1✔
813
        
1✔
814
        
1✔
815
        ^ pipelines 
1✔
816
]
1✔
817

818
{ #category : #'import - pipelines' }
819
GithubModelImporter >> importPipelinesOfProject: project [
1✔
820

1✔
821
        "add the pipeline (actions runs) in the project"
1✔
822

1✔
823
        | pipelinesResult ghApiPipelineOverview |
1✔
824
        pipelinesResult := self repoApi actions
1✔
825
                                   getLatestForRepo: project name
1✔
826
                                   ofOwner: project group name.
1✔
827
        ghApiPipelineOverview := self parsePipelinesResult: pipelinesResult.
1✔
828
        ghApiPipelineOverview workflow_runs do: [ :pipeline | 
1✔
829
                project addPipeline: pipeline ]
1✔
830
]
1✔
831

832
{ #category : #'import - projects' }
833
GithubModelImporter >> importProject: aProjectName ofGroup: aGroupName [
×
834

×
835
        | result projectResult group |
×
836
        group := self ensureGroupNamed: aGroupName.
×
NEW
837
        result := self repoApi organizations getRepository: aProjectName ofOrganization: aGroupName .
×
838
        projectResult := self parseProjectResult: result.
×
839
        projectResult group: group.
×
840
        self glhModel add: projectResult.
×
841
        self completeImportedProject: projectResult.
×
842
        ^ projectResult
×
843
]
×
844

845
{ #category : #'import - merge-requests' }
NEW
846
GithubModelImporter >> importPullRequestsOfProject: aProject [
×
NEW
847
        "alias method since PullRequest = MergeRequest in model"
×
NEW
848

×
NEW
849
        ^ self importMergeRequestsOfProject: aProject
×
NEW
850
]
×
851

852
{ #category : #'import - groups' }
853
GithubModelImporter >> importRepositoriesOfGroup: groupResult [
1✔
854
        "Github Repository = GLHProject"
1✔
855

1✔
856
        | reposResult itemByPage pageNumber reposFound tmp |
1✔
857
        itemByPage := 100.
1✔
858
        pageNumber := 1.
1✔
859
        ('Extract all repository of ' , groupResult name) recordInfo.
1✔
860
        reposFound := OrderedCollection new.
1✔
861
        ('Extract commits from ' , reposFound size printString , ' to '
1✔
862
         , (reposFound size + itemByPage) printString) recordInfo.
1✔
863
        tmp := self parseArrayOfProject: (self repoApi
1✔
864
                                organizations getRepositoriesOfOrganization: groupResult name
1✔
865
                                perPage: itemByPage
1✔
866
                                page: pageNumber).
1✔
867

1✔
868
        reposFound addAll: tmp.
1✔
869
        [ tmp size = itemByPage ] whileTrue: [
1✔
870
                pageNumber := pageNumber + 1.
1✔
871
                ('Extract issues from ' , reposFound size printString , ' to '
1✔
872
                 , (reposFound size + itemByPage) printString) recordInfo.
1✔
873
                tmp := self parseArrayOfProject: (self repoApi
1✔
874
                                        reposOfOrganization: groupResult name
1✔
875
                                        perPage: itemByPage
1✔
876
                                        page: pageNumber).
1✔
877
                reposFound addAll: tmp ].
1✔
878

1✔
879
        reposResult := self repoApi organizations getRepositoriesOfOrganization: groupResult name.
1✔
880
        groupResult projects addAll: reposFound.
1✔
881
        self glhModel addAll: groupResult projects.
1✔
882
        groupResult projects do: [ :project |
1✔
883
                self completeImportedProject: project ].
1✔
884
        ^ groupResult
1✔
885
]
1✔
886

887
{ #category : #'import - users' }
888
GithubModelImporter >> importUser: userID [
1✔
889

1✔
890
        | result userResult |
1✔
891
        (glhModel allWithType: GLHUser)
1✔
892
                detect: [ :user | user id = userID ]
1✔
893
                ifFound: [ :user | ^ user ].
1✔
894
        ('Import user: ' , userID printString) recordInfo.
1✔
895
        result := self repoApi users getUserId: userID.
1✔
896
        userResult := self parseUserResult: result.
1✔
897
        ^ glhModel
1✔
898
                  add: userResult
1✔
899
                  unless: [ :current :new | current id = new id ]
1✔
900
]
1✔
901

902
{ #category : #'import - users' }
NEW
903
GithubModelImporter >> importUserByUsername: anUsername [
×
NEW
904

×
NEW
905
        | dicUsername resultUser |
×
NEW
906
        dicUsername := ((self glhModel allWithType: GLHUser) collect: [ :user |
×
NEW
907
                                user username -> user ]) asSet asDictionary.
×
NEW
908

×
NEW
909
        dicUsername addAll: self userCatalogue collectUsernames.
×
NEW
910

×
NEW
911

×
NEW
912
        resultUser := dicUsername
×
NEW
913
                              at: anUsername
×
NEW
914
                              ifAbsent: [ "thus we have to import this new user"
×
NEW
915
                                      | userId searchResult |
×
NEW
916
                                      ('Import user with username: '
×
NEW
917
                                       , anUsername printString) recordInfo.
×
NEW
918

×
NEW
919
                                      searchResult := self repoApi users getUsername: anUsername.
×
NEW
920

×
NEW
921
                                      (searchResult class = Dictionary and: [
×
NEW
922
                                               (searchResult at: #status) includesSubstring:
×
NEW
923
                                                       '404' ])
×
NEW
924
                                              ifTrue: [ "if the result is an 403 error we fake a new user"
×
NEW
925
                                                      self glhModel
×
NEW
926
                                                              add: (GLHUser new
×
NEW
927
                                                                               username: anUsername;
×
NEW
928
                                                                               name: anUsername;
×
NEW
929
                                                                               yourself)
×
NEW
930
                                                              unless: [ :nu :ou | nu username = ou username ] ]
×
NEW
931
                                              ifFalse: [
×
NEW
932
                                                      searchResult
×
NEW
933
                                                              ifEmpty: [ "results can be empty thus we force a new user with the info we have "
×
NEW
934
                                                                      self glhModel
×
NEW
935
                                                                              add: (GLHUser new
×
NEW
936
                                                                                               username: anUsername;
×
NEW
937
                                                                                               name: anUsername;
×
NEW
938
                                                                                               yourself)
×
NEW
939
                                                                              unless: [ :nu :ou | nu username = ou username ] ]
×
NEW
940
                                                              ifNotEmpty: [ "because we may already have the researched user, we look by ID in the model"
×
NEW
941
                                                                      userId := searchResult first at: #id.
×
NEW
942
                                                                      (self glhModel allWithType: GLHUser)
×
NEW
943
                                                                              detect: [ :user | user id = userId ]
×
NEW
944
                                                                              ifNone: [ self importUser: userId ] ] ] ].
×
NEW
945

×
NEW
946
        self userCatalogue addUser: resultUser withName: anUsername.
×
NEW
947

×
NEW
948
        ^ resultUser
×
NEW
949
]
×
950

951
{ #category : #initialization }
952
GithubModelImporter >> initReader [
1✔
953

1✔
954
        super initReader. 
1✔
955
]
1✔
956

957
{ #category : #initialization }
958
GithubModelImporter >> initialize [
1✔
959

1✔
960
        super initialize.
1✔
961
        self repoApi: GithubApi new.
1✔
962
        self repoApi output: 'json'.
1✔
963
        self withCommitDiffs: true.
1✔
964
        withFiles := false
1✔
965
]
1✔
966

967
{ #category : #parsing }
968
GithubModelImporter >> parseArrayOfProject: arrayOfProjects [
1✔
969

1✔
970
        | reader |
1✔
971
        " reader := NeoJSONReader on: arrayOfProjects readStream.
1✔
972
        
1✔
973
        reader
1✔
974
                for: #ArrayOfProjects
1✔
975
                customDo: [ :customMappting | 
1✔
976
                customMappting listOfElementSchema: GLHProject ].
1✔
977
        
1✔
978
        reader for: GLHProject do: [ :mapping | 
1✔
979
                mapping mapInstVar: #name to: #name.
1✔
980
                mapping mapInstVar: #description to: #description.
1✔
981
                mapping mapInstVar: #id to: #id.
1✔
982
                mapping mapInstVar: #archived to: #archived.
1✔
983
                mapping mapInstVar: #web_url to: #html_url.
1✔
984
                mapping mapInstVar: #topics to: #topics ].
1✔
985
        ^ reader nextAs: #ArrayOfProjects
1✔
986
        "
1✔
987
        reader := generalReader on: arrayOfProjects readStream.
1✔
988

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

992
{ #category : #parsing }
993
GithubModelImporter >> parseBranchesResult: arrayOfBranch [
1✔
994

1✔
995
        | reader |
1✔
996
        reader := generalReader on: arrayOfBranch readStream.
1✔
997

1✔
998
        ^ reader nextAs: #ArrayOfBranch
1✔
999
]
1✔
1000

1001
{ #category : #parsing }
1002
GithubModelImporter >> parseCommitResult: result [
1✔
1003
        | reader |
1✔
1004
        
1✔
1005
        reader := generalReader on: result readStream.
1✔
1006

1✔
1007
        ^ reader nextAs: GLHCommit 
1✔
1008
]
1✔
1009

1010
{ #category : #parsing }
1011
GithubModelImporter >> parseCommitsResult: result [
1✔
1012

1✔
1013
        | reader |
1✔
1014
        (result includesSubstring: '"status":"409"') ifTrue: [
1✔
1015
                GHRepositoryEmptyError signal: 'Git Repository is empty' ].
1✔
1016

1✔
1017
        reader := generalReader on: result readStream.
1✔
1018

1✔
1019
        ^ reader nextAs: #ArrayOfCommit
1✔
1020
]
1✔
1021

1022
{ #category : #parsing }
1023
GithubModelImporter >> parseDiffresult: response [
×
1024

×
1025
        | result |
×
1026
        result := (response at: #files) collect: [ :file |
×
1027
                          GLHDiff new
×
1028
                                  diffString: (file at: #patch);
×
1029
                                  old_path: (file at: #filename);
×
1030
                                  new_path: (file at: #filename) ].
×
1031

×
1032
        ^ result
×
1033
]
×
1034

1035
{ #category : #parsing }
1036
GithubModelImporter >> parseFileTreeResult: aResult [
×
1037

×
1038
        | reader |
×
1039
        reader := NeoJSONReader on: aResult readStream.
×
1040
        reader mapInstVarsFor: GHApiFile.
×
1041
        reader
×
1042
                for: #ArrayOfFile
×
1043
                customDo: [ :customMappting | 
×
1044
                customMappting listOfElementSchema: GHApiFile ].
×
1045
        ^ reader nextAs: #ArrayOfFile
×
1046
]
×
1047

1048
{ #category : #parsing }
1049
GithubModelImporter >> parseGroupResult: aResult [
1✔
1050

1✔
1051
        | reader |
1✔
1052
        reader := generalReader on: aResult readStream.
1✔
1053
        
1✔
1054
        ^ reader nextAs: GLHGroup
1✔
1055
]
1✔
1056

1057
{ #category : #parsing }
NEW
1058
GithubModelImporter >> parseIssuesResult: result [ 
×
NEW
1059
        
×
NEW
1060
        ^ (generalReader on: result readStream) nextAs: #ArrayOfIssue 
×
NEW
1061
]
×
1062

1063
{ #category : #parsing }
1064
GithubModelImporter >> parseMergeRequestsResult: response [
1✔
1065

1✔
1066
        | result json|
1✔
1067
        self flag: 'temp version, must remade using NeoJsonReader'.
1✔
1068
        json := NeoJSONReader fromString: response.
1✔
1069
        
1✔
1070
        result := json collect: [ :aPull |
1✔
1071
                          GLHMergeRequest new
1✔
1072
                                  id: (aPull at: #id);
1✔
1073
                                  title: (aPull at: #title);
1✔
1074
                                  state: (aPull at: #state);
1✔
1075
                                  closed_at:
1✔
1076
                                          ((aPull at: #closed_at) ifNotNil: #asDateAndTime);
1✔
1077
                                  merged_at:
1✔
1078
                                          ((aPull at: #merged_at) ifNotNil: #asDateAndTime);
1✔
1079
                                  updated_at:
1✔
1080
                                          ((aPull at: #updated_at) ifNotNil: #asDateAndTime);
1✔
1081
                                  created_at:
1✔
1082
                                          ((aPull at: #created_at) ifNotNil: #asDateAndTime);
1✔
1083
                                  sha: (aPull at: #head at: #sha);
1✔
1084
                                  merge_commit_sha: (aPull at: #merge_commit_sha) ].
1✔
1085
        result := self glhModel addAll: result unless: self blockOnIdEquality.
1✔
1086
        ^ result
1✔
1087
]
1✔
1088

1089
{ #category : #parsing }
1090
GithubModelImporter >> parsePipelineResult: result [
1✔
1091
        
1✔
1092
        | reader |
1✔
1093
        reader := generalReader on: result readStream. 
1✔
1094
        ^ reader nextAs: GLHPipeline .
1✔
1095
        
1✔
1096
]
1✔
1097

1098
{ #category : #parsing }
1099
GithubModelImporter >> parsePipelinesResult: pipelineOverview [
1✔
1100

1✔
1101
        "in github, Actions runs (pipeline) are returns in an overview objects"
1✔
1102

1✔
1103
        | reader |
1✔
1104
        reader := generalReader on: pipelineOverview readStream.
1✔
1105

1✔
1106
        reader for: GHAPIPipelineOverview do: [ :mapping |
1✔
1107
                mapping mapInstVar: #total_count to: #total_count.
1✔
1108
                (mapping mapInstVar: #workflow_runs) valueSchema: #ArrayOfPipeline.
1✔
1109
                (mapping mapInstVar: #jobs) valueSchema: #ArrayOfJob ].
1✔
1110

1✔
1111

1✔
1112
        ^ reader nextAs: GHAPIPipelineOverview
1✔
1113
]
1✔
1114

1115
{ #category : #parsing }
1116
GithubModelImporter >> parseProjectResult: aResult [
×
1117

×
1118
        | reader |
×
NEW
1119

×
NEW
1120
        reader := generalReader on: aResult readStream.
×
NEW
1121

×
1122
        ^ reader nextAs: GLHProject
×
1123
]
×
1124

1125
{ #category : #parsing }
1126
GithubModelImporter >> parseUserResult: result [
1✔
1127

1✔
1128
        | reader |
1✔
1129
        reader := generalReader on: result readStream.
1✔
1130

1✔
1131
        ^ reader nextAs: GLHUser
1✔
1132
]
1✔
1133

1134
{ #category : #api }
1135
GithubModelImporter >> privateToken [
×
1136
        ^ self api privateToken
×
1137
]
×
1138

1139
{ #category : #api }
1140
GithubModelImporter >> privateToken: aTokenString [
×
1141
        ^ self repoApi privateToken: aTokenString
×
1142
]
×
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