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

moosetechnology / GitProjectHealth / 18708369676

22 Oct 2025 07:13AM UTC coverage: 77.946% (+4.6%) from 73.342%
18708369676

push

github

web-flow
Merge pull request #235 from moosetechnology/develop

4743 of 5132 new or added lines in 45 files covered. (92.42%)

32 existing lines in 8 files now uncovered.

23068 of 29595 relevant lines covered (77.95%)

0.78 hits per line

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

66.87
/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' }
262
GitModelImporter >> configureReaderForIssue: reader [
1✔
263

1✔
264
        reader mapInstVarsFor: GLHIssue .
1✔
265

1✔
266
        reader
1✔
267
                for: #ArrayOfIssue
1✔
268
                customDo: [ :customMappting |
1✔
269
                customMappting listOfElementSchema: GLHIssue ]
1✔
270
]
1✔
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' }
291
GitModelImporter >> configureReaderForMilestone: reader [
1✔
292

1✔
293
        reader mapInstVarsFor: GLHMilestone.
1✔
294

1✔
295
        reader
1✔
296
                for: #ArrayOfMilestone
1✔
297
                customDo: [ :customMappting |
1✔
298
                customMappting listOfElementSchema: GLHMilestone ]
1✔
299
]
1✔
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' }
346
GitModelImporter >> configureReaderForTag: reader [
1✔
347

1✔
348
        reader mapInstVarsFor: GLHTag.
1✔
349

1✔
350
        reader
1✔
351
                for: #ArrayOfTag
1✔
352
                customDo: [ :customMappting |
1✔
353
                customMappting listOfElementSchema: GLHTag ]
1✔
354
]
1✔
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' }
UNCOV
410
GitModelImporter >> importBranchesOf: aGLHProject [
×
UNCOV
411

×
NEW
412
        self
×
NEW
413
                deprecated: 'Use importBranchesOfProject: instead of current one'
×
NEW
414
                on: '26 September 2025'
×
NEW
415
                in:
×
NEW
416
                'Pharo-12.0.0+SNAPSHOT.build.1571.sha.cf5fcd22e66957962c97dffc58b0393b7f368147 (64 Bit)'.
×
NEW
417

×
UNCOV
418
        ^ self subclassResponsibility
×
UNCOV
419
]
×
420

