Showing the changes to git-traverse/src/commit.rs (1 of 4 files). Show all
Unified · Split
| @@ -50,25 +50,20 @@ pub mod ancestors { · 49 unmodified lines | |||
| 50 | 50 | ||
| 51 | use git_hash::{oid, ObjectId}; | 51 | use git_hash::{oid, ObjectId}; |
| 52 | use git_object::CommitRefIter; | 52 | use git_object::CommitRefIter; |
| 53 | use quick_error::quick_error; | ||
| 54 | 53 | ||
| 55 | use crate::commit::{Ancestors, Parents, Sorting}; | 54 | use crate::commit::{Ancestors, Parents, Sorting}; |
| 56 | 55 | ||
| 57 | quick_error! { | 56 | /// The error is part of the item returned by the [Ancestors] iterator. |
| 58 | /// The error is part of the item returned by the [Ancestors] iterator. | 57 | #[derive(Debug, thiserror::Error)] |
| 59 | #[derive(Debug)] | 58 | #[allow(missing_docs)] |
| 60 | #[allow(missing_docs)] | 59 | pub enum Error { |
| 61 | pub enum Error { | 60 | #[error("The commit {oid} could not be found")] |
| 62 | FindExisting{oid: ObjectId, err: Box<dyn std::error::Error + Send + Sync + 'static> } { | 61 | FindExisting { |
| 63 | display("The commit {} could not be found", oid) | 62 | oid: ObjectId, |
| 64 | source(&**err) | 63 | source: Box<dyn std::error::Error + Send + Sync + 'static>, |
| 65 | } | 64 | }, |
| 66 | ObjectDecode(err: git_object::decode::Error) { | 65 | #[error(transparent)] |
| 67 | display("An object could not be decoded") | 66 | ObjectDecode(#[from] git_object::decode::Error), |
| 68 | source(err) | ||
| 69 | from() | ||
| 70 | } | ||
| 71 | } | ||
| 72 | } | 67 | } |
| 73 | 68 | ||
| 74 | type TimeInSeconds = u32; | 69 | type TimeInSeconds = u32; |
| @@ -112,7 +107,7 @@ pub mod ancestors { · 37 unmodified lines | |||
| 112 | for (commit_id, commit_time) in state.next.iter_mut() { | 107 | for (commit_id, commit_time) in state.next.iter_mut() { |
| 113 | let commit_iter = (self.find)(commit_id, &mut state.buf).map_err(|err| Error::FindExisting { | 108 | let commit_iter = (self.find)(commit_id, &mut state.buf).map_err(|err| Error::FindExisting { |
| 114 | oid: *commit_id, | 109 | oid: *commit_id, |
| 115 | err: err.into(), | 110 | source: err.into(), |
| 116 | })?; | 111 | })?; |
| 117 | *commit_time = commit_iter.committer()?.time.seconds_since_unix_epoch; | 112 | *commit_time = commit_iter.committer()?.time.seconds_since_unix_epoch; |
| 118 | } | 113 | } |
| @@ -266,7 +261,12 @@ pub mod ancestors { · 147 unmodified lines | |||
| 266 | } | 261 | } |
| 267 | } | 262 | } |
| 268 | } | 263 | } |
| 269 | Err(err) => return Some(Err(Error::FindExisting { oid, err: err.into() })), | 264 | Err(err) => { |
| 265 | return Some(Err(Error::FindExisting { | ||
| 266 | oid, | ||
| 267 | source: err.into(), | ||
| 268 | })) | ||
| 269 | } | ||
| 270 | } | 270 | } |
| 271 | Some(Ok(oid)) | 271 | Some(Ok(oid)) |
| 272 | } | 272 | } |
| @@ -301,7 +301,12 @@ pub mod ancestors { · 28 unmodified lines | |||
| 301 | } | 301 | } |
| 302 | } | 302 | } |
| 303 | } | 303 | } |
| 304 | Err(err) => return Some(Err(Error::FindExisting { oid, err: err.into() })), | 304 | Err(err) => { |
| 305 | return Some(Err(Error::FindExisting { | ||
| 306 | oid, | ||
| 307 | source: err.into(), | ||
| 308 | })) | ||
| 309 | } | ||
| 305 | } | 310 | } |
| 306 | Some(Ok(oid)) | 311 | Some(Ok(oid)) |
| 307 | } | 312 | } |