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

moosetechnology / GitProjectHealth / 17973256097

24 Sep 2025 10:02AM UTC coverage: 75.872% (+2.5%) from 73.342%
17973256097

Pull #233

github

web-flow
Merge 20f79a2d6 into dd8ffa1f6
Pull Request #233: V2.0.0 : Refactoring importers

2722 of 3033 new or added lines in 37 files covered. (89.75%)

28 existing lines in 6 files now uncovered.

20889 of 27532 relevant lines covered (75.87%)

0.76 hits per line

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

27.0
/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 [
×
66

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

×
NEW
71
        aGLHProject repository: GLHRepository new.
×
NEW
72
        self glhModel add: aGLHProject repository.
×
NEW
73

×
NEW
74
        self importPipelinesOfProject: aGLHProject.
×
75
        self importBranchesOf: aGLHProject.
×
76
        self withCommitsSince ifNotNil: [ :withCommitSince | "If not nil, it means we have to import commit"
×
77
                | commits |
×
78
                commits := self importCommitsOfProject: aGLHProject.
×
79
                self chainsCommitsFrom: commits ]
×
80
]
×
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 commitCreator: (self importUser: authorId) ] ] ].
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
        reader for: DateAndTime customDo: [ :mapping |
1✔
134
                mapping decoder: [ :string | DateAndTime fromString: string ] ].
1✔
135

1✔
136
        reader for: #ArrayOfId customDo: [ :mapping |