421
{ #category : #'import - repositories' }
422
GitModelImporter >> importBranchesOfProject: aGLHProject [
423

424
        ^ self subclassResponsibility
425
]
426

427
{ #category : #'import - commits' }
428
GitModelImporter >> importCommit: aCommitID ofProject: aGLHProject [
429

430
        self subclassResponsibility 
431
]
432

433
{ #category : #'import - commits' }
434
GitModelImporter >> importCommitsOfBranch: aGLHBranch [
435
        self subclassResponsibility 
436
        
437
        
438
]
439

440
{ #category : #'import - commits' }
441
GitModelImporter >> importCommitsOfProject: aGLHProject since: since until: until [
442

443
        self subclassResponsibility 
444
]
445

446
{ #category : #'import - projects' }
NEW
447
GitModelImporter >> importContributedProjectsOfUser: aGLHUser [
×
NEW
448
]
×
449

450
{ #category : #'import - users' }
451
GitModelImporter >> importCreatorOfCommit: aGLHCommit [
1✔
452

1✔
453
        
1✔
454
        aGLHCommit commitCreator ifNil: [
1✔
455
                aGLHCommit commitCreator:
1✔
456
                        (self importUserByUsername: aGLHCommit author_name) ].
1✔
457
        self userCatalogue
1✔
458
                addUser: aGLHCommit commitCreator
1✔
459
                withProject: aGLHCommit repository project id.
1✔
460
        ^ aGLHCommit commitCreator
1✔
461
]
1✔
462

463
{ #category : #'import - diffs' }
464
GitModelImporter >> importDiffOfCommit: aCommit [
465

466
        self subclassResponsibility 
467
]
468

469
{ #category : #'import - diffs' }
470
GitModelImporter >> importDiffRangesForDiff: aGLHDiff [
1✔
471

1✔
472
        | diffRanges |
1✔
473
        aGLHDiff diffRanges ifNotEmpty: [
1✔
474
                ('Diffs already imported for ' , aGLHDiff printString) recordInfo.
1✔
475
                ^ aGLHDiff diffRanges ].
1✔
476

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

1✔
480
        diffRanges := self glhModel
1✔
481
                              addAll: (self parseDiffString: aGLHDiff)
1✔
482
                              unless: self blockForDiffRangeEquality.
1✔
483
        ^ aGLHDiff diffRanges
1✔
484
                  addAll: diffRanges
1✔
485
                  unless: self blockForDiffRangeEquality
1✔
486
]
1✔
487

488
{ #category : #'import - groups' }
489
GitModelImporter >> importGroup: aGroupID [
490

491
        self subclassResponsibility
492
]
493

494
{ #category : #'import - issues' }
495
GitModelImporter >> importIssuesOfProject: aGLHProject [
496
        self subclassResponsibility 
497
]
498

499
{ #category : #'import - jobs' }
NEW
500
GitModelImporter >> importJobsOf: aGLHPipeline [
×
NEW
501

×
NEW
502
        self
×
NEW
503
                deprecated: 'Use importJobsOfPipeline: instead of current one'
×
NEW
504
                on: '26 September 2025'
×
NEW
505
                in:
×
NEW
506
                'Pharo-12.0.0+SNAPSHOT.build.1571.sha.cf5fcd22e66957962c97dffc58b0393b7f368147 (64 Bit)'.
×
NEW
507
        self subclassResponsibility
×
NEW
508
]
×
509

510
{ #category : #'import - jobs' }
511
GitModelImporter >> importJobsOfPipeline: aGLHPipeline [
512

513
        self subclassResponsibility
514
]
515

516
{ #category : #'import - commits' }
517
GitModelImporter >> importLatestCommitsOfProject: aGLHProject [
518
        "limited to the last 50 commits"
519

520
        self subclassResponsibility 
521
]
522

523
{ #category : #'import - merge-requests' }
524
GitModelImporter >> importLatestMergeRequestsOfProject: aGLHProject [
525
        self subclassResponsibility 
526
]
527

528
{ #category : #'import - pipelines' }
529
GitModelImporter >> importLatestPipelinesOfProject: aGLHProject [
530
        self subclassResponsibility 
531
        
532
]
533

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

539
{ #category : #'import - merge-requests' }
NEW
540
GitModelImporter >> importMergeRequestCommits: mergeRequest [
×
NEW
541
]
×
542

543
{ #category : #'import - merge-requests' }
544
GitModelImporter >> importMergeRequestMergeCommits: aGLHMergeRequest [
545

546
        self subclassResponsibility 
547
]
548

549
{ #category : #'import - merge-requests' }
550
GitModelImporter >> importMergeRequestsOfProject: aGLHProject [
551

552
        self subclassResponsibility 
553
]
554

555
{ #category : #'import - merge-requests' }
556
GitModelImporter >> importMergeRequestsOfProject: aGLHProject since: fromDate until: toDate [
557
        self subclassResponsibility 
558
]
559

560
{ #category : #'import - merge-requests' }
NEW
561
GitModelImporter >> importMergeResquestAuthor: mergeRequest [
×
NEW
562
]
×
563

564
{ #category : #'import - merge-requests' }
NEW
565
GitModelImporter >> importMergeResquestMerger: mergeRequest [
×
NEW
566
]
×
567

568
{ #category : #'import - milestones' }
569
GitModelImporter >> importMilestonesOfProject: aGLHProject [
570
        self subclassResponsibility 
571
]
572

573
{ #category : #'import - notes' }
574
GitModelImporter >> importNotesOfMergeRequest: mergeRequest [
575

576
        self subclassResponsibility
577
]
578

579
{ #category : #'import - pipelines' }
580
GitModelImporter >> importPipeline: aPipelineId OfProject: aGLHProject [
581

582
        ^ self subclassResponsibility 
583
]
584

585
{ #category : #'import - merge-requests' }
586
GitModelImporter >> importPipelinesOfProject: aGLHProject [
587
        ^ self subclassResponsibility 
588
]
589

590
{ #category : #'import - projects' }
591
GitModelImporter >> importProject: id [
592
        "id can be a string or an integer depending on the APi implementation"
593

594
        "return the project created or retrieved"
595

596
        ^ self subclassResponsibility
597
]
598

599
{ #category : #'import - projects' }
NEW
600
GitModelImporter >> importProject: aProjectID ofGroup: aGroup [
×
NEW
601
]
×
602

603
{ #category : #'import - projects' }
604
GitModelImporter >> importProjects: aCollectionOfProjectID [
×
605

×
606

×
607
        ^ aCollectionOfProjectID collect: [ :id | self importProject: id ]
×
608
]
×
609

610
{ #category : #'import - projects' }
611
GitModelImporter >> importProjectsOfUser: aGLHUser [
612
        "https://docs.github.com/fr/rest/repos/repos?apiVersion=2022-11-28#list-repositories-for-a-user"
613
        
614
        self subclassResponsibility 
615
]
616

617
{ #category : #'import - commits' }
NEW
618
GitModelImporter >> importRefCommitOfBranch: aGLHBranch [
×
NEW
619
        |commit|
×
NEW
620
        commit := self
×
NEW
621
                                 importCommit: aGLHBranch sha
×
NEW
622
                                 ofProject: aGLHBranch repository project.
×
NEW
623
        commit := aGLHBranch commits
×
NEW
624
                add: commit
×
NEW
625
                unless: self blockOnIdEquality.
×
NEW
626
        ^ commit
×
NEW
627
]
×
628

629
{ #category : #'import - releases' }
630
GitModelImporter >> importRelease: aReleaseID ofProject: aGLHProject [
631
        self subclassResponsibility 
632
]
633

634
{ #category : #'import - tags' }
635
GitModelImporter >> importTagsForProject: aGLHProject [
636
        self subclassResponsibility 
637
]
638

639
{ #category : #'import - users' }
640
GitModelImporter >> importUser: aUserID [
641
        self subclassResponsibility 
642
]
643

644
{ #category : #'import - users' }
645
GitModelImporter >> importUserByUsername: username [
646

647
        self subclassResponsibility 
648
]
649

650
{ #category : #'private - configure reader' }
651
GitModelImporter >> initReader [
1✔
652

1✔
653
        | configurators |
1✔
654
        generalReader := NeoJSONReader new.
1✔
655

1✔
656
        "will be reuse for all reader next"
1✔
657
        "indique ce que doit faire le reader lorsqu'il parse une DateAndTime object"
1✔
658
        generalReader for: DateAndTime customDo: [ :mapping |
1✔
659
                mapping decoder: [ :string |
1✔
660
                        string ifNil: [ nil ] ifNotNil: [ DateAndTime fromString: string ] ] ].
1✔
661

1✔
662
        configurators := (self class allSelectors select: [ :m |
1✔
663
                                 m beginsWith: #configureReaderFor ]) asSet.
1✔
664

1✔
665
        configurators do: [ :configureReader |
1✔
666
                self perform: configureReader with: generalReader ]
1✔
667
]
1✔
668

669
{ #category : #initialization }
670
GitModelImporter >> initialize [
1✔
671

1✔
672
        super initialize.
1✔
673
        self withFiles: false. 
1✔
674
        self withCommitsSince: (Date today - 1 week) asDateAndTime.
1✔
675
        userCatalogue := GLHUserCatalogueV2 new
1✔
676
                                 anImporter: self;
1✔
677
                                 yourself.
1✔
678

1✔
679
        self initReader
1✔
680
]
1✔
681

682
{ #category : #initialization }
683
GitModelImporter >> makeGlobal [
×
684
        ^ self makeGlobal: DateAndTime now printString.
×
685
]
×
686

687
{ #category : #initialization }
688
GitModelImporter >> makeGlobal: aLabel [ 
×
689

×
690
        currentImporter := GithubModelImporter importers ifNil: [ OrderedDictionary new ].
×
691
        currentImporter at: aLabel put: self. 
×
692
        ^ currentImporter 
×
693
]
×
694

695
{ #category : #parsing }
696
GitModelImporter >> parseDiffString: aDiff [
1✔
697
        "parse diff string to create entities for each lines"
1✔
698

1✔
699
        | lines range index firstChangeRange |
1✔
700
        lines := aDiff diffString lines.
1✔
701
        index := 0.
1✔
702
        range := nil.
1✔
703

1✔
704
        lines ifEmpty: [ ^ aDiff diffRanges ].
1✔
705
        lines := self filterCommitChanges: lines.
1✔
706
        lines ifEmpty: [ ^ aDiff diffRanges ].
1✔
707
        (lines first beginsWith: '@@') ifFalse: [ ^ aDiff diffRanges ].
1✔
708

1✔
709
        lines do: [ :line |
1✔
710
                | aChange |
1✔
711
                firstChangeRange := false.
1✔
712
                (line trim beginsWith: #'@@') ifTrue: [
1✔
713
                        range := GLHDiffRange newFrom: line.
1✔
714
                        firstChangeRange := true.
1✔
715
                        range := aDiff diffRanges add: range unless: [ :existing :new |
1✔
716
                                         existing originalLineRange = new originalLineRange and: [
1✔
717
                                                 existing newLineRange = new newLineRange ] ] ].
1✔
718

1✔
719
                self withCommitDiffs ifTrue: [
1✔
720
                        firstChangeRange ifFalse: [
1✔
721
                                aChange := GLHChange newFrom: line.
1✔
722
                                aChange relativeIndex: index.
1✔
723
                                aChange := range changes add: aChange unless: [ :existing :new |
1✔
724
                                                   existing sourceCode = new sourceCode and: [
1✔
725
                                                           existing index = new index ] ].
1✔
726
                                index := index + 1 ] ] ].
1✔
727

1✔
728
        "add changes to the diff range"
1✔
729
        aDiff diffRanges do: [ :diffRange |
1✔
730
                self glhModel addAll: diffRange changes unless: [ :existing :new |
1✔
731
                        existing diffRange mooseID = new diffRange mooseID and: [
1✔
732
                                existing sourceCode = new sourceCode and: [
1✔
733
                                        existing index = new index ] ] ] ].
1✔
734

1✔
735
        ^ aDiff diffRanges
1✔
736
]
1✔
737

738
{ #category : #parsing }
739
GitModelImporter >> parseIssuesResult: aString [ 
740
        self subclassResponsibility 
741
]
742

743
{ #category : #accessing }
744
GitModelImporter >> repoApi [
1✔
745

1✔
746
        ^ repoApi
1✔
747
]
1✔
748

749
{ #category : #accessing }
750
GitModelImporter >> repoApi: anObject [
1✔
751

1✔
752
        repoApi := anObject
1✔
753
]
1✔
754

755
{ #category : #accessing }
756
GitModelImporter >> userCatalogue [
1✔
757
        ^ userCatalogue 
1✔
758
]
1✔
759

760
{ #category : #accessing }
761
GitModelImporter >> userCatalogue: aGLHUserCatalogue [
×
762

×
763
        userCatalogue := aGLHUserCatalogue.
×
764
        aGLHUserCatalogue anImporter: self. 
×
765
]
×
766

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

1✔
770
        ^ withCommitDiffs
1✔
771
]
1✔
772

773
{ #category : #accessing }
774
GitModelImporter >> withCommitDiffs: anObject [
1✔
775

1✔
776
        withCommitDiffs := anObject
1✔
777
]
1✔
778

779
{ #category : #accessing }
780
GitModelImporter >> withCommitsSince [
1✔
781

1✔
782
        ^ withCommitsSince
1✔
783
]
1✔
784

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

1✔
789
        "(GitlabModelImporter new withCommitsSince: 1 week ) >>> (Date today - 1 week) asDateAndTime"
1✔
790

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

1✔
793
        (someDays isKindOf: DateAndTime)
1✔
794
                ifTrue: [ withCommitsSince := someDays ]
1✔
795
                ifFalse: [
1✔
796
                withCommitsSince := (DateAndTime today - someDays) ].
1✔
797
        ^ withCommitsSince
1✔
798
]
1✔
799

800
{ #category : #accessing }
801
GitModelImporter >> withFiles [
1✔
802

1✔
803
        ^ withFiles
1✔
804
]
1✔
805

806
{ #category : #accessing }
807
GitModelImporter >> withFiles: anObject [
1✔
808

1✔
809
        withFiles := anObject
1✔
810
]
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