• 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

66.44
/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

254
{ #category : #'private - configure reader' }
255
GitModelImporter >> configureReaderForIssue: reader [
1✔
256

1✔
257
        reader mapInstVarsFor: GLHIssue.
1✔
258

1✔
259
        reader
1✔
260
                for: #ArrayOfIssue
1✔
261
                customDo: [ :customMappting |
1✔
262
                customMappting listOfElementSchema: GLHIssue ]
1✔
263
]
1✔
264

265
{ #category : #'private - configure reader' }
266
GitModelImporter >> configureReaderForMergeRequest: reader [
1✔
267

1✔
268
        reader mapInstVarsFor: GLHMergeRequest.
1✔
269

1✔
270
        reader
1✔
271
                for: #ArrayOfMergeRequest
1✔
272
                customDo: [ :customMappting |
1✔
273
                customMappting listOfElementSchema: GLHMergeRequest ]
1✔
274
]
1✔
275

276
{ #category : #'private - configure reader' }
277
GitModelImporter >> configureReaderForMilestone: reader [
1✔
278

1✔
279
        reader mapInstVarsFor: GLHMilestone.
1✔
280

1✔
281
        reader
1✔
282
                for: #ArrayOfMilestone
1✔
283
                customDo: [ :customMappting |
1✔
284
                customMappting listOfElementSchema: GLHMilestone ]
1✔
285
]
1✔
286

287
{ #category : #'private - configure reader' }
288
GitModelImporter >> configureReaderForPipeline: reader [
1✔
289

1✔
290
        reader mapInstVarsFor: GLHPipeline.
1✔
291

1✔
292
        reader
1✔
293
                for: #ArrayOfPipeline
1✔
294
                customDo: [ :customMappting |
1✔
295
                customMappting listOfElementSchema: GLHPipeline ]
1✔
296
]
1✔
297

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

1✔
301
        reader mapInstVarsFor: GLHProject.
1✔
302

1✔
303
        reader
1✔
304
                for: #ArrayOfProject
1✔
305
                customDo: [ :customMappting |
1✔
306
                customMappting listOfElementSchema: GLHProject ]
1✔
307
]
1✔
308

309
{ #category : #'private - configure reader' }
310
GitModelImporter >> configureReaderForRelease: reader [
1✔
311

1✔
312
        reader mapInstVarsFor: GLHRelease.
1✔
313

1✔
314
        reader
1✔
315
                for: #ArrayOfRelease
1✔
316
                customDo: [ :customMappting |
1✔
317
                customMappting listOfElementSchema: GLHRelease ]
1✔
318
]
1✔
319

320
{ #category : #'private - configure reader' }
321
GitModelImporter >> configureReaderForTag: reader [
1✔
322

1✔
323
        reader mapInstVarsFor: GLHTag.
1✔
324

1✔
325
        reader
1✔
326
                for: #ArrayOfTag
1✔
327
                customDo: [ :customMappting |
1✔
328
                customMappting listOfElementSchema: GLHTag ]
1✔
329
]
1✔
330

331
{ #category : #'private - configure reader' }
332
GitModelImporter >> configureReaderForUser: reader [
1✔
333

1✔
334
        reader mapInstVarsFor: GLHUser.
1✔
335

1✔
336
        reader
1✔
337
                for: #ArrayOfUser
1✔
338
                customDo: [ :customMappting |
1✔
339
                customMappting listOfElementSchema: GLHUser ]
1✔
340
]
1✔
341

342
{ #category : #utils }
343
GitModelImporter >> filterCommitChanges: aCollection [
1✔
344

1✔
345
        ^ aCollection reject: [ :line |
1✔
346
                  | trimmedLine |
1✔
347
                  trimmedLine := line trimLeft.
1✔
348
                  (trimmedLine beginsWith: '---') or: [
1✔
349
                          (trimmedLine beginsWith: '+++') or: [
1✔
350
                                  trimmedLine beginsWith: '\ No newline at end of file' ] ] ]
1✔
351
]
1✔
352

353
{ #category : #accessing }
354
GitModelImporter >> glhModel [
1✔
355

1✔
356
        ^ glhModel
1✔
357
]
1✔
358

359
{ #category : #accessing }
360
GitModelImporter >> glhModel: anObject [
1✔
361

1✔
362
        glhModel := anObject
1✔
363
]
1✔
364

365
{ #category : #'import - commits' }
366
GitModelImporter >> importAndLoadLatestsCommitsOfProject: aGLHProject [
367

368
        self subclassResponsibility 
369
]
370

371
{ #category : #'import - users' }
NEW
372
GitModelImporter >> importAuthorOfCommit: aGLHCommit [
×
NEW
373

×
NEW
374
        self
×
NEW
375
                deprecated: 'Use importCreatorOfCommit: instead of current one'
×
NEW
376
                on: '19 September 2025'
×
NEW
377
                in:
×
NEW
378
                'Pharo-12.0.0+SNAPSHOT.build.1571.sha.cf5fcd22e66957962c97dffc58b0393b7f368147 (64 Bit)'.
×
NEW
379

×
NEW
380
        self subclassResponsibility
×
NEW
381
]
×
382

383
{ #category : #'import - repositories' }
384
GitModelImporter >> importBranchesOf: aGLHProject [
385

386
        ^ self subclassResponsibility
387
]
388

389
{ #category : #'import - commits' }
390
GitModelImporter >> importCommit: aCommitID ofProject: aGLHProject [
391

392
        self subclassResponsibility 
393
]
394

395
{ #category : #'import - commits' }
396
GitModelImporter >> importCommitsOfBranch: aGLHBranch [
397
        self subclassResponsibility 
398
        
399
        
400
]
401

402
{ #category : #'import - commits' }
403
GitModelImporter >> importCommitsOfProject: aGLHProject since: since until: until [
404

405
        self subclassResponsibility 
406
]
407

408
{ #category : #'import - projects' }
NEW
409
GitModelImporter >> importContributedProjectsOfUser: aGLHUser [
×
NEW
410
]
×
411

412
{ #category : #'import - users' }
413
GitModelImporter >> importCreatorOfCommit: aGLHCommit [
414

415
        self subclassResponsibility 
416
]
417

418
{ #category : #'import - diffs' }
419
GitModelImporter >> importDiffOfCommit: aCommit [
420

421
        self subclassResponsibility 
422
]
423

424
{ #category : #'import - diffs' }
425
GitModelImporter >> importDiffRangesForDiff: aGLHDiff [
1✔
426

1✔
427
        | diffRanges |
1✔
428
        aGLHDiff diffRanges ifNotEmpty: [
1✔
429
                ('Diffs already imported for ' , aGLHDiff printString) recordInfo.
1✔
430
                ^ aGLHDiff diffRanges ].
1✔
431

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

1✔
435
        diffRanges := self glhModel
1✔
436
                              addAll: (self parseDiffString: aGLHDiff)
1✔
437
                              unless: self blockForDiffRangeEquality.
1✔
438
        ^ aGLHDiff diffRanges
1✔
439
                  addAll: diffRanges
1✔
440
                  unless: self blockForDiffRangeEquality
1✔
441
]
1✔
442

443
{ #category : #'import - groups' }
444
GitModelImporter >> importGroup: aGroupID [
445

446
        self subclassResponsibility
447
]
448

449
{ #category : #'import - issues' }
450
GitModelImporter >> importIssuesOfProject: aGLHProject [
451
        self subclassResponsibility 
452
]
453

454
{ #category : #'import - jobs' }
455
GitModelImporter >> importJobsOf: aGLHPipeline [
456
        self subclassResponsibility 
457
]
458

459
{ #category : #'import - commits' }
460
GitModelImporter >> importLatestCommitsOfProject: aGLHProject [
461
        "limited to the last 50 commits"
462
        self subclassResponsibility 
463
]
464

465
{ #category : #'import - merge-requests' }
466
GitModelImporter >> importLatestMergeRequestsOfProject: aGLHProject [
467
        self subclassResponsibility 
468
]
469

470
{ #category : #'import - pipelines' }
471
GitModelImporter >> importLatestPipelinesOfProject: aGLHProject [
472
        self subclassResponsibility 
473
        
474
]
475

476
{ #category : #'import - releases' }
477
GitModelImporter >> importLatestReleaseOfProject: aGLHProject [
478
        ^ self subclassResponsibility 
479
]
480

481
{ #category : #'import - merge-requests' }
NEW
482
GitModelImporter >> importMergeRequestCommits: mergeRequest [
×
NEW
483
]
×
484

485
{ #category : #'import - merge-requests' }
NEW
486
GitModelImporter >> importMergeRequestMergeCommits: aGLHMergeRequest [
×
NEW
487
]
×
488

489
{ #category : #'import - merge-requests' }
490
GitModelImporter >> importMergeRequestsOfProject: aGLHProject [
491

492
        self subclassResponsibility 
493
]
494

495
{ #category : #'import - merge-requests' }
496
GitModelImporter >> importMergeRequestsOfProject: aGLHProject since: fromDate until: toDate [
497
        self subclassResponsibility 
498
]
499

500
{ #category : #'import - merge-requests' }
NEW
501
GitModelImporter >> importMergeResquestAuthor: mergeRequest [
×
NEW
502
]
×
503

504
{ #category : #'import - merge-requests' }
NEW
505
GitModelImporter >> importMergeResquestMerger: mergeRequest [
×
NEW
506
]
×
507

508
{ #category : #'import - milestones' }
509
GitModelImporter >> importMilestonesOfProject: aGLHProject [
510
        self subclassResponsibility 
511
]
512

513
{ #category : #'import - notes' }
514
GitModelImporter >> importNotesOfMergeRequest: mergeRequest [
515

516
        self subclassResponsibility
517
]
518

519
{ #category : #'import - pipelines' }
520
GitModelImporter >> importPipeline: aPipelineId OfProject: aGLHProject [
521

522
        self subclassResponsibility 
523
]
524

525
{ #category : #'import - merge-requests' }
526
GitModelImporter >> importPipelinesOfProject: aGLHProject [
527
        ^ self subclassResponsibility 
528
]
529

530
{ #category : #'import - projects' }
531
GitModelImporter >> importProject: id [
532
        "id can be a string or an integer depending on the APi implementation"
533

534
        "return the project created or retrieved"
535

536
        ^ self subclassResponsibility
537
]
538

539
{ #category : #'import - projects' }
NEW
540
GitModelImporter >> importProject: aProjectID ofGroup: aGroup [
×
NEW
541
]
×
542

543
{ #category : #'import - projects' }
544
GitModelImporter >> importProjects: aCollectionOfProjectID [
×
545

×
546

×
547
        ^ aCollectionOfProjectID collect: [ :id | self importProject: id ]
×
548
]
×
549

550
{ #category : #'import - projects' }
551
GitModelImporter >> importProjectsOfUser: aGLHUser [
552
        "https://docs.github.com/fr/rest/repos/repos?apiVersion=2022-11-28#list-repositories-for-a-user"
553
        
554
        self subclassResponsibility 
555
]
556

557
{ #category : #'as yet unclassified' }
NEW
558
GitModelImporter >> importRefCommitOfBranch: aGLHBranch [
×
NEW
559
        |commit|
×
NEW
560
        commit := self
×
NEW
561
                                 importCommit: aGLHBranch sha
×
NEW
562
                                 ofProject: aGLHBranch repository project.
×
NEW
563
        commit := aGLHBranch commits
×
NEW
564
                add: commit
×
NEW
565
                unless: self blockOnIdEquality.
×
NEW
566
        ^ commit
×
NEW
567
]
×
568

569
{ #category : #'import - releases' }
570
GitModelImporter >> importRelease: aReleaseID ofProject: aGLHProject [
571
        self subclassResponsibility 
572
]
573

574
{ #category : #'import - tags' }
575
GitModelImporter >> importTagsForProject: aGLHProject [
576
        self subclassResponsibility 
577
]
578

579
{ #category : #'import - users' }
580
GitModelImporter >> importUser: aUserID [
581
        self subclassResponsibility 
582
]
583

584
{ #category : #'import - users' }
585
GitModelImporter >> importUserByUsername: username [
586

587
        self subclassResponsibility 
588
]
589

590
{ #category : #'private - configure reader' }
591
GitModelImporter >> initReader [
1✔
592

1✔
593
        generalReader := NeoJSONReader new.
1✔
594

1✔
595
        "will be reuse for all reader next"
1✔
596
        generalReader for: DateAndTime customDo: [ :mapping |
1✔
597
                mapping decoder: [ :string |
1✔
598
                        string ifNil: [ nil ] ifNotNil: [ DateAndTime fromString: string ] ] ].
1✔
599

1✔
600

1✔
601
        self configureReaderForCommit: generalReader.
1✔
602
        self configureReaderForGroup: generalReader.
1✔
603
        self configureReaderForDiff: generalReader.
1✔
604
        self configureReaderForMergeRequest: generalReader.
1✔
605
        self configureReaderForPipeline: generalReader.
1✔
606
        self configureReaderForTag: generalReader.
1✔
607
        self configureReaderForRelease: generalReader.
1✔
608
        self configureReaderForUser: generalReader.
1✔
609
        self configureReaderForBranch: generalReader.
1✔
610
        self configureReaderForIssue: generalReader.
1✔
611
        self configureReaderForMilestone: generalReader.
1✔
612
        self configureReaderForProject: generalReader. 
1✔
613
]
1✔
614

615
{ #category : #initialization }
616
GitModelImporter >> initialize [
1✔
617

1✔
618
        super initialize.
1✔
619
        self withCommitsSince: (Date today - 1 week) asDateAndTime.
1✔
620
        userCatalogue := GLHUserCatalogueV2 new
1✔
621
                                 anImporter: self;
1✔
622
                                 yourself.
1✔
623
                
1✔
624
        self initReader
1✔
625
]
1✔
626

627
{ #category : #initialization }
628
GitModelImporter >> makeGlobal [
×
629
        ^ self makeGlobal: DateAndTime now printString.
×
630
]
×
631

632
{ #category : #initialization }
633
GitModelImporter >> makeGlobal: aLabel [ 
×
634

×
635
        currentImporter := GithubModelImporter importers ifNil: [ OrderedDictionary new ].
×
636
        currentImporter at: aLabel put: self. 
×
637
        ^ currentImporter 
×
638
]
×
639

640
{ #category : #parsing }
641
GitModelImporter >> parseDiffString: aDiff [
1✔
642
        "parse diff string to create entities for each lines"
1✔
643

1✔
644
        | lines range index firstChangeRange |
1✔
645
        lines := aDiff diffString lines.
1✔
646
        index := 0.
1✔
647
        range := nil.
1✔
648

1✔
649
        lines ifEmpty: [ ^ aDiff diffRanges ].
1✔
650
        lines := self filterCommitChanges: lines.
1✔
651
        lines ifEmpty: [ ^ aDiff diffRanges ].
1✔
652
        (lines first beginsWith: '@@') ifFalse: [ ^ aDiff diffRanges ].
1✔
653

1✔
654
        lines do: [ :line |
1✔
655
                | aChange |
1✔
656
                firstChangeRange := false.
1✔
657
                (line trim beginsWith: #'@@') ifTrue: [
1✔
658
                        range := GLHDiffRange newFrom: line.
1✔
659
                        firstChangeRange := true.
1✔
660
                        range := aDiff diffRanges add: range unless: [ :existing :new |
1✔
661
                                         existing originalLineRange = new originalLineRange and: [
1✔
662
                                                 existing newLineRange = new newLineRange ] ] ].
1✔
663

1✔
664
                self withCommitDiffs ifTrue: [
1✔
665
                        firstChangeRange ifFalse: [
1✔
666
                                aChange := GLHChange newFrom: line.
1✔
667
                                aChange relativeIndex: index.
1✔
668
                                aChange := range changes add: aChange unless: [ :existing :new |
1✔
669
                                                   existing sourceCode = new sourceCode and: [
1✔
670
                                                           existing index = new index ] ].
1✔
671
                                index := index + 1 ] ] ].
1✔
672

1✔
673
        "add changes to the diff range"
1✔
674
        aDiff diffRanges do: [ :diffRange |
1✔
675
                self glhModel addAll: diffRange changes unless: [ :existing :new |
1✔
676
                        existing diffRange mooseID = new diffRange mooseID and: [
1✔
677
                                existing sourceCode = new sourceCode and: [
1✔
678
                                        existing index = new index ] ] ] ].
1✔
679

1✔
680
        ^ aDiff diffRanges
1✔
681
]
1✔
682

683
{ #category : #accessing }
684
GitModelImporter >> repoApi [
1✔
685

1✔
686
        ^ repoApi
1✔
687
]
1✔
688

689
{ #category : #accessing }
690
GitModelImporter >> repoApi: anObject [
1✔
691

1✔
692
        repoApi := anObject
1✔
693
]
1✔
694

695
{ #category : #accessing }
696
GitModelImporter >> userCatalogue [
1✔
697
        ^ userCatalogue 
1✔
698
]
1✔
699

700
{ #category : #accessing }
701
GitModelImporter >> userCatalogue: aGLHUserCatalogue [
×
702

×
703
        userCatalogue := aGLHUserCatalogue.
×
704
        aGLHUserCatalogue anImporter: self. 
×
705
]
×
706

707
{ #category : #accessing }
708
GitModelImporter >> withCommitDiffs [
1✔
709

1✔
710
        ^ withCommitDiffs
1✔
711
]
1✔
712

713
{ #category : #accessing }
714
GitModelImporter >> withCommitDiffs: anObject [
1✔
715

1✔
716
        withCommitDiffs := anObject
1✔
717
]
1✔
718

719
{ #category : #accessing }
720
GitModelImporter >> withCommitsSince [
×
721

×
722
        ^ withCommitsSince
×
723
]
×
724

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

1✔
729
        "(GitlabModelImporter new withCommitsSince: 1 week ) >>> (Date today - 1 week) asDateAndTime"
1✔
730

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

1✔
733
        (someDays isKindOf: DateAndTime)
1✔
734
                ifTrue: [ withCommitsSince := someDays ]
1✔
735
                ifFalse: [
1✔
736
                withCommitsSince := (DateAndTime today - someDays) ].
1✔
737
        ^ withCommitsSince
1✔
738
]
1✔
739

740
{ #category : #accessing }
741
GitModelImporter >> withFiles [
1✔
742

1✔
743
        ^ withFiles
1✔
744
]
1✔
745

746
{ #category : #accessing }
747
GitModelImporter >> withFiles: anObject [
1✔
748

1✔
749
        withFiles := anObject
1✔
750
]
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