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

moosetechnology / GitProjectHealth / 17940792567

23 Sep 2025 08:54AM UTC coverage: 72.789% (-0.6%) from 73.342%
17940792567

Pull #233

github

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

408 of 676 new or added lines in 18 files covered. (60.36%)

57 existing lines in 6 files now uncovered.

18768 of 25784 relevant lines covered (72.79%)

0.73 hits per line

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

22.55
/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
        reader for: GLHMergeRequest do: [ :mapping |
1✔
146

1✔
147
                (mapping mapInstVar: #created_at) valueSchema: DateAndTime.
1✔
148
                (mapping mapInstVar: #updated_at) valueSchema: DateAndTime.
1✔
149
                (mapping mapInstVar: #merged_at) valueSchema: DateAndTime.
1✔
150
                (mapping mapInstVar: #closed_at) valueSchema: DateAndTime.
1✔
151

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

1✔
167
        reader for: #ArrayOfMergeRequest customDo: [ :customMappting |
1✔
168
                customMappting listOfElementSchema: GLHMergeRequest ].
1✔
169

1✔
170
]
1✔
171

172
{ #category : #'private - configure reader' }
173
GithubModelImporter >> configureReaderForProject: reader [
1✔
174
        "        reader mapInstVarsFor: GLHProject. "
1✔
175

1✔
176
        reader for: GLHProject do: [ :mapping |
1✔
177
                mapping mapInstVar: #name to: #name.
1✔
178
                mapping mapInstVar: #description to: #description.
1✔
179
                mapping mapInstVar: #id to: #id.
1✔
180
                mapping mapInstVar: #archived to: #archived.
1✔
181
                mapping mapInstVar: #web_url to: #html_url.
1✔
182
                mapping mapInstVar: #topics to: #topics ].
1✔
183

1✔
184
        reader
1✔
185
                for: #ArrayOfProject
1✔
186
                customDo: [ :customMappting |
1✔
187
                customMappting listOfElementSchema: GLHProject ]
1✔
188
]
1✔
189

190
{ #category : #private }
191
GithubModelImporter >> convertApiFileAsFile: aAPIFile [
×
192

×
193
        aAPIFile type = 'dir' ifTrue: [ 
×
194
                ^ GLHFileDirectory new
×
195
                          name: aAPIFile name;
×
196
                          yourself ].
×
197
        ^ GLHFileBlob new
×
198
                  name: aAPIFile name;
×
199
                  yourself
×
200
]
×
201

202
{ #category : #'import - groups' }
203
GithubModelImporter >> ensureGroupNamed: aGroupName [
×
204

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

212
{ #category : #'import - repositories' }
NEW
213
GithubModelImporter >> importBranchesOf: aGLHProject [
×
214
        "add the pipeline (actions runs) in the project"
×
215

×
NEW
216
        | branchesResults foundBranches branches |
×
NEW
217
        branchesResults := self repoApi branches
×
NEW
218
                                   getAllForRepo: aGLHProject name
×
NEW
219
                                   ofOwner: aGLHProject group name.
×
NEW
220

×
NEW
221
        foundBranches := (branchesResults collect: [ :branchesResult |
×
NEW
222
                                  self parseBranchesResult: branchesResult ])
×
NEW
223
                                 flattened.
×
NEW
224

×
NEW
225

×
NEW
226
        "WARNING: always add branch first into repository, than into model !"
×
NEW
227
        branches := aGLHProject repository branches
×
NEW
228
                            addAll: foundBranches
×
NEW
229
                            unless: self blockOnNameEquality.
×
NEW
230

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

×
NEW
233
        branches := self glhModel
×
NEW
234
                            addAll: branches
×
NEW
235
                            unless: self blockForBranchEquality.
×
NEW
236

×
NEW
237
        self withFiles ifTrue: [
×
NEW
238
                branches do: [ :branch | self importFilesOfBranch: branch ] ]
×
UNCOV
239
]
×
240

241
{ #category : #'import - commits' }
NEW
242
GithubModelImporter >> importCommit: aCommitID ofProject: aGLHProject [
×
NEW
243

×
NEW
244
        | result parsedResult |
×
NEW
245
        (self glhModel allWithType: GLHCommit) asOrderedCollection
×
NEW
246
                detect: [ :commit | commit id = aCommitID ]
×
NEW
247
                ifFound: [ :commit | ^ commit ].
×
NEW
248

×
NEW
249
        result := self repoApi commits
×
NEW
250
                          get: aCommitID
×
NEW
251
                          inProject: aGLHProject id.
×
NEW
252

×
NEW
253
        parsedResult := self parseCommitResult: result.
×
NEW
254

×
NEW
255
        parsedResult := self glhModel
×
NEW
256
                                add: parsedResult
×
NEW
257
                                unless: self blockOnIdEquality.
×
NEW
258
        parsedResult := aGLHProject repository commits
×
NEW
259
                                add: parsedResult
×
NEW
260
                                unless: self blockOnIdEquality.
×
NEW
261

×
NEW
262
        self withCommitDiffs ifTrue: [ self importDiffOfCommit: parsedResult ].
×
NEW
263

×
NEW
264
        ^ parsedResult
×
NEW
265
]
×
266

267
{ #category : #'import - commits' }
268
GithubModelImporter >> importCommitsOfProject: aGLHProject [
×
269

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

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

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

313
{ #category : #'import - commits' }
314
GithubModelImporter >> importCreatorOfCommit: aGLHCommit [
×
315

×
316
        | creator |
×
317
        (self glhModel allWithType: GLHUser)
×
318
                detect: [ :user | user username = aGLHCommit author_name ]
×
319
                ifFound: [ :user |
×
320
                        aGLHCommit commitCreator: user.
×
321
                        ^ user ].
×
322

×
323
        aGLHCommit author_name ifNotNil: [ :author_name |
×
324
                creator := self importUserByUsername: author_name.
×
325
                aGLHCommit commitCreator: creator ].
×
326
        ^ creator
×
327
]
×
328

329
{ #category : #'import - commits' }
330
GithubModelImporter >> importDiffOfCommit: aGLHCommit [
×
331

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

×
345
        ^ aGLHCommit diffs
×
346
                  addAll: diffsResult
×
347
                  unless: self blockForDiffEquality
×
348
]
×
349

350
{ #category : #'import - files' }
351
GithubModelImporter >> importDirectoryFiles: aDirectoryFile OfBranch: aBranch [
×
352

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

372
{ #category : #'import - files' }
373
GithubModelImporter >> importFilesOfBranch: aBranch [
×
374

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

394
{ #category : #'import - groups' }
395
GithubModelImporter >> importGroup: aGroupName [
×
396

×
397
        | result groupResult |
×
NEW
398
        result := self repoApi organizations get: aGroupName.
×
399
        groupResult := self parseGroupResult: result.
×
400
        self glhModel add: groupResult.
×
401
        self importRepositoriesOfGroup: groupResult.
×
402
        ^ groupResult
×
403
]
×
404

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

×
NEW
412
        parsedResults := glhModel
×
NEW
413
                                 addAll: parsedResults
×
NEW
414
                                 unless: self blockOnIdEquality.
×
NEW
415
        parsedResults := aGLHProject mergeRequests
×
NEW
416
                                 addAll: parsedResults
×
NEW
417
                                 unless: self blockOnIdEquality.
×
NEW
418
        ^ parsedResults
×
NEW
419
]
×
420

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

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

440
{ #category : #'import - pipelines' }
NEW
441
GithubModelImporter >> importPipelinesOfProject: project [
×
442

×
443
        "add the pipeline (actions runs) in the project"
×
444

×
445
        | pipelinesResult ghApiPipelineOverview |
×
NEW
446
        pipelinesResult := self repoApi actions
×
NEW
447
                                   getLatestForRepo: project name
×
NEW
448
                                   ofOwner: project group name.
×
449
        ghApiPipelineOverview := self parsePipelinesResult: pipelinesResult.
×
450
        ghApiPipelineOverview workflow_runs do: [ :pipeline | 
×
451
                project addPipeline: pipeline ]
×
452
]
×
453

454
{ #category : #'import - projects' }
455
GithubModelImporter >> importProject: aProjectName ofGroup: aGroupName [
×
456

×
457
        | result projectResult group |
×
458
        group := self ensureGroupNamed: aGroupName.
×
459
        result := self repoApi organization: aGroupName repo: aProjectName.
×
460
        projectResult := self parseProjectResult: result.
×
461
        projectResult group: group.
×
462
        self glhModel add: projectResult.
×
463
        self completeImportedProject: projectResult.
×
464
        ^ projectResult
×
465
]
×
466

467
{ #category : #'import - merge-requests' }
NEW
468
GithubModelImporter >> importPullRequestsOfProject: aProject [
×
NEW
469
        "alias method since PullRequest = MergeRequest in model"
×
NEW
470

×
NEW
471
        ^ self importMergeRequestsOfProject: aProject
×
NEW
472
]
×
473

474
{ #category : #'import - groups' }
475
GithubModelImporter >> importRepositoriesOfGroup: groupResult [
×
NEW
476
        "Github Repository = GLHProject"
×
477

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

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

×
NEW
501
        reposResult := self repoApi organizations getRepositoriesOfOrganization: groupResult name.
×
502
        groupResult projects addAll: reposFound.
×
503
        self glhModel addAll: groupResult projects.
×
504
        groupResult projects do: [ :project |
×
505
                self completeImportedProject: project ].
×
506
        ^ groupResult
×
507
]
×
508

509
{ #category : #'import - users' }
510
GithubModelImporter >> importUser: userID [
×
511

×
512
        | result userResult |
×
513
        (glhModel allWithType: GLHUser)
×
514
                detect: [ :user | user id = userID ]
×
515
                ifFound: [ :user | ^ user ].
×
516
        ('Import user: ' , userID printString) recordInfo.
×
NEW
517
        result := self repoApi users getUserId: userID.
×
518
        userResult := self parseUserResult: result.
×
519
        ^ glhModel
×
520
                  add: userResult
×
521
                  unless: [ :current :new | current id = new id ]
×
522
]
×
523

524
{ #category : #initialization }
525
GithubModelImporter >> initReader [
1✔
526

1✔
527
        super initReader. 
1✔
528
]
1✔
529

530
{ #category : #initialization }
531
GithubModelImporter >> initialize [
1✔
532

1✔
533
        super initialize.
1✔
534
        self repoApi: GithubApi new.
1✔
535
        self repoApi output: 'json'.
1✔
536
        self withCommitDiffs: false.
1✔
537
        withFiles := false.
1✔
538

1✔
539
]
1✔
540

541
{ #category : #parsing }
542
GithubModelImporter >> parseArrayOfProject: arrayOfProjects [
×
543

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

×
NEW
563
        ^ reader nextAs: #ArrayOfProject
×
UNCOV
564
]
×
565

566
{ #category : #parsing }
567
GithubModelImporter >> parseBranchesResult: arrayOfBranch [
×
568

×
569
        | reader |
×
NEW
570
        reader := generalReader on: arrayOfBranch readStream.
×
NEW
571

×
572
        ^ reader nextAs: #ArrayOfBranch
×
573
]
×
574

575
{ #category : #parsing }
NEW
576
GithubModelImporter >> parseCommitResult: result [
×
NEW
577
        | reader |
×
NEW
578
        
×
NEW
579
        reader := generalReader on: result readStream.
×
NEW
580

×
NEW
581
        ^ reader nextAs: GLHCommit 
×
NEW
582
]
×
583

584
{ #category : #parsing }
585
GithubModelImporter >> parseCommitsResult: result [
1✔
586

1✔
587
        | reader |
1✔
588
        (result includesSubstring: '"status":"409"') ifTrue: [
1✔
589
                GHRepositoryEmptyError signal: 'Git Repository is empty' ].
1✔
590

1✔
591
        reader := generalReader on: result readStream.
1✔
592

1✔
593
        ^ reader nextAs: #ArrayOfCommit
1✔
594
]
1✔
595

596
{ #category : #parsing }
597
GithubModelImporter >> parseDiffresult: response [
×
598

×
599
        | result |
×
600
        result := (response at: #files) collect: [ :file |
×
601
                          GLHDiff new
×
602
                                  diffString: (file at: #patch);
×
603
                                  old_path: (file at: #filename);
×
604
                                  new_path: (file at: #filename) ].
×
605

×
606
        ^ result
×
607
]
×
608

609
{ #category : #parsing }
610
GithubModelImporter >> parseFileTreeResult: aResult [
×
611

×
612
        | reader |
×
613
        reader := NeoJSONReader on: aResult readStream.
×
614
        reader mapInstVarsFor: GHApiFile.
×
615
        reader
×
616
                for: #ArrayOfFile
×
617
                customDo: [ :customMappting | 
×
618
                customMappting listOfElementSchema: GHApiFile ].
×
619
        ^ reader nextAs: #ArrayOfFile
×
620
]
×
621

622
{ #category : #parsing }
623
GithubModelImporter >> parseGroupResult: aResult [
×
624

×
625
        | reader |
×
626
        reader := NeoJSONReader on: aResult readStream.
×
627
        reader for: GLHGroup do: [ :mapping | 
×
628
                mapping mapInstVar: #name to: #login.
×
629
                mapping mapInstVar: #description to: #description.
×
630
                mapping mapInstVar: #id to: #id.
×
631
                mapping mapInstVar: #web_url to: #html_url ].
×
632
        ^ reader nextAs: GLHGroup
×
633
]
×
634

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

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

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

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

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

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

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

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

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

×
690
        | reader |
×
NEW
691
"        reader := NeoJSONReader on: aResult readStream.
×
692
        reader for: GLHProject do: [ :mapping |
×
693
                mapping mapInstVar: #name to: #name.
×
694
                mapping mapInstVar: #description to: #description.
×
695
                mapping mapInstVar: #id to: #id.
×
696
                mapping mapInstVar: #archived to: #archived.
×
697
                mapping mapInstVar: #web_url to: #html_url.
×
698
                mapping mapInstVar: #topics to: #topics ].
×
NEW
699
        ^ reader nextAs: GLHProject"
×
NEW
700
        
×
NEW
701
        reader := generalReader on: aResult readStream.
×
NEW
702
        
×
703
        ^ reader nextAs: GLHProject
×
704
]
×
UNCOV
705

×
UNCOV
706
{ #category : #parsing }
×
UNCOV
707
GithubModelImporter >> parseUserResult: result [
×
UNCOV
708

×
UNCOV
709
        | reader |
×
UNCOV
710
        reader := NeoJSONReader on: result readStream.
×
UNCOV
711
        reader for: GLHUser do: [ :mapping |
×
UNCOV
712
                mapping mapInstVar: #id to: #id.
×
UNCOV
713
                mapping mapInstVar: #public_email to: #email.
×
UNCOV
714
                mapping mapInstVar: #username to: #login.
×
UNCOV
715
                mapping mapInstVar: #bio to: #bio.
×
UNCOV
716
                mapping mapInstVar: #organization to: #company.
×
UNCOV
717
                mapping mapInstVar: #followers to: #followers.
×
UNCOV
718
                mapping mapInstVar: #following to: #following.
×
UNCOV
719
                mapping mapInstVar: #web_url to: #html_url.
×
UNCOV
720
                mapping mapInstVar: #name to: #name.
×
UNCOV
721
                mapping mapInstVar: #avatar_url to: #avatar_url ].
×
UNCOV
722
        ^ reader nextAs: GLHUser
×
UNCOV
723
]
×
UNCOV
724

×
UNCOV
725
{ #category : #api }
×
726
GithubModelImporter >> privateToken [
×
727
        ^ self api privateToken
×
728
]
×
UNCOV
729

×
UNCOV
730
{ #category : #api }
×
731
GithubModelImporter >> privateToken: aTokenString [
×
732
        ^ self repoApi privateToken: aTokenString
×
733
]
×
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