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