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