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

moosetechnology / GitProjectHealth / 13327290476

14 Feb 2025 10:26AM UTC coverage: 54.598% (-6.6%) from 61.181%
13327290476

Pull #129

github

web-flow
Merge 3ce8c1d16 into 84ae214d6
Pull Request #129: Renaming importer

1063 of 2238 new or added lines in 23 files covered. (47.5%)

954 existing lines in 4 files now uncovered.

9624 of 17627 relevant lines covered (54.6%)

0.55 hits per line

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

0.0
/src/GitProjectHealth-Model-Importer/GPModelImporter.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 : #GPModelImporter,
9
        #superclass : #Object,
10
        #instVars : [
11
                'withCommitsSince',
12
                'withFiles',
13
                'glhModel',
14
                'userCatalogue',
15
                'repoApi',
16
                'withCommitDiffs'
17
        ],
18
        #classVars : [
19
                'currentImporter'
20
        ],
21
        #category : #'GitProjectHealth-Model-Importer'
22
}
23

24
{ #category : #'accessing - global variables' }
25
GPModelImporter class >> importers [
×
26
        ^ currentImporter 
×
27
]
×
28

29
{ #category : #initialization }
30
GPModelImporter class >> reset [
×
31
        currentImporter := OrderedDictionary new.
×
32
]
×
33

34
{ #category : #accessing }
35
GPModelImporter >> beWithFiles [
×
36

×
37
        withFiles := true
×
38
]
×
39

40
{ #category : #accessing }
41
GPModelImporter >> beWithoutFiles [
×
42

×
43
        withFiles := false
×
44
]
×
45

46
{ #category : #'as yet unclassified' }
UNCOV
47
GPModelImporter >> blockEqualityOn: aSymbol [
×
UNCOV
48
        ^ [ :existing :new |
×
UNCOV
49
          (existing perform: aSymbol) = (new perform: aSymbol) ]
×
UNCOV
50
]
×
51

52
{ #category : #equality }
UNCOV
53
GPModelImporter >> blockForDiffEquality [
×
UNCOV
54
        ^ [ :existing :new |
×
UNCOV
55
                        existing diffString size = new diffString size and: [
×
UNCOV
56
                                existing diffString = new diffString ] ]
×
UNCOV
57
]
×
58

59
{ #category : #'as yet unclassified' }
UNCOV
60
GPModelImporter >> blockForDiffRangeEquality [
×
UNCOV
61

×
UNCOV
62
        ^ [ :existing :new |
×
UNCOV
63
          existing diff mooseID = new diff mooseID and: [
×
UNCOV
64
                  existing originalLineRange = new originalLineRange and: [
×
UNCOV
65
                          existing newLineRange = new newLineRange ] ] ]
×
UNCOV
66
]
×
67

68
{ #category : #equality }
UNCOV
69
GPModelImporter >> blockOnIdEquality [
×
UNCOV
70

×
UNCOV
71
        ^ [ :existing :new |
×
UNCOV
72
          existing id = new id ]
×
UNCOV
73
]
×
74

75
{ #category : #equality }
UNCOV
76
GPModelImporter >> blockOnNameEquality [
×
UNCOV
77

×
UNCOV
78
        ^ self blockEqualityOn: #name
×
UNCOV
79
]
×
80

81
{ #category : #commit }
UNCOV
82
GPModelImporter >> chainsCommitsFrom: commitsCollection [
×
UNCOV
83

×
UNCOV
84
        | dic |
×
UNCOV
85
        ('Chains ' , commitsCollection size printString , ' commits')
×
UNCOV
86
                recordInfo.
×
UNCOV
87

×
UNCOV
88
        dic := ((self glhModel allWithType: GLHCommit) collect: [ :commit |
×
UNCOV
89
                        commit id -> commit ]) asSet asDictionary.
×
UNCOV
90

×
UNCOV
91
        commitsCollection do: [ :commit |
×
UNCOV
92
                commit parent_ids do: [ :parentId |
×
UNCOV
93
                        dic
×
UNCOV
94
                                at: parentId
×
UNCOV
95
                                ifPresent: [ :parentCommit |
×
UNCOV
96
                                        parentCommit childCommits
×
UNCOV
97
                                                add: commit
×
UNCOV
98
                                                unless: [ :existing :new | existing id = new id ] ]
×
UNCOV
99
                                ifAbsent: [  ] ] ].
×
UNCOV
100
        ^ commitsCollection
×
UNCOV
101
]
×
102

103
{ #category : #commit }
104
GPModelImporter >> completeImportedCommit: aGLHCommit [ 
×
105
        
×
106
        
×
107
        ('completing commit: ' , aGLHCommit short_id printString) recordInfo.
×
108
        self importCreatorOfCommit: aGLHCommit.
×
109

×
110
        self withCommitDiffs ifTrue: [
×
111
                | diffs |
×
112
                aGLHCommit diffs ifEmpty: [
×
113
                        diffs := self importDiffOfCommit: aGLHCommit.
×
114
                        self glhModel addAll: diffs unless: self blockForDiffEquality ] ].
×
115

×
116
        ^ aGLHCommit
×
117
]
×
118

119
{ #category : #'as yet unclassified' }
UNCOV
120
GPModelImporter >> filterCommitChanges: aCollection [
×
UNCOV
121

×
UNCOV
122
        ^ aCollection reject: [ :line |
×
UNCOV
123
                  | trimmedLine |
×
UNCOV
124
                  trimmedLine := line trimLeft.
×
UNCOV
125
                  (trimmedLine beginsWith: '---') or: [
×
UNCOV
126
                          (trimmedLine beginsWith: '+++') or: [
×
UNCOV
127
                                  trimmedLine beginsWith: '\ No newline at end of file' ] ] ]
×
UNCOV
128
]
×
129

130
{ #category : #accessing }
UNCOV
131
GPModelImporter >> glhModel [
×
UNCOV
132

×
UNCOV
133
        ^ glhModel
×
UNCOV
134
]
×
135

136
{ #category : #accessing }
UNCOV
137
GPModelImporter >> glhModel: anObject [
×
UNCOV
138

×
UNCOV
139
        glhModel := anObject
×
UNCOV
140
]
×
141

142
{ #category : #import }
UNCOV
143
GPModelImporter >> importDiffRangesForDiff: aGLHDiff [
×
UNCOV
144

×
UNCOV
145
        | diffRanges |
×
UNCOV
146
        aGLHDiff diffRanges ifNotEmpty: [
×
UNCOV
147
                ('Diffs already imported for ' , aGLHDiff printString) recordInfo.
×
UNCOV
148
                ^ aGLHDiff diffRanges ].
×
UNCOV
149

×
UNCOV
150
        ('Import changes of diff ' , aGLHDiff printString) recordInfo.
×
UNCOV
151
        "the import of 'diffRanges' entites is technically done inside the parseDiffString"
×
UNCOV
152

×
UNCOV
153
        diffRanges := self glhModel
×
UNCOV
154
                              addAll: (self parseDiffString: aGLHDiff)
×
UNCOV
155
                              unless: self blockForDiffRangeEquality.
×
UNCOV
156
        ^ aGLHDiff diffRanges
×
UNCOV
157
                  addAll: diffRanges
×
UNCOV
158
                  unless: self blockForDiffRangeEquality
×
UNCOV
159
]
×
160

161
{ #category : #initialization }
UNCOV
162
GPModelImporter >> initialize [
×
UNCOV
163

×
UNCOV
164
        super initialize.
×
UNCOV
165
        self withCommitsSince: (Date today - 1 week) asDateAndTime.
×
UNCOV
166
                userCatalogue := GLHUserCatalogueV2 new
×
UNCOV
167
                                 anImporter: self;
×
UNCOV
168
                                 yourself.
×
UNCOV
169
]
×
170

171
{ #category : #'as yet unclassified' }
172
GPModelImporter >> makeGlobal [
×
173
        ^ self makeGlobal: DateAndTime now printString.
×
174
]
×
175

176
{ #category : #'as yet unclassified' }
177
GPModelImporter >> makeGlobal: aLabel [ 
×
178

×
179
        currentImporter := GHModelImporter importers ifNil: [ OrderedDictionary new ].
×
180
        currentImporter at: aLabel put: self. 
×
181
        ^ currentImporter 
×
182
]
×
183

184
{ #category : #parsing }
UNCOV
185
GPModelImporter >> parseDiffString: aDiff [
×
UNCOV
186
        "parse diff string to create entities for each lines"
×
UNCOV
187

×
UNCOV
188
        | lines range index firstChangeRange |
×
UNCOV
189
        lines := aDiff diffString lines.
×
UNCOV
190
        index := 0.
×
UNCOV
191
        range := nil.
×
UNCOV
192

×
UNCOV
193
        lines ifEmpty: [ ^ aDiff diffRanges ].
×
UNCOV
194
        lines := self filterCommitChanges: lines.
×
UNCOV
195
        lines ifEmpty: [ ^ aDiff diffRanges ].
×
UNCOV
196
        (lines first beginsWith: '@@') ifFalse: [ ^ aDiff diffRanges ].
×
UNCOV
197

×
UNCOV
198
        lines do: [ :line |
×
UNCOV
199
                | aChange |
×
UNCOV
200
                firstChangeRange := false.
×
UNCOV
201
                (line trim beginsWith: #'@@') ifTrue: [
×
UNCOV
202
                        range := GLHDiffRange newFrom: line.
×
UNCOV
203
                        firstChangeRange := true.
×
UNCOV
204
                        range := aDiff diffRanges add: range unless: [ :existing :new |
×
UNCOV
205
                                         existing originalLineRange = new originalLineRange and: [
×
UNCOV
206
                                                 existing newLineRange = new newLineRange ] ] ].
×
UNCOV
207

×
UNCOV
208
                self withCommitDiffs ifTrue: [
×
UNCOV
209
                        firstChangeRange ifFalse: [
×
UNCOV
210
                                aChange := GLHChange newFrom: line.
×
UNCOV
211
                                aChange relativeIndex: index.
×
UNCOV
212
                                aChange := range changes add: aChange unless: [ :existing :new |
×
UNCOV
213
                                                   existing sourceCode = new sourceCode and: [
×
UNCOV
214
                                                           existing index = new index ] ].
×
UNCOV
215
                                index := index + 1 ] ] ].
×
UNCOV
216

×
UNCOV
217
        "add changes to the diff range"
×
UNCOV
218
        aDiff diffRanges do: [ :diffRange |
×
UNCOV
219
                self glhModel addAll: diffRange changes unless: [ :existing :new |
×
UNCOV
220
                        existing diffRange mooseID = new diffRange mooseID and: [
×
UNCOV
221
                                existing sourceCode = new sourceCode and: [
×
UNCOV
222
                                        existing index = new index ] ] ] ].
×
UNCOV
223

×
UNCOV
224
        ^ aDiff diffRanges
×
UNCOV
225
]
×
226

227
{ #category : #accessing }
UNCOV
228
GPModelImporter >> repoApi [
×
UNCOV
229

×
UNCOV
230
        ^ repoApi
×
UNCOV
231
]
×
232

233
{ #category : #accessing }
UNCOV
234
GPModelImporter >> repoApi: anObject [
×
UNCOV
235

×
UNCOV
236
        repoApi := anObject
×
UNCOV
237
]
×
238

239
{ #category : #accessing }
UNCOV
240
GPModelImporter >> userCatalogue [
×
UNCOV
241
        ^ userCatalogue 
×
UNCOV
242
]
×
243

244
{ #category : #accessing }
245
GPModelImporter >> userCatalogue: aGLHUserCatalogue [
×
246

×
247
        userCatalogue := aGLHUserCatalogue.
×
248
        aGLHUserCatalogue anImporter: self. 
×
249
]
×
250

251
{ #category : #accessing }
UNCOV
252
GPModelImporter >> withCommitDiffs [
×
UNCOV
253

×
UNCOV
254
        ^ withCommitDiffs
×
UNCOV
255
]
×
256

257
{ #category : #accessing }
UNCOV
258
GPModelImporter >> withCommitDiffs: anObject [
×
UNCOV
259

×
UNCOV
260
        withCommitDiffs := anObject
×
UNCOV
261
]
×
262

263
{ #category : #accessing }
264
GPModelImporter >> withCommitsSince [
×
265

×
266
        ^ withCommitsSince
×
267
]
×
268

269
{ #category : #accessing }
UNCOV
270
GPModelImporter >> withCommitsSince: anObject [
×
UNCOV
271

×
UNCOV
272
        withCommitsSince := anObject
×
UNCOV
273
]
×
274

275
{ #category : #accessing }
UNCOV
276
GPModelImporter >> withFiles [
×
UNCOV
277

×
UNCOV
278
        ^ withFiles
×
UNCOV
279
]
×
280

281
{ #category : #accessing }
UNCOV
282
GPModelImporter >> withFiles: anObject [
×
UNCOV
283

×
UNCOV
284
        withFiles := anObject
×
UNCOV
285
]
×
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