• 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

61.88
/src/GitProjectHealth-Model-Importer/GitModelImporter.class.st
1
"
2
I am a superclass for Model importer.
3
I am a try of normalization for the different importer.
4

5
I also define some contract so it is easier to switch from one importer to another
6
"
7
Class {
8
        #name : #GitModelImporter,
9
        #superclass : #Object,
10
        #instVars : [
11
                'withCommitsSince',
12
                'withFiles',
13
                'glhModel',
14
                'userCatalogue',
15
                'repoApi',
16
                'withCommitDiffs',
17
                'generalReader'
18
        ],
19
        #classVars : [
20
                'currentImporter'
21
        ],
22
        #category : #'GitProjectHealth-Model-Importer'
23
}
24

25
{ #category : #bitbucket }
NEW
26
GitModelImporter class >> forBitbucketHostOn: anHostURL withToken: anApiToken [
×
NEW
27
        
×
NEW
28
        ^ self forBitbucketHostOn: anHostURL withToken: anApiToken andModel: GLHModel new. 
×
NEW
29
]
×
30

31
{ #category : #bitbucket }
NEW
32
GitModelImporter class >> forBitbucketHostOn: anHostURL withToken: anApiToken andModel: aGitModel [
×
NEW
33
        
×
NEW
34
        | bitbucketApi bitBucketImporter |
×
NEW
35
        bitbucketApi := BitbucketApi new
×
NEW
36
                host: anHostURL;
×
NEW
37
                bearerToken: anApiToken.
×
NEW
38

×
NEW
39
        bitBucketImporter := BitBucketModelImporter new
×
NEW
40
                     repoApi: bitbucketApi;
×
NEW
41
                     glhModel: aGitModel;
×
NEW
42
                     withFiles: false;
×
NEW
43
                     withCommitsSince: 3 day;
×
NEW
44
                     withCommitDiffs: false.
×
NEW
45
        ^bitBucketImporter 
×
NEW
46
]
×
47

48
{ #category : #github }
NEW
49
GitModelImporter class >> forGithubWithToken: anApiToken [
×
NEW
50
        ^ self forGithubWithToken: anApiToken andModel: GLHModel new
×
NEW
51
]
×
52

53
{ #category : #github }
NEW
54
GitModelImporter class >> forGithubWithToken: anApiToken andModel: aGitModel [
×
NEW
55

×
NEW
56
        | githubImport |
×
NEW
57
        githubImport := GithubModelImporter new
×
NEW
58
                                glhModel: aGitModel;
×
NEW
59
                                privateToken: anApiToken;
×
NEW
60
                                withCommitsSince: 3 day;
×
NEW
61
                                yourself.
×
NEW
62
        ^ githubImport
×
NEW
63
]
×
64

65
{ #category : #gitlab }
NEW
66
GitModelImporter class >> forGitlabHostOn: anHostURL withToken: anApiToken [ 
×
NEW
67
        ^ self forGitlabHostOn: anHostURL withToken: anApiToken andModel: GLHModel new. 
×
NEW
68
]
×
69

70
{ #category : #gitlab }
NEW
71
GitModelImporter class >> forGitlabHostOn: anHostURL withToken: anApiToken andModel: aGitModel [
×
NEW
72
        "use it when accessing onpremise or custom gitlab platform"
×
NEW
73
        | glphApi gitlabImporter |
×
NEW
74
        
×
NEW
75
        glphApi := GitlabApi new
×
NEW
76
    privateToken: anApiToken;
×
NEW
77
    hostUrl: anHostURL;
×
NEW
78
         output: 'json';
×
NEW
79
    yourself.
×
NEW
80

×
NEW
81
        gitlabImporter := GitlabModelImporter new
×
NEW
82
    repoApi: glphApi;
×
NEW
83
    glhModel: aGitModel;
×
NEW
84
         withFiles: false;
×
NEW
85
         withCommitsSince: 3 day;
×
NEW
86
         withCommitDiffs: false.
×
NEW
87
                
×
NEW
88
        ^ gitlabImporter 
×
NEW
89
]
×
90

91
{ #category : #gitlab }
NEW
92
GitModelImporter class >> forGitlabWithToken: anApiToken [
×
NEW
93
        ^ self forGitlabHostOn: 'https://gitlab.com/api/v4' withToken: anApiToken andModel: GLHModel new. 
×
NEW
94
]
×
95

96
{ #category : #gitlab }
NEW
97
GitModelImporter class >> forGitlabWithToken: anApiToken andModel: aGitModel [
×
NEW
98
        ^ self forGitlabHostOn: 'https://gitlab.com/api/v4' withToken: anApiToken andModel: aGitModel
×
NEW
99
]
×
100

101
{ #category : #'accessing - global variables' }
102
GitModelImporter class >> importers [
×
103
        ^ currentImporter 
×
104
]
×
105

106
{ #category : #'class initialization' }
NEW
107
GitModelImporter class >> initialize [ 
×
NEW
108
        currentImporter := Dictionary new. 
×
NEW
109
]
×
110

111
{ #category : #initialization }
112
GitModelImporter class >> reset [
×
113
        currentImporter := OrderedDictionary new.
×
114
]
×
115

116
{ #category : #initialization }
117
GitModelImporter >> beWithFiles [
×
118

×
119
        withFiles := true
×
120
]
×
121

122
{ #category : #initialization }
123
GitModelImporter >> beWithoutFiles [
×
124

×
125
        withFiles := false
×
126
]
×
127

128
{ #category : #equality }
129
GitModelImporter >> blockEqualityOn: aSymbol [
1✔
130
        ^ [ :existing :new |
1✔
131
          (existing perform: aSymbol) = (new perform: aSymbol) ]
1✔
132
]
1✔
133

134
{ #category : #equality }
135
GitModelImporter >> blockEqualityOn: aSymbol andOn: aSecondSymbol [
×
136
        ^ (self blockEqualityOn: aSymbol) and: [ self blockEqualityOn: aSecondSymbol ]
×
137
]
×
138

139
{ #category : #equality }
140
GitModelImporter >> blockForBranchEquality [
1✔
141
        ^ [ :existing :new |
1✔
142
          (existing name = new name) and: [ existing repository project id = new repository project id ] ]
1✔
143
        
1✔
144
]
1✔
145

146
{ #category : #equality }
147
GitModelImporter >> blockForDiffEquality [
1✔
148
        ^ [ :existing :new |
1✔
149
                        existing diffString size = new diffString size and: [
1✔
150
                                existing diffString = new diffString ] ]
1✔
151
]
1✔
152

153
{ #category : #equality }
154
GitModelImporter >> blockForDiffRangeEquality [
1✔
155

1✔
156
        ^ [ :existing :new |
1✔
157
          existing diff mooseID = new diff mooseID and: [
1✔
158
                  existing originalLineRange = new originalLineRange and: [
1✔
159
                          existing newLineRange = new newLineRange ] ] ]
1✔
160
]
1✔
161

162
{ #category : #equality }
163
GitModelImporter >> blockOnIdEquality [
1✔
164

1✔
165
        ^ [ :existing :new |
1✔
166
          existing id = new id ]
1✔
167
]
1✔
168

169
{ #category : #equality }
170
GitModelImporter >> blockOnNameEquality [
1✔
171

1✔
172
        ^ self blockEqualityOn: #name
1✔
173
]
1✔
174

175
{ #category : #utils }
176
GitModelImporter >> chainsCommitsFrom: commitsCollection [
1✔
177

1✔
178
        | dic |
1✔
179
        ('Chains ' , commitsCollection size printString , ' commits')
1✔
180
                recordInfo.
1✔
181

1✔
182
        dic := ((self glhModel allWithType: GLHCommit) collect: [ :commit |
1✔
183
                        commit id -> commit ]) asSet asDictionary.
1✔
184

1✔
185
        commitsCollection do: [ :commit |
1✔
186
                commit parent_ids do: [ :parentId |
1✔
187
                        dic
1✔
188
                                at: parentId
1✔
189
                                ifPresent: [ :parentCommit |
1✔
190
                                        parentCommit childCommits
1✔
191
                                                add: commit
1✔
192
                                                unless: [ :existing :new | existing id = new id ] ]
1✔
193
                                ifAbsent: [  ] ] ].
1✔
194
        ^ commitsCollection
1✔
195
]
1✔
196

197
{ #category : #'import - commits' }
198
GitModelImporter >> completeImportedCommit: aGLHCommit [ 
×
199
        
×
200
        
×
201
        ('completing commit: ' , aGLHCommit short_id printString) recordInfo.
×
202
        self importCreatorOfCommit: aGLHCommit.
×
203

×
204
        self withCommitDiffs ifTrue: [
×
205
                | diffs |
×
206
                aGLHCommit diffs ifEmpty: [
×
207
                        diffs := self importDiffOfCommit: aGLHCommit.
×
208
                        self glhModel addAll: diffs unless: self blockForDiffEquality ] ].
×
209

×
210
        ^ aGLHCommit
×
211
]
×
212

213
{ #category : #'import - projects' }
NEW
214
GitModelImporter >> completeImportedProject: aGLHProject [
×
NEW
215
]
×
216

217
{ #category : #'private - configure reader' }
218
GitModelImporter >> configureReaderForBranch: reader [
1✔
219

1✔
220
        reader mapInstVarsFor: GLHBranch.
1✔
221

1✔
222
        reader
1✔
223
                for: #ArrayOfBranch
1✔
224
                customDo: [ :customMappting |
1✔
225
                customMappting listOfElementSchema: GLHBranch ]
1✔
226
]
1✔
227

228
{ #category : #'private - configure reader' }
229
GitModelImporter >> configureReaderForCommit: reader [
1✔
230
        
1✔
231
        reader mapInstVarsFor: GLHCommit .
1✔
232
        
1✔
233
        reader
1✔
234
                for: #ArrayOfCommit
1✔
235
                customDo: [ :customMappting |
1✔
236
                customMappting listOfElementSchema: GLHCommit ]
1✔
237
]
1✔
238

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

1✔
242
        reader mapInstVarsFor: GLHDiff.
1✔
243

1✔
244
        reader
1✔
245
                for: #ArrayOfDiff
1✔
246
                customDo: [ :customMappting |
1✔
247
                customMappting listOfElementSchema: GLHDiff ]
1✔
248
]
1✔
249

250
{ #category : #'private - configure reader' }
251
GitModelImporter >> configureReaderForGroup: reader [
1✔
252

1✔
253
        reader mapInstVarsFor: GLHGroup.
1✔
254

1✔
255
        reader
1✔
256
                for: #ArrayOfGroup
1✔
257
                customDo: [ :customMappting |
1✔
258
                customMappting listOfElementSchema: GLHGroup ]
1✔
259
]
1✔
260

261
{ #category : #'private - configure reader' }
NEW
262
GitModelImporter >> configureReaderForIssue: reader [
×
NEW
263

×
NEW
264
        reader mapInstVarsFor: GLHIssue.
×
NEW
265

×
NEW
266
        reader
×
NEW
267
                for: #ArrayOfIssue
×
NEW
268
                customDo: [ :customMappting |
×
NEW
269
                customMappting listOfElementSchema: GLHIssue ]
×
NEW
270
]
×
271

272
{ #category : #'private - configure reader' }
273
GitModelImporter >> configureReaderForJob: reader [
1✔
274

1✔
275
        reader mapInstVarsFor: GLHJob .
1✔
276

1✔
277
        reader for: #ArrayOfJob customDo: [ :customMappting |
1✔
278
                customMappting listOfElementSchema: GLHJob ]
1✔
279
]
1✔
280

281
{ #category : #'private - configure reader' }
282
GitModelImporter >> configureReaderForMergeRequest: reader [
1✔
283

1✔
284
        reader mapInstVarsFor: GLHMergeRequest.
1✔
285

1✔
286
        reader for: #ArrayOfMergeRequest customDo: [ :customMappting |
1✔
287
                customMappting listOfElementSchema: GLHMergeRequest ]
1✔
288
]
1✔
289

290
{ #category : #'private - configure reader' }
NEW
291
GitModelImporter >> configureReaderForMilestone: reader [
×
NEW
292

×
NEW
293
        reader mapInstVarsFor: GLHMilestone.
×
NEW
294

×
NEW
295
        reader
×
NEW
296
                for: #ArrayOfMilestone
×
NEW
297
                customDo: [ :customMappting |
×
NEW
298
                customMappting listOfElementSchema: GLHMilestone ]
×
NEW
299
]
×
300

301
{ #category : #'private - configure reader' }
302
GitModelImporter >> configureReaderForNote: reader [
1✔
303

1✔
304
        reader mapInstVarsFor: GLHNote .
1✔
305

1✔
306
        reader
1✔
307
                for: #ArrayOfNote
1✔
308
                customDo: [ :customMappting |
1✔
309
                customMappting listOfElementSchema: GLHNote ]
1✔
310
]
1✔
311

312
{ #category : #'private - configure reader' }
313
GitModelImporter >> configureReaderForPipeline: reader [
1✔
314

1✔
315
        reader mapInstVarsFor: GLHPipeline.
1✔
316

1✔
317
        reader
1✔
318
                for: #ArrayOfPipeline
1✔
319
                customDo: [ :customMappting |
1✔
320
                customMappting listOfElementSchema: GLHPipeline ]
1✔
321
]
1✔
322

323
{ #category : #'private - configure reader' }
324
GitModelImporter >> configureReaderForProject: reader [
1✔
325

1✔
326
        reader mapInstVarsFor: GLHProject.
1✔
327

1✔
328
        reader
1✔
329
                for: #ArrayOfProject
1✔
330
                customDo: [ :customMappting |
1✔
331
                customMappting listOfElementSchema: GLHProject ]
1✔
332
]
1✔
333

334
{ #category : #'private - configure reader' }
335
GitModelImporter >> configureReaderForRelease: reader [
1✔
336

1✔
337
        reader mapInstVarsFor: GLHRelease.
1✔
338

1✔
339
        reader
1✔
340
                for: #ArrayOfRelease
1✔
341
                customDo: [ :customMappting |
1✔
342
                customMappting listOfElementSchema: GLHRelease ]
1✔
343
]
1✔
344

345
{ #category : #'private - configure reader' }
NEW
346
GitModelImporter >> configureReaderForTag: reader [
×
NEW
347

×
NEW
348
        reader mapInstVarsFor: GLHTag.
×
NEW
349

×
NEW
350
        reader
×
NEW
351
                for: #ArrayOfTag
×
NEW
352
                customDo: [ :customMappting |
×
NEW
353
                customMappting listOfElementSchema: GLHTag ]
×
NEW
354
]
×
355

356
{ #category : #'private - configure reader' }
357
GitModelImporter >> configureReaderForUser: reader [
1✔
358

1✔
359
        reader mapInstVarsFor: GLHUser.
1✔
360

1✔
361
        reader
1✔
362
                for: #ArrayOfUser
1✔
363
                customDo: [ :customMappting |
1✔
364
                customMappting listOfElementSchema: GLHUser ].
1✔
365
        
1✔
366
]
1✔
367

368
{ #category : #utils }
369
GitModelImporter >> filterCommitChanges: aCollection [
1✔
370

1✔
371
        ^ aCollection reject: [ :line |
1✔
372
                  | trimmedLine |
1✔
373
                  trimmedLine := line trimLeft.
1✔
374
                  (trimmedLine beginsWith: '---') or: [
1✔
375
                          (trimmedLine beginsWith: '+++') or: [
1✔
376
                                  trimmedLine beginsWith: '\ No newline at end of file' ] ] ]
1✔
377
]
1✔
378

379
{ #category : #accessing }
380
GitModelImporter >> glhModel [
1✔
381

1✔
382
        ^ glhModel
1✔
383
]
1✔
384

385
{ #category : #accessing }
386
GitModelImporter >> glhModel: anObject [
1✔
387

1✔
388
        glhModel := anObject
1✔
389
]
1✔
390

391
{ #category : #'import - commits' }
392
GitModelImporter >> importAndLoadLatestsCommitsOfProject: aGLHProject [
393

394
        self subclassResponsibility 
395
]
396

397
{ #category : #'import - users' }
NEW
398
GitModelImporter >> importAuthorOfCommit: aGLHCommit [
×
NEW
399

×
NEW
400
        self
×
NEW
401
                deprecated: 'Use importCreatorOfCommit: instead of current one'
×
NEW
402
                on: '19 September 2025'
×
NEW
403
                in:
×
NEW
404
                'Pharo-12.0.0+SNAPSHOT.build.1571.sha.cf5fcd22e66957962c97dffc58b0393b7f368147 (64 Bit)'.
×
NEW
405

×
NEW
406
        self subclassResponsibility
×
NEW
407
]
×
408

409
{ #category : #'import - repositories' }
410
GitModelImporter >> importBranchesOf: aGLHProject [
411

412
        ^ self subclassResponsibility
413
]
414

415
{ #category : #'import - commits' }
416
GitModelImporter >> importCommit: aCommitID ofProject: aGLHProject [
417

418
        self subclassResponsibility 
419
]
420

421
{ #category : #'import - commits' }
422
GitModelImporter >> importCommitsOfBranch: aGLHBranch [
423
        self subclassResponsibility 
424
        
425
        
426
]
427

428
{ #category : #'import - commits' }
429
GitModelImporter >> importCommitsOfProject: aGLHProject since: since until: until [
430

431
        self subclassResponsibility 
432
]
433

434
{ #category : #'import - projects' }
NEW
435
GitModelImporter >> importContributedProjectsOfUser: aGLHUser [
×
NEW
436
]
×
437

438
{ #category : #'import - users' }
439
GitModelImporter >> importCreatorOfCommit: aGLHCommit [
440

441
        self subclassResponsibility 
442
]
443

444
{ #category : #'import - diffs' }
445
GitModelImporter >> importDiffOfCommit: aCommit [
446

447
        self subclassResponsibility 
448
]
449

450
{ #category : #'import - diffs' }
451
GitModelImporter >> importDiffRangesForDiff: aGLHDiff [
1✔
452

1✔
453
        | diffRanges |
1✔
454
        aGLHDiff diffRanges ifNotEmpty: [
1✔
455
                ('Diffs already imported for ' , aGLHDiff printString) recordInfo.
1✔
456
                ^ aGLHDiff diffRanges ].
1✔
457

1✔
458
        ('Import changes of diff ' , aGLHDiff printString) recordInfo.
1✔
459
        "the import of 'diffRanges' entites is technically done inside the parseDiffString"
1✔
460

1✔
461
        diffRanges := self glhModel
1✔
462
                              addAll: (self parseDiffString: aGLHDiff)
1✔
463
                              unless: self blockForDiffRangeEquality.
1✔
464
        ^ aGLHDiff diffRanges
1✔
465
                  addAll: diffRanges
1✔
466
                  unless: self blockForDiffRangeEquality
1✔
467
]
1✔
468

469
{ #category : #'import - groups' }
470
GitModelImporter >> importGroup: aGroupID [
471

472
        self subclassResponsibility
473
]
474

475
{ #category : #'import - issues' }
476
GitModelImporter >> importIssuesOfProject: aGLHProject [
477
        self subclassResponsibility 
478
]
479

480
{ #category : #'import - jobs' }
481
GitModelImporter >> importJobsOf: aGLHPipeline [
482
        self subclassResponsibility 
483
]
484

485
{ #category : #'import - commits' }
486
GitModelImporter >> importLatestCommitsOfProject: aGLHProject [
487
        "limited to the last 50 commits"
488
        self subclassResponsibility 
489
]
490

491
{ #category : #'import - merge-requests' }
492
GitModelImporter >> importLatestMergeRequestsOfProject: aGLHProject [
493
        self subclassResponsibility 
494
]
495

496
{ #category : #'import - pipelines' }
497
GitModelImporter >> importLatestPipelinesOfProject: aGLHProject [
498
        self subclassResponsibility 
499
        
500
]
501

502
{ #category : #'import - releases' }
503
GitModelImporter >> importLatestReleaseOfProject: aGLHProject [
504
        ^ self subclassResponsibility 
505
]
506

507
{ #category : #'import - merge-requests' }
NEW
508
GitModelImporter >> importMergeRequestCommits: mergeRequest [
×
NEW
509
]
×
510

511
{ #category : #'import - merge-requests' }
NEW
512
GitModelImporter >> importMergeRequestMergeCommits: aGLHMergeRequest [
×
NEW
513
]
×
514

515
{ #category : #'import - merge-requests' }
516
GitModelImporter >> importMergeRequestsOfProject: aGLHProject [
517

518
        self subclassResponsibility 
519
]
520

521
{ #category : #'import - merge-requests' }
522
GitModelImporter >> importMergeRequestsOfProject: aGLHProject since: fromDate until: toDate [
523
        self subclassResponsibility 
524
]
525

526
{ #category : #'import - merge-requests' }
NEW
527
GitModelImporter >> importMergeResquestAuthor: mergeRequest [
×
NEW
528
]
×
529

530
{ #category : #'import - merge-requests' }
NEW
531
GitModelImporter >> importMergeResquestMerger: mergeRequest [
×
NEW
532
]
×
533

534
{ #category : #'import - milestones' }
535
GitModelImporter >> importMilestonesOfProject: aGLHProject [
536
        self subclassResponsibility 
537
]
538

539
{ #category : #'import - notes' }
540
GitModelImporter >> importNotesOfMergeRequest: mergeRequest [
541

542
        self subclassResponsibility
543
]
544

545
{ #category : #'import - pipelines' }
546
GitModelImporter >> importPipeline: aPipelineId OfProject: aGLHProject [
547

548
        self subclassResponsibility 
549
]
550

551
{ #category : #'import - merge-requests' }
552
GitModelImporter >> importPipelinesOfProject: aGLHProject [
553
        ^ self subclassResponsibility 
554
]
555

556
{ #category : #'import - projects' }
557
GitModelImporter >> importProject: id [
558
        "id can be a string or an integer depending on the APi implementation"
559

560
        "return the project created or retrieved"
561

562
        ^ self subclassResponsibility
563
]
564

565
{ #category : #'import - projects' }
NEW
566
GitModelImporter >> importProject: aProjectID ofGroup: aGroup [
×
NEW
567
]
×
568

569
{ #category : #'import - projects' }
570
GitModelImporter >> importProjects: aCollectionOfProjectID [
×
571

×
572

×
573
        ^ aCollectionOfProjectID collect: [ :id | self importProject: id ]
×
574
]
×
575

576
{ #category : #'import - projects' }
577
GitModelImporter >> importProjectsOfUser: aGLHUser [
578
        "https://docs.github.com/fr/rest/repos/repos?apiVersion=2022-11-28#list-repositories-for-a-user"
579
        
580
        self subclassResponsibility 
581
]
582

583
{ #category : #'import - commits' }
NEW
584
GitModelImporter >> importRefCommitOfBranch: aGLHBranch [
×
NEW
585
        |commit|
×
NEW
586
        commit := self
×
NEW
587
                                 importCommit: aGLHBranch sha
×
NEW
588
                                 ofProject: aGLHBranch repository project.
×
NEW
589
        commit := aGLHBranch commits
×
NEW
590
                add: commit
×
NEW
591
                unless: self blockOnIdEquality.
×
NEW
592
        ^ commit
×
NEW
593
]
×
594

595
{ #category : #'import - releases' }
596
GitModelImporter >> importRelease: aReleaseID ofProject: aGLHProject [
597
        self subclassResponsibility 
598
]
599

600
{ #category : #'import - tags' }
601
GitModelImporter >> importTagsForProject: aGLHProject [
602
        self subclassResponsibility 
603
]
604

605
{ #category : #'import - users' }
606
GitModelImporter >> importUser: aUserID [
607
        self subclassResponsibility 
608
]
609

610
{ #category : #'import - users' }
611
GitModelImporter >> importUserByUsername: username [
612

613
        self subclassResponsibility 
614
]
615

616
{ #category : #'private - configure reader' }
617
GitModelImporter >> initReader [
1✔
618

1✔
619
        | configurators |
1✔
620
        generalReader := NeoJSONReader new.
1✔
621

1✔
622
        "will be reuse for all reader next"
1✔
623
        "indique ce que doit faire le reader lorsqu'il parse une DateAndTime object"
1✔
624
        generalReader for: DateAndTime customDo: [ :mapping |
1✔
625
                mapping decoder: [ :string |
1✔
626
                        string ifNil: [ nil ] ifNotNil: [ DateAndTime fromString: string ] ] ].
1✔
627

1✔
628
        configurators := self class selectors select: [ :m |
1✔
629
                                 m beginsWith: #configureReaderFor ].
1✔
630

1✔
631
        configurators do: [ :configureReader |
1✔
632
                self perform: configureReader with: generalReader ]
1✔
633
]
1✔
634

635
{ #category : #initialization }
636
GitModelImporter >> initialize [
1✔
637

1✔
638
        super initialize.
1✔
639
        self withFiles: false. 
1✔
640
        self withCommitsSince: (Date today - 1 week) asDateAndTime.
1✔
641
        userCatalogue := GLHUserCatalogueV2 new
1✔
642
                                 anImporter: self;
1✔
643
                                 yourself.
1✔
644

1✔
645
        self initReader
1✔
646
]
1✔
647

648
{ #category : #initialization }
649
GitModelImporter >> makeGlobal [
×
650
        ^ self makeGlobal: DateAndTime now printString.
×
651
]
×
652

653
{ #category : #initialization }
654
GitModelImporter >> makeGlobal: aLabel [ 
×
655

×
656
        currentImporter := GithubModelImporter importers ifNil: [ OrderedDictionary new ].
×
657
        currentImporter at: aLabel put: self. 
×
658
        ^ currentImporter 
×
659
]
×
660

661
{ #category : #parsing }
662
GitModelImporter >> parseDiffString: aDiff [
1✔
663
        "parse diff string to create entities for each lines"
1✔
664

1✔
665
        | lines range index firstChangeRange |
1✔
666
        lines := aDiff diffString lines.
1✔
667
        index := 0.
1✔
668
        range := nil.
1✔
669

1✔
670
        lines ifEmpty: [ ^ aDiff diffRanges ].
1✔
671
        lines := self filterCommitChanges: lines.
1✔
672
        lines ifEmpty: [ ^ aDiff diffRanges ].
1✔
673
        (lines first beginsWith: '@@') ifFalse: [ ^ aDiff diffRanges ].
1✔
674

1✔
675
        lines do: [ :line |
1✔
676
                | aChange |
1✔
677
                firstChangeRange := false.
1✔
678
                (line trim beginsWith: #'@@') ifTrue: [
1✔
679
                        range := GLHDiffRange newFrom: line.
1✔
680
                        firstChangeRange := true.
1✔
681
                        range := aDiff diffRanges add: range unless: [ :existing :new |
1✔
682
                                         existing originalLineRange = new originalLineRange and: [
1✔
683
                                                 existing newLineRange = new newLineRange ] ] ].
1✔
684

1✔
685
                self withCommitDiffs ifTrue: [
1✔
686
                        firstChangeRange ifFalse: [
1✔
687
                                aChange := GLHChange newFrom: line.
1✔
688
                                aChange relativeIndex: index.
1✔
689
                                aChange := range changes add: aChange unless: [ :existing :new |
1✔
690
                                                   existing sourceCode = new sourceCode and: [
1✔
691
                                                           existing index = new index ] ].
1✔
692
                                index := index + 1 ] ] ].
1✔
693

1✔
694
        "add changes to the diff range"
1✔
695
        aDiff diffRanges do: [ :diffRange |
1✔
696
                self glhModel addAll: diffRange changes unless: [ :existing :new |
1✔
697
                        existing diffRange mooseID = new diffRange mooseID and: [
1✔
698
                                existing sourceCode = new sourceCode and: [
1✔
699
                                        existing index = new index ] ] ] ].
1✔
700

1✔
701
        ^ aDiff diffRanges
1✔
702
]
1✔
703

704
{ #category : #accessing }
705
GitModelImporter >> repoApi [
1✔
706

1✔
707
        ^ repoApi
1✔
708
]
1✔
709

710
{ #category : #accessing }
711
GitModelImporter >> repoApi: anObject [
1✔
712

1✔
713
        repoApi := anObject
1✔
714
]
1✔
715

716
{ #category : #accessing }
717
GitModelImporter >> userCatalogue [
1✔
718
        ^ userCatalogue 
1✔
719
]
1✔
720

721
{ #category : #accessing }
722
GitModelImporter >> userCatalogue: aGLHUserCatalogue [
×
723

×
724
        userCatalogue := aGLHUserCatalogue.
×
725
        aGLHUserCatalogue anImporter: self. 
×
726
]
×
727

728
{ #category : #accessing }
729
GitModelImporter >> withCommitDiffs [
1✔
730

1✔
731
        ^ withCommitDiffs
1✔
732
]
1✔
733

734
{ #category : #accessing }
735
GitModelImporter >> withCommitDiffs: anObject [
1✔
736

1✔
737
        withCommitDiffs := anObject
1✔
738
]
1✔
739

740
{ #category : #accessing }
741
GitModelImporter >> withCommitsSince [
×
742

×
743
        ^ withCommitsSince
×
744
]
×
745

746
{ #category : #accessing }
747
GitModelImporter >> withCommitsSince: someDays [
1✔
748
        "substract the current date with a given number of days. Use to retrieve the commits submit in the last giving days"
1✔
749

1✔
750
        "(GitlabModelImporter new withCommitsSince: 1 week ) >>> (Date today - 1 week) asDateAndTime"
1✔
751

1✔
752
        "(GitlabModelImporter new withCommitsSince: 30 day ) >>> (Date today - 30 day) asDateAndTime"
1✔
753

1✔
754
        (someDays isKindOf: DateAndTime)
1✔
755
                ifTrue: [ withCommitsSince := someDays ]
1✔
756
                ifFalse: [
1✔
757
                withCommitsSince := (DateAndTime today - someDays) ].
1✔
758
        ^ withCommitsSince
1✔
759
]
1✔
760

761
{ #category : #accessing }
762
GitModelImporter >> withFiles [
1✔
763

1✔
764
        ^ withFiles
1✔
765
]
1✔
766

767
{ #category : #accessing }
768
GitModelImporter >> withFiles: anObject [
1✔
769

1✔
770
        withFiles := anObject
1✔
771
]
1✔
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