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

moosetechnology / GitProjectHealth / 17950363421

23 Sep 2025 03:01PM UTC coverage: 75.574% (+2.2%) from 73.342%
17950363421

Pull #233

github

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

2277 of 2574 new or added lines in 30 files covered. (88.46%)

50 existing lines in 5 files now uncovered.

20727 of 27426 relevant lines covered (75.57%)

0.76 hits per line

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

22.29
/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
        "        reader mapInstVarsFor: GLHProject. "
1✔
172

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

1✔
181
        reader
1✔
182
                for: #ArrayOfProject
1✔
183
                customDo: [ :customMappting |
1✔
184
                customMappting listOfElementSchema: GLHProject ]
1✔
185
]
1✔
186

187
{ #category : #private }
188
GithubModelImporter >> convertApiFileAsFile: aAPIFile [
×
189

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

199
{ #category : #'import - groups' }
200
GithubModelImporter >> ensureGroupNamed: aGroupName [
×
201

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

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

×
NEW
213
        | branchesResults foundBranches branches |
×
NEW
214
        branchesResults := self repoApi branches
×
NEW
215
                                   getAllForRepo: aGLHProject name
×
NEW
216
                                   ofOwner: aGLHProject group name.
×
NEW
217

×
NEW
218
        foundBranches := (branchesResults collect: [ :branchesResult |
×
NEW
219
                                  self parseBranchesResult: branchesResult ])
×
NEW
220
                                 flattened.
×
NEW
221

×
NEW
222

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

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

×
NEW
230
        branches := self glhModel
×
NEW
231
                            addAll: branches
×
NEW
232
                            unless: self blockForBranchEquality.
×
NEW
233

×
NEW
234
        self withFiles ifTrue: [
×
NEW
235
                branches do: [ :branch | self importFilesOfBranch: branch ] ]
×
UNCOV
236
]
×
237

238
{ #category : #'import - commits' }
NEW
239
GithubModelImporter >> importCommit: aCommitID ofProject: aGLHProject [
×
NEW
240

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

×
NEW
246
        result := self repoApi commits
×
NEW
247
                          get: aCommitID
×
NEW
248
                          inProject: aGLHProject id.
×
NEW
249

×
NEW
250
        parsedResult := self parseCommitResult: result.
×
NEW
251

×
NEW
252
        parsedResult := self glhModel
×
NEW
253
                                add: parsedResult
×
NEW
254
                                unless: self blockOnIdEquality.
×
NEW
255
        parsedResult := aGLHProject repository commits
×
NEW
256
                                add: parsedResult
×
NEW
257
                                unless: self blockOnIdEquality.
×
NEW
258

×
NEW
259
        self withCommitDiffs ifTrue: [ self importDiffOfCommit: parsedResult ].
×
NEW
260

×
NEW
261
        ^ parsedResult
×
NEW
262
]
×
263

264
{ #category : #'import - commits' }
265
GithubModelImporter >> importCommitsOfProject: aGLHProject [
×
266

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

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

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

310
{ #category : #'import - commits' }
311
GithubModelImporter >> importCreatorOfCommit: aGLHCommit [
×
312

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

×
320
        aGLHCommit author_name ifNotNil: [ :author_name |
×
321
                creator := self importUserByUsername: author_name.
×
322
                aGLHCommit commitCreator: creator ].
×
323
        ^ creator
×
324
]
×
325

326
{ #category : #'import - commits' }
327
GithubModelImporter >> importDiffOfCommit: aGLHCommit [
×
328

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

×
342
        ^ aGLHCommit diffs
×
343
                  addAll: diffsResult
×
344
                  unless: self blockForDiffEquality
×
345
]
×
346

347
{ #category : #'import - files' }
348
GithubModelImporter >> importDirectoryFiles: aDirectoryFile OfBranch: aBranch [
×
349

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

369
{ #category : #'import - files' }
370
GithubModelImporter >> importFilesOfBranch: aBranch [
×
371

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

391
{ #category : #'import - groups' }
392
GithubModelImporter >> importGroup: aGroupName [
×
393

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

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

×
NEW
409
        parsedResults := glhModel
×
NEW
410
                                 addAll: parsedResults
×
NEW
411
                                 unless: self blockOnIdEquality.
×
NEW
412
        parsedResults := aGLHProject mergeRequests
×
NEW
413
                                 addAll: parsedResults
×
NEW
414
                                 unless: self blockOnIdEquality.
×
NEW
415
        ^ parsedResults
×
NEW
416
]
×
417

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

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

437
{ #category : #'import - pipelines' }
NEW
438
GithubModelImporter >> importPipelinesOfProject: project [
×
439

×
440
        "add the pipeline (actions runs) in the project"
×
441

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

451
{ #category : #'import - projects' }
452
GithubModelImporter >> importProject: aProjectName ofGroup: aGroupName [
×
453

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

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

×
NEW
468
        ^ self importMergeRequestsOfProject: aProject
×
NEW
469
]
×
470

471
{ #category : #'import - groups' }
472
GithubModelImporter >> importRepositoriesOfGroup: groupResult [
×
NEW
473
        "Github Repository = GLHProject"
×
474

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

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

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

506
{ #category : #'import - users' }
507
GithubModelImporter >> importUser: userID [
×
508

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

521
{ #category : #initialization }
522
GithubModelImporter >> initReader [
1✔
523

1✔
524
        super initReader. 
1✔
525
]
1✔
526

527
{ #category : #initialization }
528
GithubModelImporter >> initialize [
1✔
529

1✔
530
        super initialize.
1✔
531
        self repoApi: GithubApi new.
1✔
532
        self repoApi output: 'json'.
1✔
533
        self withCommitDiffs: false.
1✔
534
        withFiles := false.
1✔
535

1✔
536
]
1✔
537

538
{ #category : #parsing }
539
GithubModelImporter >> parseArrayOfProject: arrayOfProjects [
×
540

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

×
NEW
560
        ^ reader nextAs: #ArrayOfProject
×
UNCOV
561
]
×
562

563
{ #category : #parsing }
564
GithubModelImporter >> parseBranchesResult: arrayOfBranch [
×
565

×
566
        | reader |
×
NEW
567
        reader := generalReader on: arrayOfBranch readStream.
×
NEW
568

×
569
        ^ reader nextAs: #ArrayOfBranch
×
570
]
×
571

572
{ #category : #parsing }
NEW
573
GithubModelImporter >> parseCommitResult: result [
×
NEW
574
        | reader |
×
NEW
575
        
×
NEW
576
        reader := generalReader on: result readStream.
×
NEW
577

×
NEW
578
        ^ reader nextAs: GLHCommit 
×
NEW
579
]
×
580

581
{ #category : #parsing }
582
GithubModelImporter >> parseCommitsResult: result [
1✔
583

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

1✔
588
        reader := generalReader on: result readStream.
1✔
589

1✔
590
        ^ reader nextAs: #ArrayOfCommit
1✔
591
]
1✔
592

593
{ #category : #parsing }
594
GithubModelImporter >> parseDiffresult: response [
×
595

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

×
603
        ^ result
×
604
]
×
605

606
{ #category : #parsing }
607
GithubModelImporter >> parseFileTreeResult: aResult [
×
608

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

619
{ #category : #parsing }
620
GithubModelImporter >> parseGroupResult: aResult [
×
621

×
622
        | reader |
×
623
        reader := NeoJSONReader on: aResult readStream.
×
NEW
624
        reader for: GLHGroup do: [ :mapping |
×
625
                mapping mapInstVar: #web_url to: #html_url ].
×
626
        ^ reader nextAs: GLHGroup
×
627
]
×
628

629
{ #category : #parsing }
630
GithubModelImporter >> parseMergeRequestsResult: response [
×
631

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

655
{ #category : #parsing }
656
GithubModelImporter >> parsePipelinesResult: pipelineOverview [
1✔
657

1✔
658
        | reader |
1✔
659
        reader := NeoJSONReader on: pipelineOverview readStream.
1✔
660

1✔
661
        reader for: GHAPIPipelineOverview do: [ :mapping |
1✔
662
                mapping mapInstVar: #total_count to: #total_count.
1✔
663
                (mapping mapInstVar: #workflow_runs) valueSchema: #ArrayOfPipeline ].
1✔
664

1✔
665
        reader
1✔
666
                for: #ArrayOfPipeline
1✔
667
                customDo: [ :customMappting |
1✔
668
                customMappting listOfElementSchema: GLHPipeline ].
1✔
669

1✔
670
        reader for: GLHPipeline do: [ :mapping |
1✔
671
                mapping
1✔
672
                        mapInstVar: #status to: #conclusion;
1✔
673
                        mapProperty: #run_started_at
1✔
674
                        getter: [ :object | #ignore ]
1✔
675
                        setter: [ :object :value |
1✔
676
                                object runDate: (DateAndTime fromString: value) ] ].
1✔
677

1✔
678
        ^ reader nextAs: GHAPIPipelineOverview
1✔
679
]
1✔
680

681
{ #category : #parsing }
682
GithubModelImporter >> parseProjectResult: aResult [
×
683

×
684
        | reader |
×
NEW
685
"        reader := NeoJSONReader on: aResult readStream.
×
686
        reader for: GLHProject do: [ :mapping |
×
687
                mapping mapInstVar: #name to: #name.
×
688
                mapping mapInstVar: #description to: #description.
×
689
                mapping mapInstVar: #id to: #id.
×
690
                mapping mapInstVar: #archived to: #archived.
×
691
                mapping mapInstVar: #web_url to: #html_url.
×
692
                mapping mapInstVar: #topics to: #topics ].
×
NEW
693
        ^ reader nextAs: GLHProject"
×
NEW
694
        
×
NEW
695
        reader := generalReader on: aResult readStream.
×
NEW
696
        
×
697
        ^ reader nextAs: GLHProject
×
698
]
×
UNCOV
699

×
UNCOV
700
{ #category : #parsing }
×
UNCOV
701
GithubModelImporter >> parseUserResult: result [
×
UNCOV
702

×
UNCOV
703
        | reader |
×
UNCOV
704
        reader := NeoJSONReader on: result readStream.
×
UNCOV
705
        reader for: GLHUser do: [ :mapping |
×
UNCOV
706
                mapping mapInstVar: #id to: #id.
×
UNCOV
707
                mapping mapInstVar: #public_email to: #email.
×
UNCOV
708
                mapping mapInstVar: #username to: #login.
×
UNCOV
709
                mapping mapInstVar: #bio to: #bio.
×
UNCOV
710
                mapping mapInstVar: #organization to: #company.
×
UNCOV
711
                mapping mapInstVar: #followers to: #followers.
×
UNCOV
712
                mapping mapInstVar: #following to: #following.
×
UNCOV
713
                mapping mapInstVar: #web_url to: #html_url.
×
UNCOV
714
                mapping mapInstVar: #name to: #name.
×
UNCOV
715
                mapping mapInstVar: #avatar_url to: #avatar_url ].
×
UNCOV
716
        ^ reader nextAs: GLHUser
×
UNCOV
717
]
×
UNCOV
718

×
UNCOV
719
{ #category : #api }
×
720
GithubModelImporter >> privateToken [
×
721
        ^ self api privateToken
×
722
]
×
UNCOV
723

×
UNCOV
724
{ #category : #api }
×
725
GithubModelImporter >> privateToken: aTokenString [
×
726
        ^ self repoApi privateToken: aTokenString
×
727
]
×
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