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

moosetechnology / GitProjectHealth / 11496852352

24 Oct 2024 09:49AM UTC coverage: 58.319% (-0.6%) from 58.906%
11496852352

Pull #92

github

web-flow
Merge pull request #91 from moosetechnology/feature-merge-metamodel

Merge Extended and default metamodel
Pull Request #92: Develop

1334 of 2585 new or added lines in 64 files covered. (51.61%)

21 existing lines in 6 files now uncovered.

9446 of 16197 relevant lines covered (58.32%)

0.58 hits per line

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

0.0
/src/BitBucketHealth-Model-Importer/BitBucketApi.class.st
1
Class {
2
        #name : 'BitBucketApi',
3
        #superclass : 'Object',
4
        #instVars : [
5
                'endpoint',
6
                'basePath',
7
                'client',
8
                'bearerToken',
9
                'apiToken',
10
                'username'
11
        ],
12
        #category : 'BitBucketHealth-Model-Importer',
13
        #package : 'BitBucketHealth-Model-Importer'
14
}
15

16
{ #category : 'api - pull-requests' }
NEW
17
BitBucketApi >> activitiesOfPullRequest: pullRequestId inRepoProjectId: repositorySlug ofProjectGroupId: projectKey [
×
18

×
19
        ^ self allValuesOfPath:
×
20
                  self basePath , '/projects/' , projectKey , '/repos/'
×
21
                  , repositorySlug , '/pull-requests/' , pullRequestId printString
×
22
                  , '/activities'
×
23
]
×
24

25
{ #category : 'private - building' }
26
BitBucketApi >> allValuesOfPath: path [
×
27

×
28
        | results values |
×
29
        self prepareZnClient.
×
30
        self client path: path.
×
31
        values := OrderedCollection new.
×
32

×
33
        [
×
34
        results := self client get.
×
35
        results := (NeoJSONReader on: results readStream) next.
×
36
        values addAll: (results at: #values).
×
37
        results
×
38
                at: #nextPageStart
×
39
                ifPresent: [
×
40
                client queryAt: #start put: (results at: #nextPageStart) ].
×
41
        results at: #isLastPage ] whileFalse.
×
42

×
43
        ^ values
×
44
]
×
45

46
{ #category : 'accessing' }
47
BitBucketApi >> apiToken [
×
48

×
49
        ^ apiToken
×
50
]
×
51

52
{ #category : 'accessing' }
53
BitBucketApi >> apiToken: anObject [
×
54

×
55
        apiToken := anObject
×
56
]
×
57

58
{ #category : 'accessing' }
59
BitBucketApi >> basePath [
×
60

×
61
        ^ basePath
×
62
]
×
63

64
{ #category : 'accessing' }
65
BitBucketApi >> basePath: anObject [
×
66

×
67
        basePath := anObject
×
68
]
×
69

70
{ #category : 'accessing' }
71
BitBucketApi >> bearerToken [
×
72

×
73
        ^ bearerToken
×
74
]
×
75

76
{ #category : 'accessing' }
77
BitBucketApi >> bearerToken: anObject [
×
78

×
79
        bearerToken := anObject
×
80
]
×
81

82
{ #category : 'accessing' }
83
BitBucketApi >> client [
×
84

×
85
        ^ client
×
86
]
×
87

88
{ #category : 'accessing' }
89
BitBucketApi >> client: anObject [
×
90

×
91
        client := anObject
×
92
]
×
93

94
{ #category : 'api - pull-requests' }
NEW
95
BitBucketApi >> commitsOfPullRequest: pullRequestId ofRepoProjectId: repoSlug inProjectGroupId: projectKey [
×
96
        ^ self allValuesOfPath: self basePath, '/projects/', projectKey, '/repos/', repoSlug, '/pull-requests/', pullRequestId printString, '/commits'.
×
97
        
×
98
]
×
99

100
{ #category : 'api - commits' }
NEW
101
BitBucketApi >> commitsOfRepoProjectId: repositorySlug inProjectGroupId: projectKey since: since until: until [
×
102
        "/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/commits"
×
103

×
104
        | results lastDate lastCommitterTimestamp commits |
×
105
        self prepareZnClient.
×
106
        self client path:
×
107
                self basePath , '/projects/' , projectKey , '/repos/'
×
108
                , repositorySlug , '/commits'.
×
NEW
109
        "self client queryAt: 'merges' put: 'exclude'."
×
110

×
111
        commits := OrderedCollection new.
×
112

×
113
        [
×
114
        results := self client get.
×
115
        results := (NeoJSONReader on: results readStream) next.
×
116
        commits addAll: (results at: #values).
×
117
        results
×
118
                at: #nextPageStart
×
119
                ifPresent: [
×
120
                client queryAt: #start put: (results at: #nextPageStart) ].
×
121

×
122
        (results at: #isLastPage)
×
123
                ifTrue: [ false ]
×
124
                ifFalse: [
×
125
                        lastCommitterTimestamp := commits last at: #authorTimestamp.
×
126
                        lastDate := DateAndTime fromUnixTime: lastCommitterTimestamp / 1000.
×
127
                        since asDate <= lastDate ] ] whileTrue.
×
128

×
129
        ^ commits select: [ :commit |
×
130
                  | commitDate |
×
131
                  commitDate := DateAndTime fromUnixTime:
×
132
                                        (commit at: #authorTimestamp) / 1000.
×
133
                  commitDate >= since asDateAndTime and:
×
134
                          commitDate <= until asDateAndTime ]
×
135
]
×
136

137
{ #category : 'api - commits' }
NEW
138
BitBucketApi >> diffsOfCommit: commitID inRepoProjectId: repositorySlug inProjectGroupId: projectKey [
×
139

×
140
        | results |
×
141
        self prepareZnClient.
×
142

×
143
        self client path:
×
144
                self basePath , '/projects/' , projectKey , '/repos/'
×
145
                , repositorySlug , '/commits/' , commitID , '/diff'.
×
146

×
147
        results := self client get.
×
148

×
149
        ^ (NeoJSONReader on: results readStream) next
×
150
]
×
151

152
{ #category : 'accessing' }
153
BitBucketApi >> endpoint [
×
154

×
155
        ^ endpoint
×
156
]
×
157

158
{ #category : 'accessing' }
159
BitBucketApi >> endpoint: anObject [
×
160

×
161
        endpoint := anObject
×
162
]
×
163

164
{ #category : 'initialization' }
165
BitBucketApi >> initialize [
×
166

×
167
        self client: (ZnClient new
×
168
                         accept: ZnMimeType applicationJson;
×
169
                         yourself).
×
170
                        
×
171
        self basePath: 'rest/api/1.0'
×
172
]
×
173

174
{ #category : 'private - building' }
175
BitBucketApi >> prepareZnClient [
×
176

×
177
        client := ZnClient new
×
178
                          accept: ZnMimeType applicationJson;
×
179
                          yourself.
×
180

×
181
        client host: self endpoint.
×
182
        client http.
×
183

×
184
        self bearerToken ifNotNil: [ :token |
×
185
                client headerAt: #Authorization put: 'Bearer ' , token ].
×
186
        self apiToken ifNotNil: [ :anApiKey |
×
187
                client headerAt: #Authorization put: 'Basic '
×
188
                        , (self username , ':' , self apiToken) utf8Encoded base64Encoded ].
×
189
]
×
190

191
{ #category : 'api - projects' }
192
BitBucketApi >> projects [
×
193
        "/rest/api/1.0/projects"
×
194

×
195
        ^ self allValuesOfPath: self basePath , '/projects'.
×
196
]
×
197

198
{ #category : 'api - pull-requests' }
NEW
199
BitBucketApi >> pullRequestsOfRepoProjectId: repositorySlug inProjectGroupId: projectKey since: since until: until [
×
200

×
201
        | pullRequests results lastCommitterTimestamp lastDate |
×
202
        self prepareZnClient.
×
203
        self client path:
×
204
                self basePath , '/projects/' , projectKey , '/repos/'
×
205
                , repositorySlug , '/pull-requests'.
×
206

×
207
        self client queryAt: 'state' put: 'all'.
×
208

×
209
        pullRequests := OrderedCollection new.
×
210

×
211
        [
×
212
        results := self client get.
×
213
        results := (NeoJSONReader on: results readStream) next.
×
214
        pullRequests addAll: (results at: #values).
×
215
        results
×
216
                at: #nextPageStart
×
217
                ifPresent: [
×
218
                client queryAt: #start put: (results at: #nextPageStart) ].
×
219

×
220
        (results at: #isLastPage)
×
221
                ifTrue: [ false ]
×
222
                ifFalse: [
×
223
                        lastCommitterTimestamp := pullRequests last at: #createdDate.
×
224
                        lastDate := DateAndTime fromUnixTime: lastCommitterTimestamp / 1000.
×
225
                        since asDate <= lastDate ] ] whileTrue.
×
226

×
227
        ^ pullRequests select: [ :commit |
×
228
                  | commitDate |
×
229
                  commitDate := DateAndTime fromUnixTime:
×
230
                                        (commit at: #createdDate) / 1000.
×
231
                  commitDate >= since asDate and: commitDate <= until asDate ]
×
232
]
×
233

234
{ #category : 'api - projects' }
NEW
235
BitBucketApi >> repositoryProjectsOfProjectGroupId: projectKey [
×
236
        ^self allValuesOfPath: self basePath, '/projects/', projectKey, '/repos'.
×
237
]
×
238

239
{ #category : 'api - user' }
240
BitBucketApi >> user: accountId [
×
241
        "https://developer.atlassian.com/cloud/bitbucket/rest/api-group-users/#api-user-get"
×
242

×
243
        self prepareZnClient.
×
244
        
×
245
        self client path: self basePath, '/user/' , accountId printString.
×
246
        ^ self client get
×
247
]
×
248

249
{ #category : 'accessing' }
250
BitBucketApi >> username [
×
251

×
252
        ^ username
×
253
]
×
254

255
{ #category : 'accessing' }
256
BitBucketApi >> username: anObject [
×
257

×
258
        username := anObject
×
259
]
×
260

261
{ #category : 'api - user' }
262
BitBucketApi >> usersByUsername: usernameString [
×
263

×
264
        | users |
×
265
        self prepareZnClient.
×
266
        self client path: self basePath , '/admin/users'.
×
267
        self client queryAt: 'filter' put: usernameString.
×
268

×
269
        users := self client get.
×
270
        users := (NeoJSONReader on: users readStream) next.
×
271

×
272
        ^ (users at: #values)
×
273
]
×
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