1✔
137
                mapping decoder: [ :parents |
1✔
138
                        parents collect: [ :parent | parent at: #sha ] ] ]
1✔
139
]
1✔
140

141
{ #category : #'private - configure reader' }
142
GithubModelImporter >> configureReaderForMergeRequest: reader [
1✔
143
        "        reader mapInstVarsFor: GLHProject. "
1✔
144

1✔
145
        super configureReaderForMergeRequest: reader.
1✔
146
        
1✔
147
        reader for: GLHMergeRequest do: [ :mapping |
1✔
148
                (mapping mapInstVar: #created_at) valueSchema: DateAndTime.
1✔
149
                (mapping mapInstVar: #updated_at) valueSchema: DateAndTime.
1✔
150
                (mapping mapInstVar: #merged_at) valueSchema: DateAndTime.
1✔
151
                (mapping mapInstVar: #closed_at) valueSchema: DateAndTime.
1✔
152

1✔
153
                mapping
1✔
154
                        mapProperty: #author
1✔
155
                        getter: [  ]
1✔
156
                        setter: [ :object :value |
1✔
157
                        object cacheAt: #authorID put: (value at: #id) ].
1✔
158
                mapping
1✔
159
                        mapProperty: #merge_user
1✔
160
                        getter: [  ]
1✔
161
                        setter: [ :object :value |
1✔
162
                                value ifNotNil: [
1✔
163
                                        object cacheAt: #mergeUserID put: (value at: #id) ] ] ].
1✔
164

1✔
165

1✔
166

1✔
167
]
1✔
168

169
{ #category : #'private - configure reader' }
170
GithubModelImporter >> configureReaderForProject: reader [
1✔
171

1✔
172
        super configureReaderForProject: reader.
1✔
173
        
1✔
174
        reader for: GLHProject do: [ :mapping |
1✔
175
                mapping mapInstVar: #web_url to: #html_url.
1✔
176
         ].
1✔
177

1✔
178
]
1✔
179

180
{ #category : #'private - configure reader' }
181
GithubModelImporter >> configureReaderForUser: reader [
1✔
182
        super configureReaderForUser: reader.
1✔
183
        
1✔
184
        
1✔
185
                reader for: GLHUser do: [ :mapping |
1✔
186
                mapping mapInstVar: #public_email to: #email.
1✔
187
                mapping mapInstVar: #username to: #login.
1✔
188
                mapping mapInstVar: #bio to: #bio.
1✔
189
                mapping mapInstVar: #organization to: #company.
1✔
190
                mapping mapInstVar: #web_url to: #html_url.
1✔
191
 ].
1✔
192
]
1✔
193

194
{ #category : #private }
195
GithubModelImporter >> convertApiFileAsFile: aAPIFile [
×
196

×
197
        aAPIFile type = 'dir' ifTrue: [ 
×
198
                ^ GLHFileDirectory new
×
199
                          name: aAPIFile name;
×
200
                          yourself ].
×
201
        ^ GLHFileBlob new
×
202
                  name: aAPIFile name;
×
203
                  yourself
×
204
]
×
205

206
{ #category : #'import - groups' }
207
GithubModelImporter >> ensureGroupNamed: aGroupName [
×
208

×
NEW
209
        self flag: 'WARNING: group from different platform (github vs gitlab) can share the same name, thus being confused here'. 
×
210
        ^ self glhModel
×
211
                  detect: [ :a |
×
212
                  (a isKindOf: GLHGroup) and: [ a name = aGroupName ] ]
×
213
                  ifNone: [ self glhModel newGroupNamed: aGroupName ]
×
214
]
×
215

216
{ #category : #'import - repositories' }
NEW
217
GithubModelImporter >> importBranchesOf: aGLHProject [
×
218
        "add the pipeline (actions runs) in the project"
×
219

×
NEW
220
        | branchesResults foundBranches branches |
×
NEW
221
        branchesResults := self repoApi branches
×
NEW
222
                                   getAllForRepo: aGLHProject name
×
NEW
223
                                   ofOwner: aGLHProject group name.
×
NEW
224

×
NEW
225
        foundBranches := (branchesResults collect: [ :branchesResult |
×
NEW
226
                                  self parseBranchesResult: branchesResult ])
×
NEW
227
                                 flattened.
×
NEW
228

×
NEW
229

×
NEW
230
        "WARNING: always add branch first into repository, than into model !"
×
NEW
231
        branches := aGLHProject repository branches
×
NEW
232
                            addAll: foundBranches
×
NEW
233
                            unless: self blockOnNameEquality.
×
NEW
234

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

×
NEW
237
        branches := self glhModel
×
NEW
238
                            addAll: branches
×
NEW
239
                            unless: self blockForBranchEquality.
×
NEW
240

×
NEW
241
        self withFiles ifTrue: [
×
NEW
242
                branches do: [ :branch | self importFilesOfBranch: branch ] ]
×
UNCOV
243
]
×
244

245
{ #category : #'import - commits' }
NEW
246
GithubModelImporter >> importCommit: aCommitID ofProject: aGLHProject [
×
NEW
247

×
NEW
248
        | result parsedResult |
×
NEW
249
        (self glhModel allWithType: GLHCommit) asOrderedCollection
×
NEW
250
                detect: [ :commit | commit id = aCommitID ]
×
NEW
251
                ifFound: [ :commit | ^ commit ].
×
NEW
252

×
NEW
253
        result := self repoApi commits
×
NEW
254
                          get: aCommitID
×
NEW
255
                          inProject: aGLHProject id.
×
NEW
256

×
NEW
257
        parsedResult := self parseCommitResult: result.
×
NEW
258

×
NEW
259
        parsedResult := self glhModel
×
NEW
260
                                add: parsedResult
×
NEW
261
                                unless: self blockOnIdEquality.
×
NEW
262
        parsedResult := aGLHProject repository commits
×
NEW
263
                                add: parsedResult
×
NEW
264
                                unless: self blockOnIdEquality.
×
NEW
265

×
NEW
266
        self withCommitDiffs ifTrue: [ self importDiffOfCommit: parsedResult ].
×
NEW
267

×
NEW
268
        ^ parsedResult
×
NEW
269
]
×
270

271
{ #category : #'import - commits' }
272
GithubModelImporter >> importCommitsOfProject: aGLHProject [
×
273

×
274
        | itemByPage foundCommits tmp pageNumber |
×
275
        itemByPage := 100.
×
276
        pageNumber := 1.
×
277
        ('Extract all commits of ' , aGLHProject name) recordInfo.
×
278
        foundCommits := OrderedCollection new.
×
279
        ('Extract commits from ' , foundCommits size printString , ' to '
×
280
         , (foundCommits size + itemByPage) printString) recordInfo.
×
281
        "also check that there is at least one commit with the error handling"
×
282
        [
×
NEW
283
        tmp := self parseCommitsResult: (self repoApi commits
×
NEW
284
                                getForRepo: aGLHProject name
×
NEW
285
                                ofOwner: aGLHProject group name
×
NEW
286
                                withParms: {
×
NEW
287
                                                (#since -> self withCommitsSince).
×
NEW
288
                                                (#perPage -> itemByPage).
×
NEW
289
                                                (#page -> pageNumber) } asDictionary) ]
×
290
                on: GHRepositoryEmptyError
×
291
                do: [ ^ {  } ].
×
292

×
293
        foundCommits addAll: tmp.
×
294
        [ tmp size = itemByPage ] whileTrue: [
×
295
                pageNumber := pageNumber + 1.
×
296
                ('Extract issues from ' , foundCommits size printString , ' to '
×
297
                 , (foundCommits size + itemByPage) printString) recordInfo.
×
NEW
298
                tmp := self parseCommitsResult: (self repoApi commits
×
NEW
299
                                        getForRepo: aGLHProject name
×
NEW
300
                                        ofOwner: aGLHProject group name
×
NEW
301
                                        withParms: {
×
NEW
302
                                                        (#sine -> self withCommitsSince).
×
NEW
303
                                                        (#perPage -> itemByPage).
×
NEW
304
                                                        (#page -> pageNumber) } asDictionary).
×
305
                foundCommits addAll: tmp ].
×
306

×
307
        "add the imported commits (unless they are already added to this repository)"
×
308
        aGLHProject repository commits
×
309
                addAll: foundCommits
×
310
                unless: [ :existing :new | existing id = new id ].
×
311
        "add the imported commits to the model unles they are already added to the model"
×
312
        ^ self glhModel
×
313
                  addAll: foundCommits
×
314
                  unless: [ :existing :new | existing id = new id ]
×
315
]
×
316

317
{ #category : #'import - commits' }
318
GithubModelImporter >> importCreatorOfCommit: aGLHCommit [
×
319

×
320
        | creator |
×
321
        (self glhModel allWithType: GLHUser)
×
322
                detect: [ :user | user username = aGLHCommit author_name ]
×
323
                ifFound: [ :user |
×
324
                        aGLHCommit commitCreator: user.
×
325
                        ^ user ].
×
326

×
327
        aGLHCommit author_name ifNotNil: [ :author_name |
×
328
                creator := self importUserByUsername: author_name.
×
329
                aGLHCommit commitCreator: creator ].
×
330
        ^ creator
×
331
]
×
332

333
{ #category : #'import - commits' }
334
GithubModelImporter >> importDiffOfCommit: aGLHCommit [
×
335

×
336
        | result diffsResult |
×
337
        aGLHCommit diffs ifNotEmpty: [
×
338
                'Diff already importer: '
×
339
                , aGLHCommit short_id printString recordInfo.
×
340
                ^ aGLHCommit diffs ].
×
341
        ('Import diff of commit: ' , aGLHCommit short_id printString)
×
342
                recordInfo.
×
343
        result := self repoApi
×
344
                          commit: aGLHCommit id
×
345
                          ofOrganisation: aGLHCommit repository project group name
×
346
                          ofProject: aGLHCommit repository project name.
×
347
        diffsResult := self parseDiffresult: result.
×
348

×
349
        ^ aGLHCommit diffs
×
350
                  addAll: diffsResult
×
351
                  unless: self blockForDiffEquality
×
352
]
×
353

354
{ #category : #'import - files' }
355
GithubModelImporter >> importDirectoryFiles: aDirectoryFile OfBranch: aBranch [
×
356

×
357
        | result files apiFiles |
×
358
        ('Explore ' , aDirectoryFile name) recordInfo.
×
359
        result := self api
×
360
                          contentsOfRepo: aBranch repository project name
×
361
                          ofOrganization: aBranch repository project group name
×
362
                          inBranch: aBranch name
×
363
                          withPath: aDirectoryFile path.
×
364
        apiFiles := self parseFileTreeResult: result.
×
365
        files := apiFiles collect: [ :apiFile | 
×
366
                         self convertApiFileAsFile: apiFile ].
×
367
        files do: [ :file | 
×
368
                self glhModel add: file.
×
369
                aDirectoryFile addFile: file ].
×
370
        files
×
371
                select: [ :file | file isKindOf: GLHFileDirectory ]
×
372
                thenCollect: [ :file | 
×
373
                self importDirectoryFiles: file OfBranch: aBranch ]
×
374
]
×
375

376
{ #category : #'import - files' }
377
GithubModelImporter >> importFilesOfBranch: aBranch [
×
378

×
379
        | result files apiFiles |
×
380
        result := self api
×
381
                          contentsOfRepo: aBranch repository project name
×
382
                          ofOrganization: aBranch repository project group name
×
383
                          inBranch: aBranch name
×
384
                          withPath: nil.
×
385
        apiFiles := self parseFileTreeResult: result.
×
386
        files := apiFiles collect: [ :apiFile | 
×
387
                         self convertApiFileAsFile: apiFile ].
×
388
        files do: [ :file | 
×
389
                self glhModel add: file.
×
390
                aBranch addFile: file ].
×
391
        files
×
392
                select: [ :file | file isKindOf: GLHFileDirectory ]
×
393
                thenCollect: [ :file | 
×
NEW
394
                self importDirectoryFiles: file OfBranch: aBranch ].
×
NEW
395
        ^ files
×
UNCOV
396
]
×
397

398
{ #category : #'import - groups' }
399
GithubModelImporter >> importGroup: aGroupName [
×
400

×
401
        | result groupResult |
×
NEW
402
        result := self repoApi organizations get: aGroupName.
×
403
        groupResult := self parseGroupResult: result.
×
404
        self glhModel add: groupResult.
×
405
        self importRepositoriesOfGroup: groupResult.
×
406
        ^ groupResult
×
407
]
×
408

409
{ #category : #'import - merge-requests' }
NEW
410
GithubModelImporter >> importLatestMergeRequestsOfProject: aGLHProject [ 
×
NEW
411
        
×
NEW
412
        | results parsedResults |
×
NEW
413
        results := self repoApi pullRequests getLatestForRepo: aGLHProject name ofOwner:  aGLHProject group name.
×
NEW
414
        parsedResults := self parseMergeRequestsResult: results.
×
NEW
415

×
NEW
416
        parsedResults := glhModel
×
NEW
417
                                 addAll: parsedResults
×
NEW
418
                                 unless: self blockOnIdEquality.
×
NEW
419
        parsedResults := aGLHProject mergeRequests
×
NEW
420
                                 addAll: parsedResults
×
NEW
421
                                 unless: self blockOnIdEquality.
×
NEW
422
        ^ parsedResults
×
NEW
423
]
×
424

425
{ #category : #'import - merge-requests' }
NEW
426
GithubModelImporter >> importLatestPullRequestsOfProject: aGLHProject [
×
NEW
427
        "alias method since PullRequest = MergeRequest in model"
×
NEW
428
        ^ self importLatestMergeRequestsOfProject: aGLHProject 
×
NEW
429
]
×
430

431
{ #category : #'import - merge-requests' }
NEW
432
GithubModelImporter >> importMergeRequestsOfProject: aProject [ 
×
433
        |response mergeRequests|
×
434
        response := self repoApi 
×
435
                        mergeRequestsOfRepo: aProject group name 
×
436
                        ofProject: aProject name.
×
437
        mergeRequests := self parseMergeRequestsResult: response. 
×
438
        
×
439
        mergeRequests := aProject mergeRequests addAll:mergeRequests unless: self blockOnIdEquality.
×
440
        ^ mergeRequests
×
441
        
×
442
]
×
443

444
{ #category : #'import - pipelines' }
NEW
445
GithubModelImporter >> importPipelinesOfProject: project [
×
446

×
447
        "add the pipeline (actions runs) in the project"
×
448

×
449
        | pipelinesResult ghApiPipelineOverview |
×
NEW
450
        pipelinesResult := self repoApi actions
×
NEW
451
                                   getLatestForRepo: project name
×
NEW
452
                                   ofOwner: project group name.
×
453
        ghApiPipelineOverview := self parsePipelinesResult: pipelinesResult.
×
454
        ghApiPipelineOverview workflow_runs do: [ :pipeline | 
×
455
                project addPipeline: pipeline ]
×
456
]
×
457

458
{ #category : #'import - projects' }
459
GithubModelImporter >> importProject: aProjectName ofGroup: aGroupName [
×
460

×
461
        | result projectResult group |
×
462
        group := self ensureGroupNamed: aGroupName.
×
463
        result := self repoApi organization: aGroupName repo: aProjectName.
×
464
        projectResult := self parseProjectResult: result.
×
465
        projectResult group: group.
×
466
        self glhModel add: projectResult.
×
467
        self completeImportedProject: projectResult.
×
468
        ^ projectResult
×
469
]
×
470

471
{ #category : #'import - merge-requests' }
NEW
472
GithubModelImporter >> importPullRequestsOfProject: aProject [
×
NEW
473
        "alias method since PullRequest = MergeRequest in model"
×
NEW
474

×
NEW
475
        ^ self importMergeRequestsOfProject: aProject
×
NEW
476
]
×
477

478
{ #category : #'import - groups' }
479
GithubModelImporter >> importRepositoriesOfGroup: groupResult [
×
NEW
480
        "Github Repository = GLHProject"
×
481

×
482
        | reposResult itemByPage pageNumber reposFound tmp |
×
483
        itemByPage := 100.
×
484
        pageNumber := 1.
×
485
        ('Extract all repository of ' , groupResult name) recordInfo.
×
486
        reposFound := OrderedCollection new.
×
487
        ('Extract commits from ' , reposFound size printString , ' to '
×
488
         , (reposFound size + itemByPage) printString) recordInfo.
×
489
        tmp := self parseArrayOfProject: (self repoApi
×
NEW
490
                                organizations getRepositoriesOfOrganization: groupResult name
×
491
                                perPage: itemByPage
×
492
                                page: pageNumber).
×
493

×
494
        reposFound addAll: tmp.
×
495
        [ tmp size = itemByPage ] whileTrue: [
×
496
                pageNumber := pageNumber + 1.
×
497
                ('Extract issues from ' , reposFound size printString , ' to '
×
498
                 , (reposFound size + itemByPage) printString) recordInfo.
×
499
                tmp := self parseArrayOfProject: (self repoApi
×
500
                                        reposOfOrganization: groupResult name
×
501
                                        perPage: itemByPage
×
502
                                        page: pageNumber).
×
503
                reposFound addAll: tmp ].
×
504

×
NEW
505
        reposResult := self repoApi organizations getRepositoriesOfOrganization: groupResult name.
×
506
        groupResult projects addAll: reposFound.
×
507
        self glhModel addAll: groupResult projects.
×
508
        groupResult projects do: [ :project |
×
509
                self completeImportedProject: project ].
×
510
        ^ groupResult
×
511
]
×
512

513
{ #category : #'import - users' }
514
GithubModelImporter >> importUser: userID [
1✔
515

1✔
516
        | result userResult |
1✔
517
        (glhModel allWithType: GLHUser)
1✔
518
                detect: [ :user | user id = userID ]
1✔
519
                ifFound: [ :user | ^ user ].
1✔
520
        ('Import user: ' , userID printString) recordInfo.
1✔
521
        result := self repoApi users getUserId: userID.
1✔
522
        userResult := self parseUserResult: result.
1✔
523
        ^ glhModel
1✔
524
                  add: userResult
1✔
525
                  unless: [ :current :new | current id = new id ]
1✔
526
]
1✔
527

528
{ #category : #initialization }
529
GithubModelImporter >> initReader [
1✔
530

1✔
531
        super initReader. 
1✔
532
]
1✔
533

534
{ #category : #initialization }
535
GithubModelImporter >> initialize [
1✔
536

1✔
537
        super initialize.
1✔
538
        self repoApi: GithubApi new.
1✔
539
        self repoApi output: 'json'.
1✔
540
        self withCommitDiffs: false.
1✔
541
        withFiles := false.
1✔
542

1✔
543
]
1✔
544

545
{ #category : #parsing }
546
GithubModelImporter >> parseArrayOfProject: arrayOfProjects [
×
547

×
548
        | reader |
×
NEW
549
        " reader := NeoJSONReader on: arrayOfProjects readStream.
×
NEW
550
        
×
551
        reader
×
552
                for: #ArrayOfProjects
×
553
                customDo: [ :customMappting | 
×
554
                customMappting listOfElementSchema: GLHProject ].
×
NEW
555
        
×
556
        reader for: GLHProject do: [ :mapping | 
×
557
                mapping mapInstVar: #name to: #name.
×
558
                mapping mapInstVar: #description to: #description.
×
559
                mapping mapInstVar: #id to: #id.
×
560
                mapping mapInstVar: #archived to: #archived.
×
561
                mapping mapInstVar: #web_url to: #html_url.
×
562
                mapping mapInstVar: #topics to: #topics ].
×
563
        ^ reader nextAs: #ArrayOfProjects
×
NEW
564
        "
×
NEW
565
        reader := generalReader on: arrayOfProjects readStream.
×
NEW
566

×
NEW
567
        ^ reader nextAs: #ArrayOfProject
×
UNCOV
568
]
×
569

570
{ #category : #parsing }
571
GithubModelImporter >> parseBranchesResult: arrayOfBranch [
×
572

×
573
        | reader |
×
NEW
574
        reader := generalReader on: arrayOfBranch readStream.
×
NEW
575

×
576
        ^ reader nextAs: #ArrayOfBranch
×
577
]
×
578

579
{ #category : #parsing }
NEW
580
GithubModelImporter >> parseCommitResult: result [
×
NEW
581
        | reader |
×
NEW
582
        
×
NEW
583
        reader := generalReader on: result readStream.
×
NEW
584

×
NEW
585
        ^ reader nextAs: GLHCommit 
×
NEW
586
]
×
587

588
{ #category : #parsing }
589
GithubModelImporter >> parseCommitsResult: result [
1✔
590

1✔
591
        | reader |
1✔
592
        (result includesSubstring: '"status":"409"') ifTrue: [
1✔
593
                GHRepositoryEmptyError signal: 'Git Repository is empty' ].
1✔
594

1✔
595
        reader := generalReader on: result readStream.
1✔
596

1✔
597
        ^ reader nextAs: #ArrayOfCommit
1✔
598
]
1✔
599

600
{ #category : #parsing }
601
GithubModelImporter >> parseDiffresult: response [
×
602

×
603
        | result |
×
604
        result := (response at: #files) collect: [ :file |
×
605
                          GLHDiff new
×
606
                                  diffString: (file at: #patch);
×
607
                                  old_path: (file at: #filename);
×
608
                                  new_path: (file at: #filename) ].
×
609

×
610
        ^ result
×
611
]
×
612

613
{ #category : #parsing }
614
GithubModelImporter >> parseFileTreeResult: aResult [
×
615

×
616
        | reader |
×
617
        reader := NeoJSONReader on: aResult readStream.
×
618
        reader mapInstVarsFor: GHApiFile.
×
619
        reader
×
620
                for: #ArrayOfFile
×
621
                customDo: [ :customMappting | 
×
622
                customMappting listOfElementSchema: GHApiFile ].
×
623
        ^ reader nextAs: #ArrayOfFile
×
624
]
×
625

626
{ #category : #parsing }
627
GithubModelImporter >> parseGroupResult: aResult [
×
628

×
629
        | reader |
×
630
        reader := NeoJSONReader on: aResult readStream.
×
NEW
631
        reader for: GLHGroup do: [ :mapping |
×
632
                mapping mapInstVar: #web_url to: #html_url ].
×
633
        ^ reader nextAs: GLHGroup
×
634
]
×
635

636
{ #category : #parsing }
637
GithubModelImporter >> parseMergeRequestsResult: response [
×
638

×
639
        | result json|
×
640
        self flag: 'temp version, must remade using NeoJsonReader'.
×
641
        json := NeoJSONReader fromString: response.
×
642
        
×
643
        result := json collect: [ :aPull |
×
644
                          GLHMergeRequest new
×
645
                                  id: (aPull at: #id);
×
646
                                  title: (aPull at: #title);
×
647
                                  state: (aPull at: #state);
×
648
                                  closed_at:
×
649
                                          ((aPull at: #closed_at) ifNotNil: #asDateAndTime);
×
650
                                  merged_at:
×
651
                                          ((aPull at: #merged_at) ifNotNil: #asDateAndTime);
×
652
                                  updated_at:
×
653
                                          ((aPull at: #updated_at) ifNotNil: #asDateAndTime);
×
654
                                  created_at:
×
655
                                          ((aPull at: #created_at) ifNotNil: #asDateAndTime);
×
656
                                  sha: (aPull at: #head at: #sha);
×
657
                                  merge_commit_sha: (aPull at: #merge_commit_sha) ].
×
658
        result := self glhModel addAll: result unless: self blockOnIdEquality.
×
659
        ^ result
×
660
]
×
661

662
{ #category : #parsing }
663
GithubModelImporter >> parsePipelinesResult: pipelineOverview [
1✔
664

1✔
665
        | reader |
1✔
666
        reader := NeoJSONReader on: pipelineOverview readStream.
1✔
667

1✔
668
        reader for: GHAPIPipelineOverview do: [ :mapping |
1✔
669
                mapping mapInstVar: #total_count to: #total_count.
1✔
670
                (mapping mapInstVar: #workflow_runs) valueSchema: #ArrayOfPipeline ].
1✔
671

1✔
672
        reader
1✔
673
                for: #ArrayOfPipeline
1✔
674
                customDo: [ :customMappting |
1✔
675
                customMappting listOfElementSchema: GLHPipeline ].
1✔
676

1✔
677
        reader for: GLHPipeline do: [ :mapping |
1✔
678
                mapping
1✔
679
                        mapInstVar: #status to: #conclusion;
1✔
680
                        mapProperty: #run_started_at
1✔
681
                        getter: [ :object | #ignore ]
1✔
682
                        setter: [ :object :value |
1✔
683
                                object runDate: (DateAndTime fromString: value) ] ].
1✔
684

1✔
685
        ^ reader nextAs: GHAPIPipelineOverview
1✔
686
]
1✔
687

688
{ #category : #parsing }
689
GithubModelImporter >> parseProjectResult: aResult [
×
690

×
691
        | reader |
×
NEW
692

×
NEW
693
        reader := generalReader on: aResult readStream.
×
NEW
694

×
695
        ^ reader nextAs: GLHProject
×
696
]
×
697

698
{ #category : #parsing }
699
GithubModelImporter >> parseUserResult: result [
1✔
700

1✔
701
        | reader |
1✔
702
        reader := generalReader on: result readStream.
1✔
703

1✔
704
        ^ reader nextAs: GLHUser
1✔
705
]
1✔
706

707
{ #category : #api }
708
GithubModelImporter >> privateToken [
×
709
        ^ self api privateToken
×
710
]
×
711

712
{ #category : #api }
713
GithubModelImporter >> privateToken: aTokenString [
×
714
        ^ self repoApi privateToken: aTokenString
×
715
]
×
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