Basic tag search and range
parent: tbd commit: 112ca96
1 | use |
2 | , | UserAuthenticationToken
3 | , |
4 | |
5 | AuthenticationTokenRequest, Instance, RegisterAccountRequest, RepositoryCreateRequest, |
6 | , |
7 | , | ObjectBackend
8 | |
9 | Commit, DefaultBranch, Description, LatestCommit, Repository, RepositoryBranch, |
10 | RepositoryBranchRequest, RepositoryBranchesRequest, RepositoryCommitBeforeRequest, |
11 | RepositoryCommitFromIdRequest, RepositoryDiff, RepositoryDiffPatchRequest, |
12 | RepositoryDiffRequest, RepositoryFile, RepositoryFileFromIdRequest, |
13 | RepositoryFileFromPathRequest, RepositoryFileInspectRequest, RepositoryInfoRequest, |
14 | RepositoryLastCommitOfFileRequest, RepositoryStatistics, RepositoryStatisticsRequest, |
15 | RepositorySummary, RepositoryTag, RepositoryTagsRequest, RepositoryView, Visibility, |
16 | , |
17 | , |
18 | ; |
19 | use ; |
20 | |
21 | use DatabaseBackend; |
22 | |
23 | pub async |
24 | object: User, |
25 | _operation: UserRepositoriesRequest, |
26 | state: DatabaseBackend, |
27 | OperationState | : ,
28 | requester: , |
29 | |
30 | let object = object.clone; |
31 | |
32 | let mut user_backend = state.user_backend.lock .await; |
33 | let repositories_response = user_backend |
34 | .repositories_for_user |
35 | .await |
36 | .as_internal_error?; |
37 | drop; |
38 | let mut repositories_backend = state.repository_backend.lock .await; |
39 | |
40 | let mut repositories = vec!; |
41 | |
42 | for repository in repositories_response |
43 | if repositories_backend |
44 | .exists |
45 | .await |
46 | .as_internal_error? |
47 | |
48 | repositories.push; |
49 | |
50 | |
51 | |
52 | Ok |
53 | |
54 | |
55 | pub async |
56 | object: Repository, |
57 | operation: RepositoryInfoRequest, |
58 | state: DatabaseBackend, |
59 | OperationState | : ,
60 | backend: GiteratedStack, |
61 | requester: , |
62 | |
63 | info!; |
64 | let mut object = backend |
65 | . |
66 | .await |
67 | .unwrap; |
68 | let mut repository_backend = state.repository_backend.lock .await; |
69 | let tree = repository_backend |
70 | .repository_file_inspect |
71 | &requester, |
72 | object.object, |
73 | &RepositoryFileInspectRequest |
74 | extra_metadata: operation.extra_metadata, |
75 | path: operation.path.clone, |
76 | rev: operation.rev.clone, |
77 | , |
78 | |
79 | .await |
80 | .as_internal_error?; |
81 | |
82 | let statistics = repository_backend |
83 | .repository_get_statistics |
84 | &requester, |
85 | object.object, |
86 | &RepositoryStatisticsRequest |
87 | rev: operation.rev.clone, |
88 | , |
89 | |
90 | .await |
91 | .as_internal_error?; |
92 | drop; |
93 | |
94 | let info = RepositoryView |
95 | name: object.object .name.clone, |
96 | owner: object.object .owner.clone, |
97 | description: object. .await.ok, |
98 | visibility: object |
99 | . |
100 | .await |
101 | .as_internal_error?, |
102 | default_branch: object |
103 | . |
104 | .await |
105 | .as_internal_error?, |
106 | // TODO: Can't be a simple get function, this needs to be returned alongside the tree as this differs depending on the rev and path. |
107 | latest_commit: object. .await.ok, |
108 | stats: statistics, |
109 | tree_rev: operation.rev.clone, |
110 | tree, |
111 | ; |
112 | |
113 | Ok |
114 | |
115 | |
116 | pub async |
117 | object: Repository, |
118 | operation: RepositoryStatisticsRequest, |
119 | state: DatabaseBackend, |
120 | OperationState | : ,
121 | backend: GiteratedStack, |
122 | requester: , |
123 | |
124 | let object = backend |
125 | . |
126 | .await |
127 | .unwrap; |
128 | |
129 | let mut repository_backend = state.repository_backend.lock .await; |
130 | let statistics = repository_backend |
131 | .repository_get_statistics |
132 | &requester, |
133 | object.object, |
134 | &RepositoryStatisticsRequest |
135 | rev: operation.rev.clone, |
136 | , |
137 | |
138 | .await |
139 | .as_internal_error?; |
140 | drop; |
141 | |
142 | Ok |
143 | |
144 | |
145 | pub async |
146 | object: Repository, |
147 | operation: RepositoryBranchesRequest, |
148 | state: DatabaseBackend, |
149 | OperationState | : ,
150 | backend: GiteratedStack, |
151 | requester: , |
152 | |
153 | let mut object = backend |
154 | . |
155 | .await |
156 | .unwrap; |
157 | |
158 | let mut repository_backend = state.repository_backend.lock .await; |
159 | let branches = repository_backend |
160 | .repository_get_branches |
161 | &requester, |
162 | &mut object, |
163 | OperationState, |
164 | &operation, |
165 | |
166 | .await |
167 | .as_internal_error?; |
168 | drop; |
169 | |
170 | Ok |
171 | |
172 | |
173 | pub async |
174 | object: Repository, |
175 | operation: RepositoryBranchRequest, |
176 | state: DatabaseBackend, |
177 | OperationState | : ,
178 | backend: GiteratedStack, |
179 | requester: , |
180 | |
181 | let mut object = backend |
182 | . |
183 | .await |
184 | .unwrap; |
185 | |
186 | let mut repository_backend = state.repository_backend.lock .await; |
187 | let branch = repository_backend |
188 | .repository_get_branch |
189 | &requester, |
190 | &mut object, |
191 | OperationState, |
192 | &operation, |
193 | |
194 | .await |
195 | .as_internal_error?; |
196 | drop; |
197 | |
198 | Ok |
199 | |
200 | |
201 | pub async |
202 | object: Repository, |
203 | operation: RepositoryTagsRequest, |
204 | state: DatabaseBackend, |
205 | OperationState | : ,
206 | backend: GiteratedStack, |
207 | requester: , |
208 | |
209 | let mut object = backend |
210 | . |
211 | .await |
212 | .unwrap; |
213 | |
214 | let mut repository_backend = state.repository_backend.lock .await; |
215 | let branches = repository_backend |
216 | .repository_get_tags |
217 | &requester, |
218 | &mut object, |
219 | OperationState, |
220 | &operation, |
221 | |
222 | .await |
223 | .as_internal_error?; |
224 | drop; |
225 | |
226 | Ok |
227 | |
228 | |
229 | pub async |
230 | object: Repository, |
231 | operation: RepositoryFileFromIdRequest, |
232 | state: DatabaseBackend, |
233 | OperationState | : ,
234 | backend: GiteratedStack, |
235 | requester: , |
236 | |
237 | let object = backend |
238 | . |
239 | .await |
240 | .unwrap; |
241 | |
242 | let mut repository_backend = state.repository_backend.lock .await; |
243 | let file = repository_backend |
244 | .repository_file_from_id |
245 | &requester, |
246 | object.object, |
247 | &RepositoryFileFromIdRequest, |
248 | |
249 | .await |
250 | .as_internal_error?; |
251 | drop; |
252 | |
253 | Ok |
254 | |
255 | |
256 | pub async |
257 | object: Repository, |
258 | operation: RepositoryFileFromPathRequest, |
259 | state: DatabaseBackend, |
260 | OperationState | : ,
261 | backend: GiteratedStack, |
262 | requester: , |
263 | |
264 | let object = backend |
265 | . |
266 | .await |
267 | .unwrap; |
268 | |
269 | let mut repository_backend = state.repository_backend.lock .await; |
270 | let file = repository_backend |
271 | .repository_file_from_path |
272 | &requester, |
273 | object.object, |
274 | &RepositoryFileFromPathRequest |
275 | rev: operation.rev.clone, |
276 | path: operation.path.clone, |
277 | , |
278 | |
279 | .await |
280 | .as_internal_error?; |
281 | drop; |
282 | |
283 | Ok |
284 | |
285 | |
286 | pub async |
287 | object: Repository, |
288 | operation: RepositoryLastCommitOfFileRequest, |
289 | state: DatabaseBackend, |
290 | OperationState | : ,
291 | backend: GiteratedStack, |
292 | requester: , |
293 | |
294 | let object = backend |
295 | . |
296 | .await |
297 | .unwrap; |
298 | |
299 | let mut repository_backend = state.repository_backend.lock .await; |
300 | let commit = repository_backend |
301 | .repository_last_commit_of_file |
302 | &requester, |
303 | object.object, |
304 | &RepositoryLastCommitOfFileRequest |
305 | start_commit: operation.start_commit.clone, |
306 | path: operation.path.clone, |
307 | , |
308 | |
309 | .await |
310 | .as_internal_error?; |
311 | drop; |
312 | |
313 | Ok |
314 | |
315 | |
316 | pub async |
317 | object: Repository, |
318 | operation: RepositoryCommitFromIdRequest, |
319 | state: DatabaseBackend, |
320 | OperationState | : ,
321 | backend: GiteratedStack, |
322 | requester: , |
323 | |
324 | let object = backend |
325 | . |
326 | .await |
327 | .unwrap; |
328 | |
329 | let mut repository_backend = state.repository_backend.lock .await; |
330 | let commit = repository_backend |
331 | .repository_commit_from_id |
332 | &requester, |
333 | object.object, |
334 | &RepositoryCommitFromIdRequest, |
335 | |
336 | .await |
337 | .as_internal_error?; |
338 | drop; |
339 | |
340 | Ok |
341 | |
342 | |
343 | pub async |
344 | object: Repository, |
345 | operation: RepositoryDiffRequest, |
346 | state: DatabaseBackend, |
347 | OperationState | : ,
348 | backend: GiteratedStack, |
349 | requester: , |
350 | |
351 | let object = backend |
352 | . |
353 | .await |
354 | .unwrap; |
355 | |
356 | let mut repository_backend = state.repository_backend.lock .await; |
357 | let diff = repository_backend |
358 | .repository_diff |
359 | .await |
360 | .as_internal_error?; |
361 | drop; |
362 | |
363 | Ok |
364 | |
365 | |
366 | pub async |
367 | object: Repository, |
368 | operation: RepositoryDiffPatchRequest, |
369 | state: DatabaseBackend, |
370 | OperationState | : ,
371 | backend: GiteratedStack, |
372 | requester: , |
373 | |
374 | let object = backend |
375 | . |
376 | .await |
377 | .unwrap; |
378 | |
379 | let mut repository_backend = state.repository_backend.lock .await; |
380 | let patch = repository_backend |
381 | .repository_diff_patch |
382 | .await |
383 | .as_internal_error?; |
384 | drop; |
385 | |
386 | Ok |
387 | |
388 | |
389 | pub async |
390 | object: Repository, |
391 | operation: RepositoryCommitBeforeRequest, |
392 | state: DatabaseBackend, |
393 | OperationState | : ,
394 | backend: GiteratedStack, |
395 | requester: , |
396 | |
397 | let object = backend |
398 | . |
399 | .await |
400 | .unwrap; |
401 | |
402 | let mut repository_backend = state.repository_backend.lock .await; |
403 | let file = repository_backend |
404 | .repository_commit_before |
405 | .await |
406 | .as_internal_error?; |
407 | drop; |
408 | |
409 | Ok |
410 | |
411 | |
412 | pub async |
413 | object: Instance, |
414 | operation: AuthenticationTokenRequest, |
415 | state: DatabaseBackend, |
416 | OperationState | : ,
417 | // Authorizes the request for SAME-INSTANCE |
418 | // _authorized_instance: AuthorizedInstance, |
419 | |
420 | let mut backend = state.user_backend.lock .await; |
421 | |
422 | backend |
423 | .login |
424 | .await |
425 | .as_internal_error |
426 | |
427 | |
428 | pub async |
429 | _object: Instance, |
430 | operation: RegisterAccountRequest, |
431 | state: DatabaseBackend, |
432 | OperationState// Authorizes the request for SAME-INSTANCE | : ,
433 | // _authorized_instance: AuthorizedInstance, |
434 | |
435 | let mut backend = state.user_backend.lock .await; |
436 | |
437 | backend |
438 | .register |
439 | .await |
440 | .as_internal_error |
441 | |
442 | |
443 | pub async |
444 | _object: Instance, |
445 | operation: RepositoryCreateRequest, |
446 | state: DatabaseBackend, |
447 | OperationState | : ,
448 | requester: AuthenticatedUser, |
449 | // Authorizes the request for SAME-INSTANCE |
450 | // _authorized_instance: AuthorizedInstance, |
451 | |
452 | let mut backend = state.repository_backend.lock .await; |
453 | |
454 | backend |
455 | .create_repository |
456 | .await |
457 | .as_internal_error |
458 | |
459 | |
460 | pub async |
461 | _repository: Repository, |
462 | _state: DatabaseBackend, |
463 | OperationState | : ,
464 | |
465 | Ok |
466 | |
467 |