Add repository setings
parent: tbd commit: 3b20354
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 | RepositoryFileInspectRequest, RepositoryInfoRequest, RepositorySummary, RepositoryView, |
16 | Visibility, |
17 | , |
18 | , |
19 | , |
20 | , |
21 | ; |
22 | use ; |
23 | |
24 | use DatabaseBackend; |
25 | |
26 | |
27 | object: &User, |
28 | _operation: UserRepositoriesRequest, |
29 | state: DatabaseBackend, |
30 | |
31 | let object = object.clone; |
32 | |
33 | async move |
34 | let mut user_backend = state.user_backend.lock .await; |
35 | let repositories = user_backend |
36 | .repositories_for_user |
37 | .await |
38 | .map_err?; |
39 | |
40 | Ok |
41 | |
42 | .boxed |
43 | |
44 | |
45 | |
46 | object: &User, |
47 | operation: , |
48 | state: DatabaseBackend, |
49 | |
50 | let object = object.clone; |
51 | |
52 | async move |
53 | let mut user_backend = state.user_backend.lock .await; |
54 | let value = user_backend |
55 | .get_value |
56 | .await |
57 | .map_err?; |
58 | |
59 | Ok |
60 | |
61 | .boxed |
62 | |
63 | |
64 | |
65 | object: &User, |
66 | operation: , |
67 | state: DatabaseBackend, |
68 | |
69 | let object = object.clone; |
70 | |
71 | async move |
72 | let mut user_backend = state.user_backend.lock .await; |
73 | let value = user_backend |
74 | .get_setting |
75 | .await |
76 | .map_err?; |
77 | |
78 | Ok |
79 | |
80 | .boxed |
81 | |
82 | |
83 | |
84 | object: &User, |
85 | operation: , |
86 | state: DatabaseBackend, |
87 | |
88 | let object = object.clone; |
89 | |
90 | async move |
91 | let mut user_backend = state.user_backend.lock .await; |
92 | let value = user_backend |
93 | .write_setting |
94 | .await |
95 | .map_err?; |
96 | |
97 | Ok |
98 | |
99 | .boxed |
100 | |
101 | |
102 | |
103 | object: &Repository, |
104 | operation: RepositoryInfoRequest, |
105 | state: DatabaseBackend, |
106 | operation_state: StackOperationState, |
107 | backend: BackendWrapper, |
108 | |
109 | let object = object.clone; |
110 | |
111 | async move |
112 | let mut object = backend |
113 | . |
114 | .await |
115 | .unwrap; |
116 | |
117 | let mut repository_backend = state.repository_backend.lock .await; |
118 | let tree = repository_backend |
119 | .repository_file_inspect |
120 | None, |
121 | object.object, |
122 | &RepositoryFileInspectRequest |
123 | extra_metadata: operation.extra_metadata, |
124 | path: operation.path, |
125 | rev: operation.rev.clone, |
126 | , |
127 | |
128 | .await |
129 | .map_err?; |
130 | drop; |
131 | |
132 | let info = RepositoryView |
133 | name: object.object .name.clone, |
134 | owner: object.object .owner.clone, |
135 | description: object. .await.ok, |
136 | visibility: object |
137 | . |
138 | .await |
139 | .map_err?, |
140 | default_branch: object |
141 | . |
142 | .await |
143 | .map_err?, |
144 | // 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. |
145 | latest_commit: object. .await.ok, |
146 | tree_rev: operation.rev, |
147 | tree, |
148 | ; |
149 | |
150 | Ok |
151 | |
152 | .boxed |
153 | |
154 | |
155 | |
156 | object: &Repository, |
157 | operation: RepositoryFileFromIdRequest, |
158 | state: DatabaseBackend, |
159 | operation_state: StackOperationState, |
160 | backend: BackendWrapper, |
161 | |
162 | let object = object.clone; |
163 | |
164 | async move |
165 | let object = backend |
166 | . |
167 | .await |
168 | .unwrap; |
169 | |
170 | let mut repository_backend = state.repository_backend.lock .await; |
171 | let file = repository_backend |
172 | .repository_file_from_id |
173 | None, |
174 | object.object, |
175 | &RepositoryFileFromIdRequest, |
176 | |
177 | .await |
178 | .map_err?; |
179 | drop; |
180 | |
181 | Ok |
182 | |
183 | .boxed |
184 | |
185 | |
186 | |
187 | object: &Repository, |
188 | operation: RepositoryDiffRequest, |
189 | state: DatabaseBackend, |
190 | operation_state: StackOperationState, |
191 | backend: BackendWrapper, |
192 | |
193 | let object = object.clone; |
194 | |
195 | async move |
196 | let object = backend |
197 | . |
198 | .await |
199 | .unwrap; |
200 | |
201 | let mut repository_backend = state.repository_backend.lock .await; |
202 | let diff = repository_backend |
203 | .repository_diff |
204 | .await |
205 | .map_err?; |
206 | drop; |
207 | |
208 | Ok |
209 | |
210 | .boxed |
211 | |
212 | |
213 | |
214 | object: &Repository, |
215 | operation: RepositoryDiffPatchRequest, |
216 | state: DatabaseBackend, |
217 | operation_state: StackOperationState, |
218 | backend: BackendWrapper, |
219 | |
220 | let object = object.clone; |
221 | |
222 | async move |
223 | let object = backend |
224 | . |
225 | .await |
226 | .unwrap; |
227 | |
228 | let mut repository_backend = state.repository_backend.lock .await; |
229 | let patch = repository_backend |
230 | .repository_diff_patch |
231 | .await |
232 | .map_err?; |
233 | drop; |
234 | |
235 | Ok |
236 | |
237 | .boxed |
238 | |
239 | |
240 | |
241 | object: &Repository, |
242 | operation: RepositoryCommitBeforeRequest, |
243 | state: DatabaseBackend, |
244 | operation_state: StackOperationState, |
245 | backend: BackendWrapper, |
246 | |
247 | let object = object.clone; |
248 | |
249 | async move |
250 | let object = backend |
251 | . |
252 | .await |
253 | .unwrap; |
254 | |
255 | let mut repository_backend = state.repository_backend.lock .await; |
256 | let file = repository_backend |
257 | .repository_commit_before |
258 | .await |
259 | .map_err?; |
260 | drop; |
261 | |
262 | Ok |
263 | |
264 | .boxed |
265 | |
266 | |
267 | |
268 | object: &Repository, |
269 | operation: , |
270 | state: DatabaseBackend, |
271 | |
272 | let object = object.clone; |
273 | |
274 | async move |
275 | let mut repository_backend = state.repository_backend.lock .await; |
276 | let value = repository_backend |
277 | .get_value |
278 | .await |
279 | .map_err |
280 | Internal |
281 | ?; |
282 | |
283 | Ok |
284 | |
285 | .boxed |
286 | |
287 | |
288 | |
289 | object: &Repository, |
290 | operation: , |
291 | state: DatabaseBackend, |
292 | |
293 | let object = object.clone; |
294 | |
295 | async move |
296 | let mut repository_backend = state.repository_backend.lock .await; |
297 | let value = repository_backend |
298 | .get_setting |
299 | .await |
300 | .map_err?; |
301 | |
302 | Ok |
303 | |
304 | .boxed |
305 | |
306 | |
307 | |
308 | object: &Repository, |
309 | operation: , |
310 | state: DatabaseBackend, |
311 | |
312 | let object = object.clone; |
313 | |
314 | async move |
315 | let mut repository_backend = state.repository_backend.lock .await; |
316 | let value = repository_backend |
317 | .write_setting |
318 | .await |
319 | .map_err?; |
320 | |
321 | Ok |
322 | |
323 | .boxed |
324 | |
325 | |
326 | |
327 | object: &Instance, |
328 | operation: AuthenticationTokenRequest, |
329 | state: DatabaseBackend, |
330 | |
331 | let object = object.clone; |
332 | async move |
333 | let mut backend = state.user_backend.lock .await; |
334 | |
335 | backend |
336 | .login |
337 | .await |
338 | .map_err |
339 | |
340 | .boxed |
341 | |
342 | |
343 | |
344 | _object: &Instance, |
345 | operation: RegisterAccountRequest, |
346 | state: DatabaseBackend, |
347 | |
348 | async move |
349 | let mut backend = state.user_backend.lock .await; |
350 | |
351 | backend |
352 | .register |
353 | .await |
354 | .map_err |
355 | |
356 | .boxed |
357 | |
358 | |
359 | |
360 | _object: &Instance, |
361 | operation: RepositoryCreateRequest, |
362 | state: DatabaseBackend, |
363 | |
364 | async move |
365 | let mut backend = state.repository_backend.lock .await; |
366 | |
367 | backend |
368 | .create_repository |
369 | .await |
370 | .map_err |
371 | |
372 | .boxed |
373 | |
374 |