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

moosetechnology / GitProjectHealth / 11232401812

08 Oct 2024 09:18AM UTC coverage: 56.272% (-2.7%) from 58.976%
11232401812

push

github

web-flow
Merge pull request #80 from moosetechnology/feature/commitImportBitBucket

Feature/commit import bit bucket

134 of 270 new or added lines in 6 files covered. (49.63%)

368 existing lines in 3 files now uncovered.

8609 of 15299 relevant lines covered (56.27%)

0.56 hits per line

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

3.27
/src/BitBucketHealth-Model-Importer/BitBucketModelImporter.class.st
1
Class {
2
        #name : #BitBucketModelImporter,
3
        #superclass : #GPModelImporter,
4
        #instVars : [
5
                'withCommitDiffs',
6
                'withInitialCommits'
7
        ],
8
        #category : #'BitBucketHealth-Model-Importer'
9
}
10

11
{ #category : #accessing }
UNCOV
12
BitBucketModelImporter >> bitBucketApi [
×
UNCOV
13

×
NEW
14
        self
×
NEW
15
                deprecated: 'Use #repoApi instead'
×
NEW
16
                on: '7 October 2024'
×
NEW
17
                in:
×
NEW
18
                'Pharo-11.0.0+build.726.sha.aece1b5473acf3830a0e082c1bc3a15d4ff3522b (64 Bit)'.
×
NEW
19

×
NEW
20
        ^ repoApi
×
UNCOV
21
]
×
22

23
{ #category : #accessing }
24
BitBucketModelImporter >> bitBucketApi: anObject [
1✔
25

1✔
26
        self
1✔
27
                deprecated: 'Use #repoApi: instead'
1✔
28
                on: '7 October 2024'
1✔
29
                in:
1✔
30
                'Pharo-11.0.0+build.726.sha.aece1b5473acf3830a0e082c1bc3a15d4ff3522b (64 Bit)'.
1✔
31

1✔
32
        repoApi := anObject
1✔
33
]
1✔
34

35
{ #category : #'private - api' }
36
BitBucketModelImporter >> completeImportProject: aGLHProject [
1✔
37

1✔
38
        aGLHProject repository: GLHRepository new.
1✔
39
        self glhModel add: aGLHProject repository.
1✔
40
        "TODO: import repository"
1✔
41
        ^ aGLHProject
1✔
42
]
1✔
43

44
{ #category : #commit }
NEW
45
BitBucketModelImporter >> completeImportedCommit: aCommit [ 
×
NEW
46
        
×
NEW
47
        ('completing commit: ' , aCommit short_id printString) recordInfo.
×
NEW
48
        self importCreatorOfCommit: aCommit.
×
NEW
49

×
NEW
50
        self withCommitDiffs ifTrue: [
×
NEW
51
                | diffs |
×
NEW
52
                aCommit diffs ifEmpty: [
×
NEW
53
                        diffs := self importDiffOfCommit: aCommit.
×
NEW
54
                        self glhModel addAll: diffs unless: self blockForDiffEquality ] ].
×
NEW
55

×
NEW
56
        ^ aCommit
×
NEW
57
]
×
58

59
{ #category : #convert }
NEW
60
BitBucketModelImporter >> convertBitBucketDiffToGitDiff: response [ 
×
NEW
61
        | bitbucketDiff gitDiff filePath fromHash toHash sourceLine sourceSpan destinationLine destinationSpan result|
×
NEW
62
        
×
NEW
63
         fromHash := (response at: 'fromHash') ifNil: '' .
×
NEW
64
    toHash := (response at: 'toHash') ifNil: ''.
×
NEW
65
        
×
NEW
66
gitDiff := ''.
×
NEW
67
"Iterate over each diff in 'diffs'"
×
NEW
68
result := (response at: #diffs) collect: [:diff |
×
NEW
69

×
NEW
70
    "Extract file path, hashes"
×
NEW
71
    filePath := (diff at: 'source') at: 'toString'.
×
NEW
72

×
NEW
73
    "Build the diff header"
×
NEW
74
   " gitDiff := gitDiff , 'diff --git a/', filePath, ' b/', filePath, String cr."
×
NEW
75
   " gitDiff := gitDiff , 'index ', fromHash, '..', toHash, ' 100644', String cr."
×
NEW
76
    gitDiff := gitDiff , '--- a/', filePath, String cr.
×
NEW
77
    gitDiff := gitDiff , '+++ b/', filePath, String cr.
×
NEW
78

×
NEW
79
    "Iterate over hunks"
×
NEW
80
    (diff at: 'hunks') do: [:hunk |
×
NEW
81
        sourceLine := hunk at: 'sourceLine'.
×
NEW
82
        sourceSpan := hunk at: 'sourceSpan'.
×
NEW
83
        destinationLine := hunk at: 'destinationLine'.
×
NEW
84
        destinationSpan := hunk at: 'destinationSpan'.
×
NEW
85

×
NEW
86
        "Hunk header"
×
NEW
87
        gitDiff := gitDiff , ('@@ -{1},{2} +{3},{4} @@' format: { sourceLine. sourceSpan. destinationLine. destinationSpan }), String cr.
×
NEW
88

×
NEW
89
        "Iterate over segments"
×
NEW
90
        (hunk at: 'segments') do: [:segment |
×
NEW
91
            (segment at: 'lines') do: [:line |
×
NEW
92
                (segment at: 'type') = 'REMOVED'
×
NEW
93
                    ifTrue: [ gitDiff := gitDiff , '-', (line at: 'line'), String cr ].
×
NEW
94
                (segment at: 'type') = 'ADDED'
×
NEW
95
                    ifTrue: [ gitDiff := gitDiff , '+', (line at: 'line'), String cr ].
×
NEW
96
            ].
×
NEW
97
        ].
×
NEW
98
    ].
×
NEW
99
        GLHDiff new diffString: gitDiff; new_path: filePath; old_path: 'filePath'.
×
NEW
100
].
×
NEW
101

×
NEW
102
 ^ result
×
NEW
103

×
NEW
104
]
×
NEW
105

×
UNCOV
106
{ #category : #'private - api' }
×
UNCOV
107
BitBucketModelImporter >> getContributionFromDiffs: diffs [
×
UNCOV
108

×
UNCOV
109
        | contribution |
×
UNCOV
110
        contribution := {
×
UNCOV
111
                                ('additions' -> 0).
×
UNCOV
112
                                ('deletions' -> 0) } asDictionary.
×
UNCOV
113

×
UNCOV
114
        diffs do: [ :diff |
×
UNCOV
115
                | hunks segments |
×
UNCOV
116
                hunks := diff at: #hunks ifAbsent: Array new.
×
UNCOV
117

×
UNCOV
118
                hunks do: [ :hunk |
×
UNCOV
119
                        | addedSegment removedSegment |
×
UNCOV
120
                        segments := hunk at: #segments.
×
UNCOV
121

×
UNCOV
122
                        addedSegment := segments
×
UNCOV
123
                                                detect: [ :segment |
×
UNCOV
124
                                                (segment at: #type) = 'ADDED' ]
×
UNCOV
125
                                                ifNone: [ nil ].
×
UNCOV
126
                        removedSegment := segments
×
UNCOV
127
                                                  detect: [ :segment |
×
UNCOV
128
                                                  (segment at: #type) = 'REMOVED' ]
×
UNCOV
129
                                                  ifNone: [ nil ].
×
UNCOV
130

×
UNCOV
131
                        addedSegment ifNotNil: [
×
UNCOV
132
                                contribution
×
UNCOV
133
                                        at: #additions
×
UNCOV
134
                                        put:
×
UNCOV
135
                                        (contribution at: #additions) + (addedSegment at: #lines) size ].
×
UNCOV
136
                        removedSegment ifNotNil: [
×
UNCOV
137
                                contribution
×
UNCOV
138
                                        at: #deletions
×
UNCOV
139
                                        put:
×
UNCOV
140
                                        (contribution at: #deletions) + (removedSegment at: #lines) size ] ] ].
×
UNCOV
141

×
UNCOV
142
        ^ contribution
×
UNCOV
143
]
×
UNCOV
144

×
NEW
145
{ #category : #'comment import' }
×
NEW
146
BitBucketModelImporter >> importAndLoadLatestsCommitsOfProject: aGLHProject [ 
×
NEW
147
        
×
NEW
148
        ^ self importCommitsOfProject: aGLHProject since: (Date today - 3 week) asDateAndTime  until: Date today asDateAndTime 
×
NEW
149
]
×
NEW
150

×
UNCOV
151
{ #category : #'import - commits' }
×
UNCOV
152
BitBucketModelImporter >> importCommitsOfProject: aGLHProject since: since until: until [
×
UNCOV
153

×
UNCOV
154
        | commits |
×
NEW
155
        commits := self repoApi
×
UNCOV
156
                           commitsOfRepo: aGLHProject id
×
UNCOV
157
                           inProject: aGLHProject group id
×
UNCOV
158
                           since: since
×
UNCOV
159
                           until: until.
×
UNCOV
160

×
UNCOV
161
        commits := commits collect: [ :commit |
×
UNCOV
162
                           | glhCommit commitDiffs contribution |
×
UNCOV
163
                           glhCommit := self parseCommitIntoGLHCommit: commit.
×
NEW
164
                           commitDiffs := self repoApi
×
UNCOV
165
                                                  diffsOfCommit: glhCommit id
×
UNCOV
166
                                                  inRepo: aGLHProject id
×
UNCOV
167
                                                  inProject: aGLHProject group id.
×
UNCOV
168

×
UNCOV
169
                           contribution := self getContributionFromDiffs:
×
UNCOV
170
                                                   (commitDiffs at: #diffs).
×
UNCOV
171
                           glhCommit additions: (contribution at: #additions).
×
UNCOV
172
                           glhCommit deletions: (contribution at: #deletions).
×
UNCOV
173
                           glhCommit ].
×
UNCOV
174

×
UNCOV
175
        aGLHProject repository commits: commits.
×
UNCOV
176
        self glhModel addAll: commits unless: self blockOnIdEquality.
×
UNCOV
177

×
UNCOV
178
        ^ commits
×
UNCOV
179
]
×
UNCOV
180

×
UNCOV
181
{ #category : #'import - projects' }
×
UNCOV
182
BitBucketModelImporter >> importContributedProjectsOfUser: aGLHUser [
×
UNCOV
183

×
UNCOV
184
        | projects repositories repositoriesCommits userRepositories userProjects |
×
UNCOV
185
        "get all projects"
×
NEW
186
        projects := self repoApi projects.
×
UNCOV
187

×
UNCOV
188
        "get all repos of projects"
×
UNCOV
189
        repositories := projects flatCollect: [ :project |
×
NEW
190
                                self repoApi repositoriesOfProject:
×
UNCOV
191
                                        (project at: #key) ].
×
UNCOV
192

×
UNCOV
193

×
UNCOV
194
        "get all commits of repo"
×
UNCOV
195
        repositoriesCommits := repositories collect: [ :repository |
×
NEW
196
                                       repository -> (self repoApi
×
UNCOV
197
                                                commitsOfRepo: (repository at: #slug)
×
UNCOV
198
                                                inProject:
×
UNCOV
199
                                                ((repository at: #project) at: #key)
×
UNCOV
200
                                                since: DateAndTime now - 10 days
×
UNCOV
201
                                                until: DateAndTime now) ].
×
UNCOV
202

×
UNCOV
203

×
UNCOV
204
        "look if user is author of min one commit"
×
UNCOV
205
        userRepositories := repositoriesCommits select: [ :repository |
×
UNCOV
206
                                    | repos |
×
UNCOV
207
                                    repos := repository value
×
UNCOV
208
                                                     ifEmpty: [ false ]
×
UNCOV
209
                                                     ifNotEmpty: [
×
UNCOV
210
                                                             repository value
×
UNCOV
211
                                                                     detect: [ :commit |
×
UNCOV
212
                                                                     ((commit at: #author) at: #name)
×
UNCOV
213
                                                                     = aGLHUser username ]
×
UNCOV
214
                                                                     ifFound: [ true ]
×
UNCOV
215
                                                                     ifNone: [ false ] ] ].
×
UNCOV
216

×
UNCOV
217

×
UNCOV
218
        "Transform user repositories in GLHProject"
×
UNCOV
219
        userProjects := userRepositories collect: [ :repoCommits |
×
UNCOV
220
                                | repo project |
×
UNCOV
221
                                repo := repoCommits key.
×
UNCOV
222
                                project := repo at: #project.
×
UNCOV
223

×
UNCOV
224
                                (self glhModel allWithType: GLHProject)
×
UNCOV
225
                                        detect: [ :glhProject |
×
UNCOV
226
                                        glhProject id = (project at: #key) ]
×
UNCOV
227
                                        ifFound: [ :glhProject | glhProject ]
×
UNCOV
228
                                        ifNone: [
×
UNCOV
229
                                                | glhProject |
×
UNCOV
230
                                                glhProject := self parseRepoIntoGLHProject: repo.
×
UNCOV
231
                                                glhModel add: glhProject.
×
UNCOV
232
                                                glhProject ] ].
×
UNCOV
233

×
UNCOV
234
        aGLHUser contributedProjects: userProjects.
×
UNCOV
235

×
UNCOV
236
        ^ userProjects
×
UNCOV
237
]
×
UNCOV
238

×
UNCOV
239
{ #category : #'import - commits' }
×
UNCOV
240
BitBucketModelImporter >> importCreatorOfCommit: aGLHCommit [
×
UNCOV
241

×
UNCOV
242
        | creator |
×
UNCOV
243
        (self glhModel allWithType: GLHUser)
×
UNCOV
244
                detect: [ :user | user username = aGLHCommit author_name ]
×
UNCOV
245
                ifFound: [ :user |
×
UNCOV
246
                        aGLHCommit commitCreator: user.
×
UNCOV
247
                        ^ user ].
×
UNCOV
248

×
UNCOV
249
        creator := self importUserByUsername: aGLHCommit author_name.
×
UNCOV
250
        aGLHCommit commitCreator: creator.
×
UNCOV
251
        ^ creator
×
UNCOV
252
]
×
UNCOV
253

×
NEW
254
{ #category : #api }
×
NEW
255
BitBucketModelImporter >> importDiffOfCommit: aCommit [
×
NEW
256

×
NEW
257
        | result diffsResult |
×
NEW
258
        aCommit diffs ifNotEmpty: [
×
NEW
259
                'Diff already importer: ' , aCommit short_id printString recordInfo.
×
NEW
260
                ^ aCommit diffs ].
×
NEW
261
        ('Import diff of commit: ' , aCommit short_id printString) recordInfo.
×
NEW
262
        result := self repoApi
×
NEW
263
                          diffsOfCommit: aCommit id
×
NEW
264
                          inRepo: aCommit repository project id
×
NEW
265
                          inProject: aCommit repository project group id.
×
NEW
266

×
NEW
267
        diffsResult := self convertBitBucketDiffToGitDiff: result.
×
NEW
268

×
NEW
269

×
NEW
270
        aCommit diffs addAll: diffsResult unless: self blockForDiffEquality.
×
NEW
271

×
NEW
272
        "changes are added into the model during the import"
×
NEW
273
        aCommit diffs do: [ :diff | self importDiffRangesForDiff: diff ].
×
NEW
274

×
NEW
275
        ^ aCommit diffs
×
NEW
276
]
×
NEW
277

×
UNCOV
278
{ #category : #'import - merge-requests' }
×
UNCOV
279
BitBucketModelImporter >> importMergeRequestCommits: mergeRequest [
×
UNCOV
280

×
UNCOV
281
        | commits |
×
NEW
282
        commits := self repoApi
×
UNCOV
283
                           commitsOfPullRequest: mergeRequest id
×
UNCOV
284
                           ofRepo: mergeRequest project id
×
UNCOV
285
                           inProject: mergeRequest project group id.
×
UNCOV
286

×
UNCOV
287
        commits := commits collect: [ :commit |
×
UNCOV
288
                           self parseCommitIntoGLHCommit: commit ].
×
UNCOV
289

×
UNCOV
290
        mergeRequest commits: commits.
×
UNCOV
291

×
UNCOV
292
        ^ commits
×
UNCOV
293
]
×
UNCOV
294

×
UNCOV
295
{ #category : #'import - merge-requests' }
×
UNCOV
296
BitBucketModelImporter >> importMergeRequests: aGLHProject since: fromDate until: toDate [
×
UNCOV
297

×
UNCOV
298
        | pullRequests |
×
NEW
299
        pullRequests := self repoApi
×
UNCOV
300
                                pullRequestsOfRepo: aGLHProject id
×
UNCOV
301
                                inProject: aGLHProject group id
×
UNCOV
302
                                since: fromDate
×
UNCOV
303
                                until: toDate.
×
UNCOV
304

×
UNCOV
305
        pullRequests := pullRequests collect: [ :pullRequest |
×
UNCOV
306
                                self parsePullRequestIntoGLPHEMergeRequest:
×
UNCOV
307
                                        pullRequest ].
×
UNCOV
308

×
UNCOV
309
        self glhModel addAll: pullRequests unless: self blockOnIdEquality.
×
UNCOV
310

×
UNCOV
311
        ^ pullRequests
×
UNCOV
312
]
×
UNCOV
313

×
UNCOV
314
{ #category : #'import - merge-requests' }
×
315
BitBucketModelImporter >> importMergeResquestAuthor: mergeRequest [
×
316
        mergeRequest author ifNotNil: [ ^mergeRequest ]
×
317
]
×
UNCOV
318

×
UNCOV
319
{ #category : #'import - merge-requests' }
×
UNCOV
320
BitBucketModelImporter >> importMergeResquestMerger: mergeRequest [
×
UNCOV
321

×
UNCOV
322
        | activities mergeActivity mergeUser |
×
UNCOV
323
        mergeRequest merge_user ifNotNil: [ ^ mergeRequest merge_user ].
×
UNCOV
324
        mergeRequest state = 'merged' ifFalse: [ ^ nil ].
×
UNCOV
325

×
NEW
326
        activities := self repoApi
×
UNCOV
327
                              activitiesOfPullRequest: mergeRequest id
×
UNCOV
328
                              inRepo: mergeRequest project id
×
UNCOV
329
                              ofProject: mergeRequest project group id.
×
UNCOV
330

×
UNCOV
331
        mergeActivity := activities detect: [ :activity |
×
UNCOV
332
                                 (activity at: #action) = 'MERGED' ].
×
UNCOV
333

×
UNCOV
334
        mergeUser := mergeActivity at: #user.
×
UNCOV
335

×
UNCOV
336
        mergeUser := (glhModel allWithType: GLHUser)
×
UNCOV
337
                             detect: [ :user | user id = (mergeUser at: #id) ]
×
UNCOV
338
                             ifFound: [ :user | user ]
×
UNCOV
339
                             ifNone: [
×
UNCOV
340
                                     | glhUser |
×
UNCOV
341
                                     glhUser := self parseUserIntoGLHUser: mergeUser.
×
UNCOV
342
                                     glhModel add: glhUser.
×
UNCOV
343
                                     glhUser ].
×
UNCOV
344

×
UNCOV
345
        mergeRequest merge_user: mergeUser.
×
UNCOV
346
        ^ mergeUser
×
UNCOV
347
]
×
UNCOV
348

×
UNCOV
349
{ #category : #'import - users' }
×
UNCOV
350
BitBucketModelImporter >> importUserByUsername: username [
×
UNCOV
351

×
NEW
352
         
×
UNCOV
353

×
NEW
354
        ^ self userCatalogue collectUsernames at: username ifAbsent: [
×
NEW
355
                |users glhUser user|
×
NEW
356
                
×
NEW
357
                users := self repoApi usersByUsername: username.
×
NEW
358
                users ifEmpty: [ ^ nil ].
×
NEW
359
                user := users first.
×
NEW
360

×
NEW
361
                glhUser := self parseUserIntoGLHUser: user.
×
NEW
362
                self glhModel add: glhUser unless: self blockOnIdEquality.
×
NEW
363
                self userCatalogue addUser: glhUser withName: username. 
×
NEW
364
                glhUser
×
NEW
365
                 ].
×
NEW
366
        
×
NEW
367
        
×
UNCOV
368
]
×
UNCOV
369

×
UNCOV
370
{ #category : #parsing }
×
UNCOV
371
BitBucketModelImporter >> parseCommitIntoGLHCommit: commitDictionary [
×
UNCOV
372

×
UNCOV
373
        | author committer parentIds |
×
UNCOV
374
        author := commitDictionary at: #author.
×
UNCOV
375
        committer := commitDictionary at: #committer.
×
UNCOV
376

×
UNCOV
377
        parentIds := (commitDictionary at: #parents) collect: [ :parent |
×
UNCOV
378
                             parent at: #id ].
×
UNCOV
379

×
UNCOV
380
        ^ GLHCommit new
×
UNCOV
381
                  id: (commitDictionary at: #id);
×
UNCOV
382
                  message: (commitDictionary at: #message);
×
UNCOV
383
                  author_email: (author at: #emailAddress);
×
UNCOV
384
                  author_name: (author at: #name);
×
UNCOV
385
                  authored_date: (DateAndTime fromUnixTime:
×
UNCOV
386
                                           (commitDictionary at: #authorTimestamp) / 1000);
×
UNCOV
387
                  created_at: (DateAndTime fromUnixTime:
×
UNCOV
388
                                           (commitDictionary at: #authorTimestamp) / 1000);
×
UNCOV
389
                  committed_date: (DateAndTime fromUnixTime:
×
UNCOV
390
                                           (commitDictionary at: #committerTimestamp) / 1000);
×
UNCOV
391
                  committer_email: (committer at: #emailAddress);
×
UNCOV
392
                  committer_name: (committer at: #name);
×
UNCOV
393
                  parent_ids: parentIds
×
UNCOV
394
]
×
UNCOV
395

×
UNCOV
396
{ #category : #parsing }
×
UNCOV
397
BitBucketModelImporter >> parseProjectIntoGLHGroup: projectRepository [
×
UNCOV
398

×
UNCOV
399
        ^GLHGroup new
×
UNCOV
400
                                                     name: (projectRepository at: #name);
×
UNCOV
401
                                                     id: (projectRepository at: #key);
×
UNCOV
402
                                                     description: (projectRepository at: #description).
×
UNCOV
403
]
×
UNCOV
404

×
UNCOV
405
{ #category : #parsing }
×
UNCOV
406
BitBucketModelImporter >> parsePullRequestIntoGLPHEMergeRequest: pullRequestDictionary [
×
UNCOV
407

×
UNCOV
408
        | repository project toRef fromRef glpheMergeRequest author state reviewers |
×
UNCOV
409
        toRef := pullRequestDictionary at: #toRef.
×
UNCOV
410
        fromRef := pullRequestDictionary at: #fromRef.
×
UNCOV
411
        
×
UNCOV
412
        reviewers := pullRequestDictionary at: #reviewers.
×
UNCOV
413
        reviewers := reviewers collect: [ :reviewer | 
×
UNCOV
414
                |reviewerUser|
×
UNCOV
415
                reviewerUser := reviewer at: #user.
×
UNCOV
416
                (self glhModel allWithType: GLHUser) detect: [ :user | user id = (reviewerUser at: #id) ]         ifFound: [ :user | user ] ifNone: [ 
×
UNCOV
417
                        |glhUser|
×
UNCOV
418
                        glhUser := self parseUserIntoGLHUser: reviewerUser.
×
UNCOV
419
                        glhModel  add: glhUser.
×
UNCOV
420
                        glhUser.                
×
UNCOV
421
                ]
×
UNCOV
422
                
×
UNCOV
423
        ].
×
UNCOV
424

×
UNCOV
425
        repository := toRef at: #repository.
×
UNCOV
426
        project := (self glhModel allWithType: GLHProject)
×
UNCOV
427
                           detect: [ :glhProject |
×
UNCOV
428
                           glhProject id = (repository at: #id) ]
×
UNCOV
429
                           ifFound: [ :glhProject | glhProject ]
×
UNCOV
430
                           ifNone: [
×
UNCOV
431
                                   project := self parseRepoIntoGLHProject: repository.
×
UNCOV
432
                                   self glhModel add: project.
×
UNCOV
433
                                   project ].
×
UNCOV
434

×
UNCOV
435

×
UNCOV
436
        author := pullRequestDictionary at: #author.
×
UNCOV
437
        author := (self glhModel allWithType: GLHUser)
×
UNCOV
438
                          detect: [ :user | user id = ((author at: #user) at: #id) ]
×
UNCOV
439
                          ifFound: [ :user | user ]
×
UNCOV
440
                          ifNone: [
×
UNCOV
441
                          self importUserByUsername:
×
UNCOV
442
                                  ((author at: #user) at: #displayName) ].
×
UNCOV
443

×
UNCOV
444

×
UNCOV
445
        glpheMergeRequest := GLPHEMergeRequest new
×
UNCOV
446
                                     name: (pullRequestDictionary at: #title);
×
UNCOV
447
                                     title: (pullRequestDictionary at: #title);
×
UNCOV
448
                                     id: (pullRequestDictionary at: #id);
×
UNCOV
449
                                     project: project;
×
UNCOV
450
                                     project_id: project id;
×
UNCOV
451
                                     target_branch: (toRef at: #id);
×
UNCOV
452
                                     target_project_id:
×
UNCOV
453
                                             ((toRef at: #repository) at: #id);
×
UNCOV
454
                                     source_branch: (fromRef at: #id);
×
UNCOV
455
                                     target_project_id:
×
UNCOV
456
                                             ((fromRef at: #repository) at: #id);
×
UNCOV
457
                                     updated_at: (DateAndTime fromUnixTime:
×
UNCOV
458
                                                              (pullRequestDictionary at: #updatedDate)
×
UNCOV
459
                                                              / 1000);
×
UNCOV
460
                                     created_at: (DateAndTime fromUnixTime:
×
UNCOV
461
                                                              (pullRequestDictionary at: #createdDate)
×
UNCOV
462
                                                              / 1000);
×
UNCOV
463
                                     author: author.
×
UNCOV
464

×
UNCOV
465
        "STATE"
×
UNCOV
466
        state := pullRequestDictionary at: #state.
×
UNCOV
467
        state = 'OPEN' ifTrue: [ glpheMergeRequest state: 'opened' ].
×
UNCOV
468
        state = 'MERGED' ifTrue: [
×
UNCOV
469
                glpheMergeRequest state: 'merged'.
×
UNCOV
470
                glpheMergeRequest merged_at: (DateAndTime fromUnixTime:
×
UNCOV
471
                                 (pullRequestDictionary at: #closedDate) / 1000) ].
×
UNCOV
472

×
UNCOV
473
        state = 'DECLINED' ifTrue: [
×
UNCOV
474
                glpheMergeRequest state: 'closed'.
×
UNCOV
475
                glpheMergeRequest closed_at: (DateAndTime fromUnixTime:
×
UNCOV
476
                                 (pullRequestDictionary at: #closedDate) / 1000) ].
×
UNCOV
477

×
UNCOV
478
        ^ glpheMergeRequest
×
UNCOV
479
]
×
UNCOV
480

×
UNCOV
481
{ #category : #parsing }
×
UNCOV
482
BitBucketModelImporter >> parseRepoIntoGLHProject: repositoryDictionary [
×
UNCOV
483

×
UNCOV
484
        | project group glhProject |
×
UNCOV
485
        project := repositoryDictionary at: #project.
×
UNCOV
486

×
UNCOV
487
        group := (self glhModel allWithType: GLHGroup)
×
UNCOV
488
                         detect: [ :glhGroup | glhGroup id = (project at: #key) ]
×
UNCOV
489
                         ifFound: [ :glhGroup | glhGroup ]
×
UNCOV
490
                         ifNone: [
×
UNCOV
491
                                 | newGroup |
×
UNCOV
492
                                 newGroup := self parseProjectIntoGLHGroup: project.
×
UNCOV
493
                                 glhModel add: newGroup.
×
UNCOV
494
                                 newGroup ].
×
UNCOV
495

×
UNCOV
496

×
UNCOV
497
        glhProject := GLHProject new
×
UNCOV
498
                              name: (repositoryDictionary at: #name);
×
UNCOV
499
                              id: (repositoryDictionary at: #slug);
×
UNCOV
500
                                                  repository: GLHRepository new;
×
UNCOV
501
                              group: group.
×
UNCOV
502

×
UNCOV
503
        group addProject: glhProject.
×
UNCOV
504

×
UNCOV
505
        ^ glhProject
×
UNCOV
506
]
×
UNCOV
507

×
UNCOV
508
{ #category : #parsing }
×
UNCOV
509
BitBucketModelImporter >> parseUserIntoGLHUser: userDictionnary [
×
UNCOV
510

×
UNCOV
511
        ^ GLHUser new name: (userDictionnary at: #displayName);
×
UNCOV
512
                public_email: (userDictionnary at: #emailAddress);
×
UNCOV
513
                id: (userDictionnary at: #id);
×
UNCOV
514
                username: (userDictionnary at: #name).
×
UNCOV
515
]
×
UNCOV
516

×
UNCOV
517
{ #category : #accessing }
×
518
BitBucketModelImporter >> withCommitDiffs [
×
519

×
520
        ^ withCommitDiffs
×
521
]
×
UNCOV
522

×
UNCOV
523
{ #category : #accessing }
×
524
BitBucketModelImporter >> withCommitDiffs: anObject [
×
525

×
526
        withCommitDiffs := anObject
×
527
]
×
UNCOV
528

×
UNCOV
529
{ #category : #accessing }
×
530
BitBucketModelImporter >> withInitialCommits [
×
531

×
532
        ^ withInitialCommits
×
533
]
×
UNCOV
534

×
UNCOV
535
{ #category : #accessing }
×
536
BitBucketModelImporter >> withInitialCommits: anObject [
×
537

×
538
        withInitialCommits := anObject
×
539
]
×
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

© 2025 Coveralls, Inc