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

moosetechnology / GitProjectHealth / 18844534946

27 Oct 2025 02:29PM UTC coverage: 77.768% (-0.2%) from 77.946%
18844534946

Pull #237

github

web-flow
Merge 3a11924c3 into 9215ab54a
Pull Request #237: feat(GLHModel): add position and suggestions in GLHNote

364 of 545 new or added lines in 8 files covered. (66.79%)

3 existing lines in 1 file now uncovered.

23412 of 30105 relevant lines covered (77.77%)

0.78 hits per line

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

65.76
/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
        ^ [ :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 }
NEW
163
GitModelImporter >> blockForNoteSuggestionEquality [
×
NEW
164

×
NEW
165

×
NEW
166
^ [ :existing :new |
×
NEW
167
         | sameLine sameNote sameContent |
×
NEW
168
          sameLine := existing to_line = new to_line.
×
NEW
169
          sameNote := existing note id = new note id.
×
NEW
170
          sameContent := existing to_content = new to_content.
×
NEW
171
          sameLine and: (sameNote and: sameContent)
×
NEW
172
        
×
NEW
173
        ]
×
NEW
174
]
×
175

176
{ #category : #equality }
177
GitModelImporter >> blockOnIdEquality [
1✔
178

1✔
179
        ^ [ :existing :new |
1✔
180
          existing id = new id ]
1✔
181
]
1✔
182

183
{ #category : #equality }
184
GitModelImporter >> blockOnNameEquality [
1✔
185

1✔
186
        ^ self blockEqualityOn: #name
1✔
187
]
1✔
188

189
{ #category : #utils }
190
GitModelImporter >> chainsCommitsFrom: commitsCollection [
1✔
191

1✔
192
        | dic |
1✔
193
        ('Chains ' , commitsCollection size printString , ' commits')
1✔
194
                recordInfo.
1✔
195

1✔
196
        dic := ((self glhModel allWithType: GLHCommit) collect: [ :commit |
1✔
197
                        commit id -> commit ]) asSet asDictionary.
1✔
198

1✔
199
        commitsCollection do: [ :commit |
1✔
200
                commit parent_ids do: [ :parentId |
1✔
201
                        dic
1✔
202
                                at: parentId
1✔
203
                                ifPresent: [ :parentCommit |
1✔
204
                                        parentCommit childCommits
1✔
205
                                                add: commit
1✔
206
                                                unless: [ :existing :new | existing id = new id ] ]
1✔
207
                                ifAbsent: [  ] ] ].
1✔
208
        ^ commitsCollection
1✔
209
]
1✔
210

211
{ #category : #'import - commits' }
212
GitModelImporter >> completeImportedCommit: aGLHCommit [ 
×
213
        
×
214
        
×
215
        ('completing commit: ' , aGLHCommit short_id printString) recordInfo.
×
216
        self importCreatorOfCommit: aGLHCommit.
×
217

×
218
        self withCommitDiffs ifTrue: [
×
219
                | diffs |
×
220
                aGLHCommit diffs ifEmpty: [
×
221
                        diffs := self importDiffOfCommit: aGLHCommit.
×
222
                        self glhModel addAll: diffs unless: self blockForDiffEquality ] ].
×
223

×
224
        ^ aGLHCommit
×
225
]
×
226

227
{ #category : #'import - projects' }
228
GitModelImporter >> completeImportedProject: aGLHProject [
×
229
]
×
230

231
{ #category : #'private - configure reader' }
232
GitModelImporter >> configureReaderForBranch: reader [
1✔
233

1✔
234
        reader mapInstVarsFor: GLHBranch.
1✔
235

1✔
236
        reader
1✔
237
                for: #ArrayOfBranch
1✔
238
                customDo: [ :customMappting |
1✔
239
                customMappting listOfElementSchema: GLHBranch ]
1✔
240
]
1✔
241

242
{ #category : #'private - configure reader' }
243
GitModelImporter >> configureReaderForCommit: reader [
1✔
244
        
1✔
245
        reader mapInstVarsFor: GLHCommit .
1✔
246
        
1✔
247
        reader
1✔
248
                for: #ArrayOfCommit
1✔
249
                customDo: [ :customMappting |
1✔
250
                customMappting listOfElementSchema: GLHCommit ]
1✔
251
]
1✔
252

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

1✔
256
        reader mapInstVarsFor: GLHDiff.
1✔
257

1✔
258
        reader
1✔
259
                for: #ArrayOfDiff
1✔
260
                customDo: [ :customMappting |
1✔
261
                customMappting listOfElementSchema: GLHDiff ]
1✔
262
]
1✔
263

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

1✔
267
        reader mapInstVarsFor: GLHGroup.
1✔
268

1✔
269
        reader
1✔
270
                for: #ArrayOfGroup
1✔
271
                customDo: [ :customMappting |
1✔
272
                customMappting listOfElementSchema: GLHGroup ]
1✔
273
]
1✔
274

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

1✔
278
        reader mapInstVarsFor: GLHIssue .
1✔
279

1✔
280
        reader
1✔
281
                for: #ArrayOfIssue
1✔
282
                customDo: [ :customMappting |
1✔
283
                customMappting listOfElementSchema: GLHIssue ]
1✔
284
]
1✔
285

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

1✔
289
        reader mapInstVarsFor: GLHJob .
1✔
290

1✔
291
        reader for: #ArrayOfJob customDo: [ :customMappting |
1✔
292
                customMappting listOfElementSchema: GLHJob ]
1✔
293
]
1✔
294

295
{ #category : #'private - configure reader' }
296
GitModelImporter >> configureReaderForMergeRequest: reader [
1✔
297

1✔
298
        reader mapInstVarsFor: GLHMergeRequest.
1✔
299

1✔
300
        reader for: #ArrayOfMergeRequest customDo: [ :customMappting |
1✔
301
                customMappting listOfElementSchema: GLHMergeRequest ]
1✔
302
]
1✔
303

304
{ #category : #'private - configure reader' }
305
GitModelImporter >> configureReaderForMilestone: reader [
1✔
306

1✔
307
        reader mapInstVarsFor: GLHMilestone.
1✔
308

1✔
309
        reader
1✔
310
                for: #ArrayOfMilestone
1✔
311
                customDo: [ :customMappting |
1✔
312
                customMappting listOfElementSchema: GLHMilestone ]
1✔
313
]
1✔
314

315
{ #category : #'private - configure reader' }
316
GitModelImporter >> configureReaderForNote: reader [
1✔
317

1✔
318
        reader mapInstVarsFor: GLHNote .
1✔
319

1✔
320
        reader
1✔
321
                for: #ArrayOfNote
1✔
322
                customDo: [ :customMappting |
1✔
323
                customMappting listOfElementSchema: GLHNote ]
1✔
324
]
1✔
325

326
{ #category : #'private - configure reader' }
327
GitModelImporter >> configureReaderForNotePosition: reader [
1✔
328

1✔
329
        reader mapInstVarsFor: GLHNotePosition.
1✔
330

1✔
331
        reader for: #ArrayOfNotePosition customDo: [ :customMapping |
1✔
332
                customMapping listOfElementSchema: GLHNotePosition ]
1✔
333
]
1✔
334

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

1✔
338
        reader mapInstVarsFor: GLHPipeline.
1✔
339

1✔
340
        reader
1✔
341
                for: #ArrayOfPipeline
1✔
342
                customDo: [ :customMappting |
1✔
343
                customMappting listOfElementSchema: GLHPipeline ]
1✔
344
]
1✔
345

346
{ #category : #'private - configure reader' }
347
GitModelImporter >> configureReaderForProject: reader [
1✔
348

1✔
349
        reader mapInstVarsFor: GLHProject.
1✔
350

1✔
351
        reader
1✔
352
                for: #ArrayOfProject
1✔
353
                customDo: [ :customMappting |
1✔
354
                customMappting listOfElementSchema: GLHProject ]
1✔
355
]
1✔
356

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

1✔
360
        reader mapInstVarsFor: GLHRelease.
1✔
361

1✔
362
        reader
1✔
363
                for: #ArrayOfRelease
1✔
364
                customDo: [ :customMappting |
1✔
365
                customMappting listOfElementSchema: GLHRelease ]
1✔
366
]
1✔
367

368
{ #category : #'private - configure reader' }
369
GitModelImporter >> configureReaderForTag: reader [
1✔
370

1✔
371
        reader mapInstVarsFor: GLHTag.
1✔
372

1✔
373
        reader
1✔
374
                for: #ArrayOfTag
1✔
375
                customDo: [ :customMappting |
1✔
376
                customMappting listOfElementSchema: GLHTag ]
1✔
377
]
1✔
378

379
{ #category : #'private - configure reader' }
380
GitModelImporter >> configureReaderForUser: reader [
1✔
381

1✔
382
        reader mapInstVarsFor: GLHUser.
1✔
383

1✔
384
        reader
1✔
385
                for: #ArrayOfUser
1✔
386
                customDo: [ :customMappting |
1✔
387
                customMappting listOfElementSchema: GLHUser ].
1✔
388
        
1✔
389
]
1✔
390

391
{ #category : #utils }
392
GitModelImporter >> filterCommitChanges: aCollection [
1✔
393

1✔
394
        ^ aCollection reject: [ :line |
1✔
395
                  | trimmedLine |
1✔
396
                  trimmedLine := line trimLeft.
1✔
397
                  (trimmedLine beginsWith: '---') or: [
1✔
398
                          (trimmedLine beginsWith: '+++') or: [
1✔
399
                                  trimmedLine beginsWith: '\ No newline at end of file' ] ] ]
1✔
400
]
1✔
401

402
{ #category : #accessing }
403
GitModelImporter >> glhModel [
1✔
404

1✔
405
        ^ glhModel
1✔
406
]
1✔
407

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

1✔
411
        glhModel := anObject
1✔
412
]
1✔
413

414
{ #category : #'import - commits' }
415
GitModelImporter >> importAndLoadLatestsCommitsOfProject: aGLHProject [
416

417
        self subclassResponsibility 
418
]
419

420
{ #category : #'import - users' }
421
GitModelImporter >> importAuthorOfCommit: aGLHCommit [
×
422

×
423
        self
×
424
                deprecated: 'Use importCreatorOfCommit: instead of current one'
×
425
                on: '19 September 2025'
×
426
                in:
×
427
                'Pharo-12.0.0+SNAPSHOT.build.1571.sha.cf5fcd22e66957962c97dffc58b0393b7f368147 (64 Bit)'.
×
428

×
429
        self subclassResponsibility
×
430
]
×
431

432
{ #category : #'import - repositories' }
433
GitModelImporter >> importBranchesOf: aGLHProject [
×
434

×
435
        self
×
436
                deprecated: 'Use importBranchesOfProject: instead of current one'
×
437
                on: '26 September 2025'
×
438
                in:
×
439
                'Pharo-12.0.0+SNAPSHOT.build.1571.sha.cf5fcd22e66957962c97dffc58b0393b7f368147 (64 Bit)'.
×
440

×
441
        ^ self subclassResponsibility
×
442
]
×
443

444
{ #category : #'import - repositories' }
445
GitModelImporter >> importBranchesOfProject: aGLHProject [
446

447
        ^ self subclassResponsibility
448
]
449

450
{ #category : #'import - commits' }
451
GitModelImporter >> importCommit: aCommitID ofProject: aGLHProject [
452

453
        self subclassResponsibility 
454
]
455

456
{ #category : #'import - commits' }
457
GitModelImporter >> importCommitsOfBranch: aGLHBranch [
458
        self subclassResponsibility 
459
        
460
        
461
]
462

463
{ #category : #'import - commits' }
464
GitModelImporter >> importCommitsOfProject: aGLHProject since: since until: until [
465

466
        self subclassResponsibility 
467
]
468

469
{ #category : #'import - projects' }
470
GitModelImporter >> importContributedProjectsOfUser: aGLHUser [
×
471
]
×
472

473
{ #category : #'import - users' }
474
GitModelImporter >> importCreatorOfCommit: aGLHCommit [
1✔
475

1✔
476
        
1✔
477
        aGLHCommit commitCreator ifNil: [
1✔
478
                aGLHCommit commitCreator:
1✔
479
                        (self importUserByUsername: aGLHCommit author_name) ].
1✔
480
        self userCatalogue
1✔
481
                addUser: aGLHCommit commitCreator
1✔
482
                withProject: aGLHCommit repository project id.
1✔
483
        ^ aGLHCommit commitCreator
1✔
484
]
1✔
485

486
{ #category : #'import - diffs' }
487
GitModelImporter >> importDiffOfCommit: aCommit [
488

489
        self subclassResponsibility 
490
]
491

492
{ #category : #'import - diffs' }
493
GitModelImporter >> importDiffRangesForDiff: aGLHDiff [
1✔
494

1✔
495
        | diffRanges |
1✔
496
        aGLHDiff diffRanges ifNotEmpty: [
1✔
497
                ('Diffs already imported for ' , aGLHDiff printString) recordInfo.
1✔
498
                ^ aGLHDiff diffRanges ].
1✔
499

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

1✔
503
        diffRanges := self glhModel
1✔
504
                              addAll: (self parseDiffString: aGLHDiff)
1✔
505
                              unless: self blockForDiffRangeEquality.
1✔
506
        ^ aGLHDiff diffRanges
1✔
507
                  addAll: diffRanges
1✔
508
                  unless: self blockForDiffRangeEquality
1✔
509
]
1✔
510

511
{ #category : #'import - groups' }
512
GitModelImporter >> importGroup: aGroupID [
513

514
        self subclassResponsibility
515
]
516

517
{ #category : #'import - issues' }
518
GitModelImporter >> importIssuesOfProject: aGLHProject [
519
        self subclassResponsibility 
520
]
521

522
{ #category : #'import - jobs' }
523
GitModelImporter >> importJobsOf: aGLHPipeline [
×
524

×
525
        self
×
526
                deprecated: 'Use importJobsOfPipeline: instead of current one'
×
527
                on: '26 September 2025'
×
528
                in:
×
529
                'Pharo-12.0.0+SNAPSHOT.build.1571.sha.cf5fcd22e66957962c97dffc58b0393b7f368147 (64 Bit)'.
×
530
        self subclassResponsibility
×
531
]
×
532

533
{ #category : #'import - jobs' }
534
GitModelImporter >> importJobsOfPipeline: aGLHPipeline [
535

536
        self subclassResponsibility
537
]
538

539
{ #category : #'import - commits' }
540
GitModelImporter >> importLatestCommitsOfProject: aGLHProject [
541
        "limited to the last 50 commits"
542

543
        self subclassResponsibility 
544
]
545

546
{ #category : #'import - merge-requests' }
547
GitModelImporter >> importLatestMergeRequestsOfProject: aGLHProject [
548
        self subclassResponsibility 
549
]
550

551
{ #category : #'import - pipelines' }
552
GitModelImporter >> importLatestPipelinesOfProject: aGLHProject [
553
        self subclassResponsibility 
554
        
555
]
556

557
{ #category : #'import - releases' }
558
GitModelImporter >> importLatestReleaseOfProject: aGLHProject [
559
        ^ self subclassResponsibility 
560
]
561

562
{ #category : #'import - merge-requests' }
563
GitModelImporter >> importMergeRequestCommits: mergeRequest [
×
564
]
×
565

566
{ #category : #'import - merge-requests' }
567
GitModelImporter >> importMergeRequestMergeCommits: aGLHMergeRequest [
568

569
        self subclassResponsibility 
570
]
571

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

575
        self subclassResponsibility 
576
]
577

578
{ #category : #'import - merge-requests' }
579
GitModelImporter >> importMergeRequestsOfProject: aGLHProject since: fromDate until: toDate [
580
        self subclassResponsibility 
581
]
582

583
{ #category : #'import - merge-requests' }
584
GitModelImporter >> importMergeResquestAuthor: mergeRequest [
×
585
]
×
586

587
{ #category : #'import - merge-requests' }
588
GitModelImporter >> importMergeResquestMerger: mergeRequest [
×
589
]
×
590

591
{ #category : #'import - milestones' }
592
GitModelImporter >> importMilestonesOfProject: aGLHProject [
593
        self subclassResponsibility 
594
]
595

596
{ #category : #'import - notes' }
597
GitModelImporter >> importNotesOfMergeRequest: mergeRequest [
598

599
        self subclassResponsibility
600
]
601

602
{ #category : #'import - pipelines' }
603
GitModelImporter >> importPipeline: aPipelineId OfProject: aGLHProject [
604

605
        ^ self subclassResponsibility 
606
]
607

608
{ #category : #'import - merge-requests' }
609
GitModelImporter >> importPipelinesOfProject: aGLHProject [
610
        ^ self subclassResponsibility 
611
]
612

613
{ #category : #'import - projects' }
614
GitModelImporter >> importProject: id [
615
        "id can be a string or an integer depending on the APi implementation"
616

617
        "return the project created or retrieved"
618

619
        ^ self subclassResponsibility
620
]
621

622
{ #category : #'import - projects' }
623
GitModelImporter >> importProject: aProjectID ofGroup: aGroup [
×
624
]
×
625

626
{ #category : #'import - projects' }
627
GitModelImporter >> importProjects: aCollectionOfProjectID [
×
628

×
629

×
630
        ^ aCollectionOfProjectID collect: [ :id | self importProject: id ]
×
631
]
×
632

633
{ #category : #'import - projects' }
634
GitModelImporter >> importProjectsOfUser: aGLHUser [
635
        "https://docs.github.com/fr/rest/repos/repos?apiVersion=2022-11-28#list-repositories-for-a-user"
636
        
637
        self subclassResponsibility 
638
]
639

640
{ #category : #'import - commits' }
641
GitModelImporter >> importRefCommitOfBranch: aGLHBranch [
×
642
        |commit|
×
643
        commit := self
×
644
                                 importCommit: aGLHBranch sha
×
645
                                 ofProject: aGLHBranch repository project.
×
646
        commit := aGLHBranch commits
×
647
                add: commit
×
648
                unless: self blockOnIdEquality.
×
649
        ^ commit
×
650
]
×
651

652
{ #category : #'import - releases' }
653
GitModelImporter >> importRelease: aReleaseID ofProject: aGLHProject [
654
        self subclassResponsibility 
655
]
656

657
{ #category : #'import - tags' }
658
GitModelImporter >> importTagsForProject: aGLHProject [
659
        self subclassResponsibility 
660
]
661

662
{ #category : #'import - users' }
663
GitModelImporter >> importUser: aUserID [
664
        self subclassResponsibility 
665
]
666

667
{ #category : #'import - users' }
668
GitModelImporter >> importUserByUsername: username [
669

670
        self subclassResponsibility 
671
]
672

673
{ #category : #'private - configure reader' }
674
GitModelImporter >> initReader [
1✔
675

1✔
676
        | configurators |
1✔
677
        generalReader := NeoJSONReader new.
1✔
678

1✔
679
        "will be reuse for all reader next"
1✔
680
        "indique ce que doit faire le reader lorsqu'il parse une DateAndTime object"
1✔
681
        generalReader for: DateAndTime customDo: [ :mapping |
1✔
682
                mapping decoder: [ :string |
1✔
683
                        string ifNil: [ nil ] ifNotNil: [ DateAndTime fromString: string ] ] ].
1✔
684

1✔
685
        configurators := (self class allSelectors select: [ :m |
1✔
686
                                  m beginsWith: #configureReaderFor ]) asSet.
1✔
687

1✔
688
        configurators do: [ :configureReader |
1✔
689
                self perform: configureReader with: generalReader ]
1✔
690
]
1✔
691

692
{ #category : #initialization }
693
GitModelImporter >> initialize [
1✔
694

1✔
695
        super initialize.
1✔
696
        self withFiles: false. 
1✔
697
        self withCommitsSince: (Date today - 1 week) asDateAndTime.
1✔
698
        userCatalogue := GLHUserCatalogueV2 new
1✔
699
                                 anImporter: self;
1✔
700
                                 yourself.
1✔
701

1✔
702
        self initReader
1✔
703
]
1✔
704

705
{ #category : #initialization }
706
GitModelImporter >> makeGlobal [
×
707
        ^ self makeGlobal: DateAndTime now printString.
×
708
]
×
709

710
{ #category : #initialization }
711
GitModelImporter >> makeGlobal: aLabel [ 
×
712

×
713
        currentImporter := GithubModelImporter importers ifNil: [ OrderedDictionary new ].
×
714
        currentImporter at: aLabel put: self. 
×
715
        ^ currentImporter 
×
716
]
×
717

718
{ #category : #parsing }
719
GitModelImporter >> parseDiffString: aDiff [
1✔
720
        "parse diff string to create entities for each lines"
1✔
721

1✔
722
        | lines range index firstChangeRange |
1✔
723
        lines := aDiff diffString lines.
1✔
724
        index := 0.
1✔
725
        range := nil.
1✔
726

1✔
727
        lines ifEmpty: [ ^ aDiff diffRanges ].
1✔
728
        lines := self filterCommitChanges: lines.
1✔
729
        lines ifEmpty: [ ^ aDiff diffRanges ].
1✔
730
        (lines first beginsWith: '@@') ifFalse: [ ^ aDiff diffRanges ].
1✔
731

1✔
732
        lines do: [ :line |
1✔
733
                | aChange |
1✔
734
                firstChangeRange := false.
1✔
735
                (line trim beginsWith: #'@@') ifTrue: [
1✔
736
                        range := GLHDiffRange newFrom: line.
1✔
737
                        firstChangeRange := true.
1✔
738
                        range := aDiff diffRanges add: range unless: [ :existing :new |
1✔
739
                                         existing originalLineRange = new originalLineRange and: [
1✔
740
                                                 existing newLineRange = new newLineRange ] ] ].
1✔
741

1✔
742
                self withCommitDiffs ifTrue: [
1✔
743
                        firstChangeRange ifFalse: [
1✔
744
                                aChange := GLHChange newFrom: line.
1✔
745
                                aChange relativeIndex: index.
1✔
746
                                aChange := range changes add: aChange unless: [ :existing :new |
1✔
747
                                                   existing sourceCode = new sourceCode and: [
1✔
748
                                                           existing index = new index ] ].
1✔
749
                                index := index + 1 ] ] ].
1✔
750

1✔
751
        "add changes to the diff range"
1✔
752
        aDiff diffRanges do: [ :diffRange |
1✔
753
                self glhModel addAll: diffRange changes unless: [ :existing :new |
1✔
754
                        existing diffRange mooseID = new diffRange mooseID and: [
1✔
755
                                existing sourceCode = new sourceCode and: [
1✔
756
                                        existing index = new index ] ] ] ].
1✔
757

1✔
758
        ^ aDiff diffRanges
1✔
759
]
1✔
760

761
{ #category : #parsing }
762
GitModelImporter >> parseIssuesResult: aString [ 
763
        self subclassResponsibility 
764
]
765

766
{ #category : #accessing }
767
GitModelImporter >> repoApi [
1✔
768

1✔
769
        ^ repoApi
1✔
770
]
1✔
771

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

1✔
775
        repoApi := anObject
1✔
776
]
1✔
777

778
{ #category : #accessing }
779
GitModelImporter >> userCatalogue [
1✔
780
        ^ userCatalogue 
1✔
781
]
1✔
782

783
{ #category : #accessing }
784
GitModelImporter >> userCatalogue: aGLHUserCatalogue [
×
785

×
786
        userCatalogue := aGLHUserCatalogue.
×
787
        aGLHUserCatalogue anImporter: self. 
×
788
]
×
789

790
{ #category : #accessing }
791
GitModelImporter >> withCommitDiffs [
1✔
792

1✔
793
        ^ withCommitDiffs
1✔
794
]
1✔
795

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

1✔
799
        withCommitDiffs := anObject
1✔
800
]
1✔
801

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

1✔
805
        ^ withCommitsSince
1✔
806
]
1✔
807

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

1✔
812
        "(GitlabModelImporter new withCommitsSince: 1 week ) >>> (Date today - 1 week) asDateAndTime"
1✔
813

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

1✔
816
        (someDays isKindOf: DateAndTime)
1✔
817
                ifTrue: [ withCommitsSince := someDays ]
1✔
818
                ifFalse: [
1✔
819
                withCommitsSince := (DateAndTime today - someDays) ].
1✔
820
        ^ withCommitsSince
1✔
821
]
1✔
822

823
{ #category : #accessing }
824
GitModelImporter >> withFiles [
1✔
825

1✔
826
        ^ withFiles
1✔
827
]
1✔
828

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

1✔
832
        withFiles := anObject
1✔
833
]
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