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

moosetechnology / GitProjectHealth / 19461083505

18 Nov 2025 09:32AM UTC coverage: 78.047% (+0.1%) from 77.946%
19461083505

Pull #240

github

web-flow
Merge 2b798f965 into 18c5cb3fc
Pull Request #240: Improve metrics

792 of 974 new or added lines in 12 files covered. (81.31%)

3 existing lines in 1 file now uncovered.

23798 of 30492 relevant lines covered (78.05%)

0.78 hits per line

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

66.15
/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 }
26
GitModelImporter class >> forBitbucketHostOn: anHostURL withToken: anApiToken [
×
27
        
×
28
        ^ self forBitbucketHostOn: anHostURL withToken: anApiToken andModel: GLHModel new. 
×
29
]
×
30

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

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

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

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

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

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

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

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

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

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

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

106
{ #category : #'class initialization' }
107
GitModelImporter class >> initialize [ 
×
108
        currentImporter := Dictionary 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

1✔
149
^ [ :existing :new |
1✔
150
          | sameSize sameDiff sameFile |
1✔
151
          sameSize := existing diffString size = new diffString size.
1✔
152
          sameDiff := existing diffString = new diffString.
1✔
153
          sameFile := existing new_path = new new_path.
1✔
154

1✔
155
          sameSize and: [ sameDiff and: [ sameFile ] ].
1✔
156
 ]
1✔
157
]
1✔
158

159
{ #category : #equality }
160
GitModelImporter >> blockForDiffRangeEquality [
1✔
161

1✔
162
        ^ [ :existing :new |
1✔
163
          existing diff mooseID = new diff mooseID and: [
1✔
164
                  existing originalLineRange = new originalLineRange and: [
1✔
165
                          existing newLineRange = new newLineRange ] ] ]
1✔
166
]
1✔
167

168
{ #category : #equality }
NEW
169
GitModelImporter >> blockForNoteSuggestionEquality [
×
NEW
170

×
NEW
171

×
NEW
172
^ [ :existing :new |
×
NEW
173
         | sameLine sameNote sameContent |
×
NEW
174
          sameLine := existing to_line = new to_line.
×
NEW
175
          sameNote := existing note id = new note id.
×
NEW
176
          sameContent := existing to_content = new to_content.
×
NEW
177
          sameLine and: (sameNote and: sameContent)
×
NEW
178
        
×
NEW
179
        ]
×
NEW
180
]
×
181

182
{ #category : #equality }
183
GitModelImporter >> blockOnIdEquality [
1✔
184

1✔
185
        ^ [ :existing :new |
1✔
186
          existing id = new id ]
1✔
187
]
1✔
188

189
{ #category : #equality }
190
GitModelImporter >> blockOnNameEquality [
1✔
191

1✔
192
        ^ self blockEqualityOn: #name
1✔
193
]
1✔
194

195
{ #category : #utils }
196
GitModelImporter >> chainsCommitsFrom: commitsCollection [
1✔
197

1✔
198
        | dic |
1✔
199
        ('Chains ' , commitsCollection size printString , ' commits')
1✔
200
                recordInfo.
1✔
201

1✔
202
        dic := ((self glhModel allWithType: GLHCommit) collect: [ :commit |
1✔
203
                        commit id -> commit ]) asSet asDictionary.
1✔
204

1✔
205
        commitsCollection do: [ :commit |
1✔
206
                commit parent_ids do: [ :parentId |
1✔
207
                        dic
1✔
208
                                at: parentId
1✔
209
                                ifPresent: [ :parentCommit |
1✔
210
                                        parentCommit childCommits
1✔
211
                                                add: commit
1✔
212
                                                unless: [ :existing :new | existing id = new id ] ]
1✔
213
                                ifAbsent: [  ] ] ].
1✔
214
        ^ commitsCollection
1✔
215
]
1✔
216

217
{ #category : #'import - commits' }
218
GitModelImporter >> completeImportedCommit: aGLHCommit [ 
×
219
        
×
220
        
×
221
        ('completing commit: ' , aGLHCommit short_id printString) recordInfo.
×
222
        self importCreatorOfCommit: aGLHCommit.
×
223

×
224
        self withCommitDiffs ifTrue: [
×
225
                | diffs |
×
226
                aGLHCommit diffs ifEmpty: [
×
227
                        diffs := self importDiffOfCommit: aGLHCommit.
×
228
                        self glhModel addAll: diffs unless: self blockForDiffEquality ] ].
×
229

×
230
        ^ aGLHCommit
×
231
]
×
232

233
{ #category : #'import - projects' }
234
GitModelImporter >> completeImportedProject: aGLHProject [
×
235
]
×
236

237
{ #category : #'private - configure reader' }
238
GitModelImporter >> configureReaderForBranch: reader [
1✔
239

1✔
240
        reader mapInstVarsFor: GLHBranch.
1✔
241

1✔
242
        reader
1✔
243
                for: #ArrayOfBranch
1✔
244
                customDo: [ :customMappting |
1✔
245
                customMappting listOfElementSchema: GLHBranch ]
1✔
246
]
1✔
247

248
{ #category : #'private - configure reader' }
249
GitModelImporter >> configureReaderForCommit: reader [
1✔
250
        
1✔
251
        reader mapInstVarsFor: GLHCommit .
1✔
252
        
1✔
253
        reader
1✔
254
                for: #ArrayOfCommit
1✔
255
                customDo: [ :customMappting |
1✔
256
                customMappting listOfElementSchema: GLHCommit ]
1✔
257
]
1✔
258

259
{ #category : #'private - configure reader' }
260
GitModelImporter >> configureReaderForDiff: reader [
1✔
261

1✔
262
        reader mapInstVarsFor: GLHDiff.
1✔
263

1✔
264
        reader
1✔
265
                for: #ArrayOfDiff
1✔
266
                customDo: [ :customMappting |
1✔
267
                customMappting listOfElementSchema: GLHDiff ]
1✔
268
]
1✔
269

270
{ #category : #'private - configure reader' }
271
GitModelImporter >> configureReaderForGroup: reader [
1✔
272

1✔
273
        reader mapInstVarsFor: GLHGroup.
1✔
274

1✔
275
        reader
1✔
276
                for: #ArrayOfGroup
1✔
277
                customDo: [ :customMappting |
1✔
278
                customMappting listOfElementSchema: GLHGroup ]
1✔
279
]
1✔
280

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

1✔
284
        reader mapInstVarsFor: GLHIssue .
1✔
285

1✔
286
        reader
1✔
287
                for: #ArrayOfIssue
1✔
288
                customDo: [ :customMappting |
1✔
289
                customMappting listOfElementSchema: GLHIssue ]
1✔
290
]
1✔
291

292
{ #category : #'private - configure reader' }
293
GitModelImporter >> configureReaderForJob: reader [
1✔
294

1✔
295
        reader mapInstVarsFor: GLHJob .
1✔
296

1✔
297
        reader for: #ArrayOfJob customDo: [ :customMappting |
1✔
298
                customMappting listOfElementSchema: GLHJob ]
1✔
299
]
1✔
300

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

1✔
304
        reader mapInstVarsFor: GLHMergeRequest.
1✔
305

1✔
306
        reader for: #ArrayOfMergeRequest customDo: [ :customMappting |
1✔
307
                customMappting listOfElementSchema: GLHMergeRequest ]
1✔
308
]
1✔
309

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

1✔
313
        reader mapInstVarsFor: GLHMilestone.
1✔
314

1✔
315
        reader
1✔
316
                for: #ArrayOfMilestone
1✔
317
                customDo: [ :customMappting |
1✔
318
                customMappting listOfElementSchema: GLHMilestone ]
1✔
319
]
1✔
320

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

1✔
324
        reader mapInstVarsFor: GLHNote .
1✔
325

1✔
326
        reader
1✔
327
                for: #ArrayOfNote
1✔
328
                customDo: [ :customMappting |
1✔
329
                customMappting listOfElementSchema: GLHNote ]
1✔
330
]
1✔
331

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

1✔
335
        reader mapInstVarsFor: GLHNotePosition.
1✔
336

1✔
337
        reader for: #ArrayOfNotePosition customDo: [ :customMapping |
1✔
338
                customMapping listOfElementSchema: GLHNotePosition ]
1✔
339
]
1✔
340

341
{ #category : #'private - configure reader' }
342
GitModelImporter >> configureReaderForPipeline: reader [
1✔
343

1✔
344
        reader mapInstVarsFor: GLHPipeline.
1✔
345

1✔
346
        reader
1✔
347
                for: #ArrayOfPipeline
1✔
348
                customDo: [ :customMappting |
1✔
349
                customMappting listOfElementSchema: GLHPipeline ]
1✔
350
]
1✔
351

352
{ #category : #'private - configure reader' }
353
GitModelImporter >> configureReaderForProject: reader [
1✔
354

1✔
355
        reader mapInstVarsFor: GLHProject.
1✔
356

1✔
357
        reader
1✔
358
                for: #ArrayOfProject
1✔
359
                customDo: [ :customMappting |
1✔
360
                customMappting listOfElementSchema: GLHProject ]
1✔
361
]
1✔
362

363
{ #category : #'private - configure reader' }
364
GitModelImporter >> configureReaderForRelease: reader [
1✔
365

1✔
366
        reader mapInstVarsFor: GLHRelease.
1✔
367

1✔
368
        reader
1✔
369
                for: #ArrayOfRelease
1✔
370
                customDo: [ :customMappting |
1✔
371
                customMappting listOfElementSchema: GLHRelease ]
1✔
372
]
1✔
373

374
{ #category : #'private - configure reader' }
375
GitModelImporter >> configureReaderForTag: reader [
1✔
376

1✔
377
        reader mapInstVarsFor: GLHTag.
1✔
378

1✔
379
        reader
1✔
380
                for: #ArrayOfTag
1✔
381
                customDo: [ :customMappting |
1✔
382
                customMappting listOfElementSchema: GLHTag ]
1✔
383
]
1✔
384

385
{ #category : #'private - configure reader' }
386
GitModelImporter >> configureReaderForUser: reader [
1✔
387

1✔
388
        reader mapInstVarsFor: GLHUser.
1✔
389

1✔
390
        reader
1✔
391
                for: #ArrayOfUser
1✔
392
                customDo: [ :customMappting |
1✔
393
                customMappting listOfElementSchema: GLHUser ].
1✔
394
        
1✔
395
]
1✔
396

397
{ #category : #utils }
398
GitModelImporter >> filterCommitChanges: aCollection [
1✔
399

1✔
400
        ^ aCollection reject: [ :line |
1✔
401
                  | trimmedLine |
1✔
402
                  trimmedLine := line trimLeft.
1✔
403
                  (trimmedLine beginsWith: '---') or: [
1✔
404
                          (trimmedLine beginsWith: '+++') or: [
1✔
405
                                  trimmedLine beginsWith: '\ No newline at end of file' ] ] ]
1✔
406
]
1✔
407

408
{ #category : #accessing }
409
GitModelImporter >> glhModel [
1✔
410

1✔
411
        ^ glhModel
1✔
412
]
1✔
413

414
{ #category : #accessing }
415
GitModelImporter >> glhModel: anObject [
1✔
416

1✔
417
        glhModel := anObject
1✔
418
]
1✔
419

420
{ #category : #'import - commits' }
421
GitModelImporter >> importAndLoadLatestsCommitsOfProject: aGLHProject [
422

423
        self subclassResponsibility 
424
]
425

426
{ #category : #'import - users' }
427
GitModelImporter >> importAuthorOfCommit: aGLHCommit [
×
428

×
429
        self
×
430
                deprecated: 'Use importCreatorOfCommit: instead of current one'
×
431
                on: '19 September 2025'
×
432
                in:
×
433
                'Pharo-12.0.0+SNAPSHOT.build.1571.sha.cf5fcd22e66957962c97dffc58b0393b7f368147 (64 Bit)'.
×
434

×
435
        self subclassResponsibility
×
436
]
×
437

438
{ #category : #'import - repositories' }
439
GitModelImporter >> importBranchesOf: aGLHProject [
×
440

×
441
        self
×
442
                deprecated: 'Use importBranchesOfProject: instead of current one'
×
443
                on: '26 September 2025'
×
444
                in:
×
445
                'Pharo-12.0.0+SNAPSHOT.build.1571.sha.cf5fcd22e66957962c97dffc58b0393b7f368147 (64 Bit)'.
×
446

×
447
        ^ self subclassResponsibility
×
448
]
×
449

450
{ #category : #'import - repositories' }
451
GitModelImporter >> importBranchesOfProject: aGLHProject [
452

453
        ^ self subclassResponsibility
454
]
455

456
{ #category : #'import - commits' }
457
GitModelImporter >> importCommit: aCommitID ofProject: aGLHProject [
458

459
        self subclassResponsibility 
460
]
461

462
{ #category : #'import - commits' }
463
GitModelImporter >> importCommitsOfBranch: aGLHBranch [
464
        self subclassResponsibility 
465
        
466
        
467
]
468

469
{ #category : #'import - commits' }
470
GitModelImporter >> importCommitsOfProject: aGLHProject since: since until: until [
471

472
        self subclassResponsibility 
473
]
474

475
{ #category : #'import - projects' }
476
GitModelImporter >> importContributedProjectsOfUser: aGLHUser [
×
477
]
×
478

479
{ #category : #'import - users' }
480
GitModelImporter >> importCreatorOfCommit: aGLHCommit [
1✔
481

1✔
482
        
1✔
483
        aGLHCommit commitCreator ifNil: [
1✔
484
                aGLHCommit commitCreator:
1✔
485
                        (self importUserByUsername: aGLHCommit author_name) ].
1✔
486
        self userCatalogue
1✔
487
                addUser: aGLHCommit commitCreator
1✔
488
                withProject: aGLHCommit repository project id.
1✔
489
        ^ aGLHCommit commitCreator
1✔
490
]
1✔
491

492
{ #category : #'import - diffs' }
493
GitModelImporter >> importDiffOfCommit: aCommit [
494

495
        self subclassResponsibility 
496
]
497

498
{ #category : #'import - diffs' }
499
GitModelImporter >> importDiffRangesForDiff: aGLHDiff [
1✔
500

1✔
501
        | diffRanges |
1✔
502
        aGLHDiff diffRanges ifNotEmpty: [
1✔
503
                ('Diffs already imported for ' , aGLHDiff printString) recordInfo.
1✔
504
                ^ aGLHDiff diffRanges ].
1✔
505

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

1✔
509
        diffRanges := self glhModel
1✔
510
                              addAll: (self parseDiffString: aGLHDiff)
1✔
511
                              unless: self blockForDiffRangeEquality.
1✔
512
        ^ aGLHDiff diffRanges
1✔
513
                  addAll: diffRanges
1✔
514
                  unless: self blockForDiffRangeEquality
1✔
515
]
1✔
516

517
{ #category : #'import - groups' }
518
GitModelImporter >> importGroup: aGroupID [
519

520
        self subclassResponsibility
521
]
522

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

528
{ #category : #'import - jobs' }
529
GitModelImporter >> importJobsOf: aGLHPipeline [
×
530

×
531
        self
×
532
                deprecated: 'Use importJobsOfPipeline: instead of current one'
×
533
                on: '26 September 2025'
×
534
                in:
×
535
                'Pharo-12.0.0+SNAPSHOT.build.1571.sha.cf5fcd22e66957962c97dffc58b0393b7f368147 (64 Bit)'.
×
536
        self subclassResponsibility
×
537
]
×
538

539
{ #category : #'import - jobs' }
540
GitModelImporter >> importJobsOfPipeline: aGLHPipeline [
541

542
        self subclassResponsibility
543
]
544

545
{ #category : #'import - commits' }
546
GitModelImporter >> importLatestCommitsOfProject: aGLHProject [
547
        "limited to the last 50 commits"
548

549
        self subclassResponsibility 
550
]
551

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

557
{ #category : #'import - pipelines' }
558
GitModelImporter >> importLatestPipelinesOfProject: aGLHProject [
559
        self subclassResponsibility 
560
        
561
]
562

563
{ #category : #'import - releases' }
564
GitModelImporter >> importLatestReleaseOfProject: aGLHProject [
565
        ^ self subclassResponsibility 
566
]
567

568
{ #category : #'import - merge-requests' }
569
GitModelImporter >> importMergeRequestCommits: mergeRequest [
×
570
]
×
571

572
{ #category : #'import - merge-requests' }
573
GitModelImporter >> importMergeRequestMergeCommits: aGLHMergeRequest [
574

575
        self subclassResponsibility 
576
]
577

578
{ #category : #'import - merge-requests' }
579
GitModelImporter >> importMergeRequestsOfProject: aGLHProject [
580

581
        self subclassResponsibility 
582
]
583

584
{ #category : #'import - merge-requests' }
585
GitModelImporter >> importMergeRequestsOfProject: aGLHProject since: fromDate until: toDate [
586
        self subclassResponsibility 
587
]
588

589
{ #category : #'import - merge-requests' }
590
GitModelImporter >> importMergeResquestAuthor: mergeRequest [
×
591
]
×
592

593
{ #category : #'import - merge-requests' }
594
GitModelImporter >> importMergeResquestMerger: mergeRequest [
×
595
]
×
596

597
{ #category : #'import - milestones' }
598
GitModelImporter >> importMilestonesOfProject: aGLHProject [
599
        self subclassResponsibility 
600
]
601

602
{ #category : #'import - notes' }
603
GitModelImporter >> importNotesOfMergeRequest: mergeRequest [
604

605
        self subclassResponsibility
606
]
607

608
{ #category : #'import - pipelines' }
609
GitModelImporter >> importPipeline: aPipelineId OfProject: aGLHProject [
610

611
        ^ self subclassResponsibility 
612
]
613

614
{ #category : #'import - merge-requests' }
615
GitModelImporter >> importPipelinesOfProject: aGLHProject [
616
        ^ self subclassResponsibility 
617
]
618

619
{ #category : #'import - projects' }
620
GitModelImporter >> importProject: id [
621
        "id can be a string or an integer depending on the APi implementation"
622

623
        "return the project created or retrieved"
624

625
        ^ self subclassResponsibility
626
]
627

628
{ #category : #'import - projects' }
629
GitModelImporter >> importProject: aProjectID ofGroup: aGroup [
×
630
]
×
631

632
{ #category : #'import - projects' }
633
GitModelImporter >> importProjects: aCollectionOfProjectID [
×
634

×
635

×
636
        ^ aCollectionOfProjectID collect: [ :id | self importProject: id ]
×
637
]
×
638

639
{ #category : #'import - projects' }
640
GitModelImporter >> importProjectsOfUser: aGLHUser [
641
        "https://docs.github.com/fr/rest/repos/repos?apiVersion=2022-11-28#list-repositories-for-a-user"
642
        
643
        self subclassResponsibility 
644
]
645

646
{ #category : #'import - commits' }
647
GitModelImporter >> importRefCommitOfBranch: aGLHBranch [
×
648
        |commit|
×
649
        commit := self
×
650
                                 importCommit: aGLHBranch sha
×
651
                                 ofProject: aGLHBranch repository project.
×
652
        commit := aGLHBranch commits
×
653
                add: commit
×
654
                unless: self blockOnIdEquality.
×
655
        ^ commit
×
656
]
×
657

658
{ #category : #'import - releases' }
659
GitModelImporter >> importRelease: aReleaseID ofProject: aGLHProject [
660
        self subclassResponsibility 
661
]
662

663
{ #category : #'import - tags' }
664
GitModelImporter >> importTagsForProject: aGLHProject [
665
        self subclassResponsibility 
666
]
667

668
{ #category : #'import - users' }
669
GitModelImporter >> importUser: aUserID [
670
        self subclassResponsibility 
671
]
672

673
{ #category : #'import - users' }
674
GitModelImporter >> importUserByUsername: username [
675

676
        self subclassResponsibility 
677
]
678

679
{ #category : #'private - configure reader' }
680
GitModelImporter >> initReader [
1✔
681

1✔
682
        | configurators |
1✔
683
        generalReader := NeoJSONReader new.
1✔
684

1✔
685
        "will be reuse for all reader next"
1✔
686
        "indique ce que doit faire le reader lorsqu'il parse une DateAndTime object"
1✔
687
        generalReader for: DateAndTime customDo: [ :mapping |
1✔
688
                mapping decoder: [ :string |
1✔
689
                        string ifNil: [ nil ] ifNotNil: [ DateAndTime fromString: string ] ] ].
1✔
690

1✔
691
        configurators := (self class allSelectors select: [ :m |
1✔
692
                                  m beginsWith: #configureReaderFor ]) asSet.
1✔
693

1✔
694
        configurators do: [ :configureReader |
1✔
695
                self perform: configureReader with: generalReader ]
1✔
696
]
1✔
697

698
{ #category : #initialization }
699
GitModelImporter >> initialize [
1✔
700

1✔
701
        super initialize.
1✔
702
        self withFiles: false. 
1✔
703
        self withCommitsSince: (Date today - 1 week) asDateAndTime.
1✔
704
        userCatalogue := GLHUserCatalogueV2 new
1✔
705
                                 anImporter: self;
1✔
706
                                 yourself.
1✔
707

1✔
708
        self initReader
1✔
709
]
1✔
710

711
{ #category : #initialization }
712
GitModelImporter >> makeGlobal [
×
713
        ^ self makeGlobal: DateAndTime now printString.
×
714
]
×
715

716
{ #category : #initialization }
717
GitModelImporter >> makeGlobal: aLabel [ 
×
718

×
719
        currentImporter := GithubModelImporter importers ifNil: [ OrderedDictionary new ].
×
720
        currentImporter at: aLabel put: self. 
×
721
        ^ currentImporter 
×
722
]
×
723

724
{ #category : #parsing }
725
GitModelImporter >> parseDiffString: aDiff [
1✔
726
        "parse diff string to create entities for each lines"
1✔
727

1✔
728
        | lines range index firstChangeRange |
1✔
729
        lines := aDiff diffString lines.
1✔
730
        index := 0.
1✔
731
        range := nil.
1✔
732

1✔
733
        lines ifEmpty: [ ^ aDiff diffRanges ].
1✔
734
        lines := self filterCommitChanges: lines.
1✔
735
        lines ifEmpty: [ ^ aDiff diffRanges ].
1✔
736
        (lines first beginsWith: '@@') ifFalse: [ ^ aDiff diffRanges ].
1✔
737

1✔
738
        lines do: [ :line |
1✔
739
                | aChange |
1✔
740
                firstChangeRange := false.
1✔
741
                (line trim beginsWith: #'@@') ifTrue: [
1✔
742
                        range := GLHDiffRange newFrom: line.
1✔
743
                        firstChangeRange := true.
1✔
744
                        range := aDiff diffRanges add: range unless: [ :existing :new |
1✔
745
                                         existing originalLineRange = new originalLineRange and: [
1✔
746
                                                 existing newLineRange = new newLineRange ] ] ].
1✔
747

1✔
748
                self withCommitDiffs ifTrue: [
1✔
749
                        firstChangeRange ifFalse: [
1✔
750
                                aChange := GLHChange newFrom: line.
1✔
751
                                aChange relativeIndex: index.
1✔
752
                                aChange := range changes add: aChange unless: [ :existing :new |
1✔
753
                                                   existing sourceCode = new sourceCode and: [
1✔
754
                                                           existing index = new index ] ].
1✔
755
                                index := index + 1 ] ] ].
1✔
756

1✔
757
        "add changes to the diff range"
1✔
758
        aDiff diffRanges do: [ :diffRange |
1✔
759
                self glhModel addAll: diffRange changes unless: [ :existing :new |
1✔
760
                        existing diffRange mooseID = new diffRange mooseID and: [
1✔
761
                                existing sourceCode = new sourceCode and: [
1✔
762
                                        existing index = new index ] ] ] ].
1✔
763

1✔
764
        ^ aDiff diffRanges
1✔
765
]
1✔
766

767
{ #category : #parsing }
768
GitModelImporter >> parseIssuesResult: aString [ 
769
        self subclassResponsibility 
770
]
771

772
{ #category : #accessing }
773
GitModelImporter >> repoApi [
1✔
774

1✔
775
        ^ repoApi
1✔
776
]
1✔
777

778
{ #category : #accessing }
779
GitModelImporter >> repoApi: anObject [
1✔
780

1✔
781
        repoApi := anObject
1✔
782
]
1✔
783

784
{ #category : #accessing }
785
GitModelImporter >> userCatalogue [
1✔
786
        ^ userCatalogue 
1✔
787
]
1✔
788

789
{ #category : #accessing }
790
GitModelImporter >> userCatalogue: aGLHUserCatalogue [
×
791

×
792
        userCatalogue := aGLHUserCatalogue.
×
793
        aGLHUserCatalogue anImporter: self. 
×
794
]
×
795

796
{ #category : #accessing }
797
GitModelImporter >> withCommitDiffs [
1✔
798

1✔
799
        ^ withCommitDiffs
1✔
800
]
1✔
801

802
{ #category : #accessing }
803
GitModelImporter >> withCommitDiffs: anObject [
1✔
804

1✔
805
        withCommitDiffs := anObject
1✔
806
]
1✔
807

808
{ #category : #accessing }
809
GitModelImporter >> withCommitsSince [
1✔
810

1✔
811
        ^ withCommitsSince
1✔
812
]
1✔
813

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

1✔
818
        "(GitlabModelImporter new withCommitsSince: 1 week ) >>> (Date today - 1 week) asDateAndTime"
1✔
819

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

1✔
822
        (someDays isKindOf: DateAndTime)
1✔
823
                ifTrue: [ withCommitsSince := someDays ]
1✔
824
                ifFalse: [
1✔
825
                withCommitsSince := (DateAndTime today - someDays) ].
1✔
826
        ^ withCommitsSince
1✔
827
]
1✔
828

829
{ #category : #accessing }
830
GitModelImporter >> withFiles [
1✔
831

1✔
832
        ^ withFiles
1✔
833
]
1✔
834

835
{ #category : #accessing }
836
GitModelImporter >> withFiles: anObject [
1✔
837

1✔
838
        withFiles := anObject
1✔
839
]
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