Fixes and cleanup
parent: tbd commit: 555bd26
Showing 5 changed files with 46 insertions and 29 deletions
giterated-daemon/src/backend/git.rs
@@ -1,6 +1,5 @@ | ||
1 | 1 | use anyhow::Error; |
2 | 2 | use async_trait::async_trait; |
3 | use futures_util::StreamExt; | |
4 | 3 | |
5 | 4 | use git2::BranchType; |
6 | 5 | use giterated_models::instance::{Instance, RepositoryCreateRequest}; |
@@ -839,6 +838,7 @@ impl IssuesBackend for GitBackend { | ||
839 | 838 | } |
840 | 839 | } |
841 | 840 | |
841 | #[allow(unused)] | |
842 | 842 | #[derive(Debug, sqlx::FromRow)] |
843 | 843 | struct RepositoryMetadata { |
844 | 844 | pub repository: String, |
giterated-daemon/src/backend/user.rs
@@ -257,6 +257,7 @@ struct UserRow { | ||
257 | 257 | pub enc_private_key: Vec<u8>, |
258 | 258 | } |
259 | 259 | |
260 | #[allow(unused)] | |
260 | 261 | #[derive(Debug, sqlx::FromRow)] |
261 | 262 | struct UserValue { |
262 | 263 | pub username: String, |
giterated-daemon/src/database_backend/mod.rs
@@ -106,10 +106,13 @@ impl ObjectBackend for DatabaseBackend { | ||
106 | 106 | .map_err(|e| OperationError::Internal(e.to_string()))?), |
107 | 107 | Err(err) => match err { |
108 | 108 | OperationError::Internal(internal) => { |
109 | warn!("Internal Error: {:?}", OperationError::<()>::Internal(internal.clone())); | |
110 | ||
109 | warn!( | |
110 | "Internal Error: {:?}", | |
111 | OperationError::<()>::Internal(internal.clone()) | |
112 | ); | |
113 | ||
111 | 114 | Err(OperationError::Internal(internal)) |
112 | }, | |
115 | } | |
113 | 116 | OperationError::Unhandled => Err(OperationError::Unhandled), |
114 | 117 | OperationError::Operation(err) => Err(OperationError::Operation( |
115 | 118 | serde_json::from_slice(&err) |
@@ -142,10 +145,13 @@ impl ObjectBackend for DatabaseBackend { | ||
142 | 145 | .map_err(|e| OperationError::Internal(e.to_string()))?), |
143 | 146 | Err(err) => match err { |
144 | 147 | OperationError::Internal(internal) => { |
145 | warn!("Internal Error: {:?}", OperationError::<()>::Internal(internal.clone())); | |
148 | warn!( | |
149 | "Internal Error: {:?}", | |
150 | OperationError::<()>::Internal(internal.clone()) | |
151 | ); | |
146 | 152 | |
147 | 153 | Err(OperationError::Internal(internal)) |
148 | }, | |
154 | } | |
149 | 155 | OperationError::Unhandled => Err(OperationError::Unhandled), |
150 | 156 | OperationError::Operation(err) => Err(OperationError::Operation( |
151 | 157 | serde_json::from_slice(&err) |
@@ -178,10 +184,13 @@ impl ObjectBackend for DatabaseBackend { | ||
178 | 184 | .map_err(|e| OperationError::Internal(e.to_string()))?), |
179 | 185 | Err(err) => match err { |
180 | 186 | OperationError::Internal(internal) => { |
181 | warn!("Internal Error: {:?}", OperationError::<()>::Internal(internal.clone())); | |
182 | ||
183 | Err(OperationError::Internal(internal)) | |
184 | } | |
187 | warn!( | |
188 | "Internal Error: {:?}", | |
189 | OperationError::<()>::Internal(internal.clone()) | |
190 | ); | |
191 | ||
192 | Err(OperationError::Internal(internal)) | |
193 | } | |
185 | 194 | OperationError::Unhandled => Err(OperationError::Unhandled), |
186 | 195 | OperationError::Operation(err) => Err(OperationError::Operation( |
187 | 196 | serde_json::from_slice(&err) |
@@ -312,8 +321,8 @@ mod test { | ||
312 | 321 | } |
313 | 322 | async fn repositories_for_user( |
314 | 323 | &mut self, |
315 | requester: Option<&User>, | |
316 | user: &User, | |
324 | _requester: Option<&User>, | |
325 | _user: &User, | |
317 | 326 | ) -> Result<Vec<RepositorySummary>, Error> { |
318 | 327 | todo!() |
319 | 328 | } |
@@ -350,33 +359,33 @@ mod test { | ||
350 | 359 | } |
351 | 360 | async fn repository_file_inspect( |
352 | 361 | &mut self, |
353 | requester: Option<&User>, | |
354 | repository: &Repository, | |
355 | request: &RepositoryFileInspectRequest, | |
362 | _requester: Option<&User>, | |
363 | _repository: &Repository, | |
364 | _request: &RepositoryFileInspectRequest, | |
356 | 365 | ) -> Result<Vec<RepositoryTreeEntry>, Error> { |
357 | 366 | todo!() |
358 | 367 | } |
359 | 368 | async fn repository_file_from_id( |
360 | 369 | &mut self, |
361 | requester: Option<&User>, | |
362 | repository: &Repository, | |
363 | request: &RepositoryFileFromIdRequest, | |
370 | _requester: Option<&User>, | |
371 | _repository: &Repository, | |
372 | _request: &RepositoryFileFromIdRequest, | |
364 | 373 | ) -> Result<RepositoryFile, Error> { |
365 | 374 | todo!() |
366 | 375 | } |
367 | 376 | async fn repository_diff( |
368 | 377 | &mut self, |
369 | requester: Option<&User>, | |
370 | repository: &Repository, | |
371 | request: &RepositoryDiffRequest, | |
378 | _requester: Option<&User>, | |
379 | _repository: &Repository, | |
380 | _request: &RepositoryDiffRequest, | |
372 | 381 | ) -> Result<RepositoryDiff, Error> { |
373 | 382 | todo!() |
374 | 383 | } |
375 | 384 | async fn repository_commit_before( |
376 | 385 | &mut self, |
377 | requester: Option<&User>, | |
378 | repository: &Repository, | |
379 | request: &RepositoryCommitBeforeRequest, | |
386 | _requester: Option<&User>, | |
387 | _repository: &Repository, | |
388 | _request: &RepositoryCommitBeforeRequest, | |
380 | 389 | ) -> Result<Commit, Error> { |
381 | 390 | todo!() |
382 | 391 | } |
giterated-models/src/message.rs
@@ -15,6 +15,7 @@ pub struct GiteratedMessage<O: GiteratedObject, V: GiteratedOperation<O>> { | ||
15 | 15 | pub payload: V, |
16 | 16 | } |
17 | 17 | |
18 | #[allow(unused)] | |
18 | 19 | mod string { |
19 | 20 | use std::fmt::Display; |
20 | 21 | use std::str::FromStr; |
giterated-models/src/repository/operations.rs
@@ -7,7 +7,10 @@ use crate::{ | ||
7 | 7 | operation::GiteratedOperation, |
8 | 8 | }; |
9 | 9 | |
10 | use super::{IssueLabel, Repository, RepositoryIssue, RepositoryTreeEntry, RepositoryView, RepositoryFile, RepositoryDiff, Commit}; | |
10 | use super::{ | |
11 | Commit, IssueLabel, Repository, RepositoryDiff, RepositoryFile, RepositoryIssue, | |
12 | RepositoryTreeEntry, RepositoryView, | |
13 | }; | |
11 | 14 | |
12 | 15 | /// A request to get a repository's information. |
13 | 16 | /// |
@@ -164,12 +167,13 @@ impl<B: ObjectBackend + std::fmt::Debug> Object<'_, Repository, B> { | ||
164 | 167 | }) |
165 | 168 | .await |
166 | 169 | } |
167 | ||
170 | ||
168 | 171 | pub async fn file_from_id( |
169 | 172 | &mut self, |
170 | 173 | id: String, |
171 | 174 | ) -> Result<RepositoryFile, OperationError<RepositoryError>> { |
172 | self.request::<RepositoryFileFromIdRequest>(RepositoryFileFromIdRequest(id)).await | |
175 | self.request::<RepositoryFileFromIdRequest>(RepositoryFileFromIdRequest(id)) | |
176 | .await | |
173 | 177 | } |
174 | 178 | |
175 | 179 | pub async fn diff( |
@@ -177,14 +181,16 @@ impl<B: ObjectBackend + std::fmt::Debug> Object<'_, Repository, B> { | ||
177 | 181 | old_id: String, |
178 | 182 | new_id: String, |
179 | 183 | ) -> Result<RepositoryDiff, OperationError<RepositoryError>> { |
180 | self.request::<RepositoryDiffRequest>(RepositoryDiffRequest { old_id, new_id }).await | |
184 | self.request::<RepositoryDiffRequest>(RepositoryDiffRequest { old_id, new_id }) | |
185 | .await | |
181 | 186 | } |
182 | 187 | |
183 | 188 | pub async fn commit_before( |
184 | 189 | &mut self, |
185 | 190 | id: String, |
186 | 191 | ) -> Result<Commit, OperationError<RepositoryError>> { |
187 | self.request::<RepositoryCommitBeforeRequest>(RepositoryCommitBeforeRequest(id)).await | |
192 | self.request::<RepositoryCommitBeforeRequest>(RepositoryCommitBeforeRequest(id)) | |
193 | .await | |
188 | 194 | } |
189 | 195 | |
190 | 196 | // pub async fn issues_count(&mut self) -> Result<u64, OperationError<RepositoryError>> { |