- find a way to reasonably keep previous semantics in downstream users
Unified · Split
| @@ -36,6 +36,13 @@ pub mod snapshot; · 35 unmodified lines | ||
| 36 | 36 | /// optionally name to find mappings to new names and/or emails. |
| 37 | 37 | /// |
| 38 | 38 | /// The memory layout is efficient, even though lots of small allocations are performed to store strings of emails and names. |
| 39 | +/// | |
| 40 | +/// ### Handling of invalid `SignatureRef::time` | |
| 41 | +/// | |
| 42 | +/// As the `time` field in [`SignatureRef`](gix_actor::SignatureRef) as passed by the caller maybe invalid, | |
| 43 | +/// something that should be very rare but is possible, we decided to not expose this fallibility in the API. | |
| 44 | +/// Hence, the user may separately check for the correctness of `time`, which we replace with [`gix_date::Time::default()`] | |
| 45 | +/// in case of parse errors. | |
| 39 | 46 | #[derive(Default, Clone, Debug, Eq, PartialEq)] |
| 40 | 47 | pub struct Snapshot { |
| 41 | 48 | /// Sorted by `old_email` |
| @@ -157,17 +157,17 @@ fn enriched_signature<'a>( · 156 unmodified lines | ||
| 157 | 157 | (Some(new_email), Some(new_name)) => Signature { |
| 158 | 158 | email: new_email.to_owned().into(), |
| 159 | 159 | name: new_name.to_owned().into(), |
| 160 | − time: gix_date::Time::from_bytes(time).expect("Time must be valid"), | |
| 160 | + time: gix_date::Time::from_bytes(time).unwrap_or_default(), | |
| 161 | 161 | }, |
| 162 | 162 | (Some(new_email), None) => Signature { |
| 163 | 163 | email: new_email.to_owned().into(), |
| 164 | 164 | name: name.into(), |
| 165 | − time: gix_date::Time::from_bytes(time).expect("Time must be valid"), | |
| 165 | + time: gix_date::Time::from_bytes(time).unwrap_or_default(), | |
| 166 | 166 | }, |
| 167 | 167 | (None, Some(new_name)) => Signature { |
| 168 | 168 | email: email.into(), |
| 169 | 169 | name: new_name.to_owned().into(), |
| 170 | − time: gix_date::Time::from_bytes(time).expect("Time must be valid"), | |
| 170 | + time: gix_date::Time::from_bytes(time).unwrap_or_default(), | |
| 171 | 171 | }, |
| 172 | 172 | (None, None) => unreachable!("BUG: ResolvedSignatures don't exist here when nothing is set"), |
| 173 | 173 | } |
| @@ -29,7 +29,7 @@ impl<'a> From<gix_actor::SignatureRef<'a>> for Signature<'a> { · 28 unmodified lines | ||
| 29 | 29 | Signature { |
| 30 | 30 | name: s.name.into(), |
| 31 | 31 | email: s.email.into(), |
| 32 | − time: gix_date::Time::from_bytes(s.time).expect("Time must be valid"), | |
| 32 | + time: gix_date::Time::from_bytes(s.time).unwrap_or_default(), | |
| 33 | 33 | } |
| 34 | 34 | } |
| 35 | 35 | } |