Unified · Split
| @@ -300,7 +300,7 @@ mod tests { · 299 unmodified lines | ||
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | pub fn time_to_offset_date_time(time: gix::actor::Time) -> OffsetDateTime { |
| 303 | − time::OffsetDateTime::from_unix_timestamp(time.seconds_since_unix_epoch as i64) | |
| 303 | + time::OffsetDateTime::from_unix_timestamp(time.seconds as i64) | |
| 304 | 304 | .expect("always valid unix time") |
| 305 | − .replace_offset(time::UtcOffset::from_whole_seconds(time.offset_in_seconds).expect("valid offset")) | |
| 305 | + .replace_offset(time::UtcOffset::from_whole_seconds(time.offset).expect("valid offset")) | |
| 306 | 306 | } |
| @@ -24,11 +24,7 @@ pub fn estimate_hours( · 23 unmodified lines | ||
| 24 | 24 | let hours_for_commits = commits.iter().map(|t| &t.1).rev().tuple_windows().fold( |
| 25 | 25 | 0_f32, |
| 26 | 26 | |hours, (cur, next): (&gix::actor::SignatureRef<'_>, &gix::actor::SignatureRef<'_>)| { |
| 27 | − let change_in_minutes = (next | |
| 28 | − .time | |
| 29 | − .seconds_since_unix_epoch | |
| 30 | − .saturating_sub(cur.time.seconds_since_unix_epoch)) as f32 | |
| 31 | − / MINUTES_PER_HOUR; | |
| 27 | + let change_in_minutes = (next.time.seconds.saturating_sub(cur.time.seconds)) as f32 / MINUTES_PER_HOUR; | |
| 32 | 28 | if change_in_minutes < MAX_COMMIT_DIFFERENCE_IN_MINUTES { |
| 33 | 29 | hours + change_in_minutes / MINUTES_PER_HOUR |
| 34 | 30 | } else { |
| @@ -95,12 +95,9 @@ where · 94 unmodified lines | ||
| 95 | 95 | } |
| 96 | 96 | out.shrink_to_fit(); |
| 97 | 97 | out.sort_by(|a, b| { |
| 98 | − a.1.email.cmp(b.1.email).then( | |
| 99 | − a.1.time | |
| 100 | − .seconds_since_unix_epoch | |
| 101 | − .cmp(&b.1.time.seconds_since_unix_epoch) | |
| 102 | − .reverse(), | |
| 103 | − ) | |
| 98 | + a.1.email | |
| 99 | + .cmp(b.1.email) | |
| 100 | + .then(a.1.time.seconds.cmp(&b.1.time.seconds).reverse()) | |
| 104 | 101 | }); |
| 105 | 102 | Ok(out) |
| 106 | 103 | }); |
| @@ -1,6 +1,7 @@ | ||
| 1 | 1 | pub(crate) mod function { |
| 2 | 2 | use bstr::ByteSlice; |
| 3 | 3 | use btoi::btoi; |
| 4 | + use gix_date::{OffsetInSeconds, SecondsSinceUnixEpoch}; | |
| 4 | 5 | use nom::{ |
| 5 | 6 | branch::alt, |
| 6 | 7 | bytes::complete::{tag, take, take_until, take_while_m_n}, |
| @@ -25,7 +26,7 @@ pub(crate) mod function { · 18 unmodified lines | ||
| 25 | 26 | tag(b" "), |
| 26 | 27 | context("<timestamp>", |i| { |
| 27 | 28 | terminated(take_until(SPACE), take(1usize))(i).and_then(|(i, v)| { |
| 28 | − btoi::<u32>(v) | |
| 29 | + btoi::<SecondsSinceUnixEpoch>(v) | |
| 29 | 30 | .map(|v| (i, v)) |
| 30 | 31 | .map_err(|_| nom::Err::Error(E::from_error_kind(i, nom::error::ErrorKind::MapRes))) |
| 31 | 32 | }) |
| @@ -33,14 +34,14 @@ pub(crate) mod function { · 1 unmodified line | ||
| 33 | 34 | context("+|-", alt((tag(b"-"), tag(b"+")))), |
| 34 | 35 | context("HH", |i| { |
| 35 | 36 | take_while_m_n(2usize, 2, is_digit)(i).and_then(|(i, v)| { |
| 36 | − btoi::<i32>(v) | |
| 37 | + btoi::<OffsetInSeconds>(v) | |
| 37 | 38 | .map(|v| (i, v)) |
| 38 | 39 | .map_err(|_| nom::Err::Error(E::from_error_kind(i, nom::error::ErrorKind::MapRes))) |
| 39 | 40 | }) |
| 40 | 41 | }), |
| 41 | 42 | context("MM", |i| { |
| 42 | 43 | take_while_m_n(2usize, 2, is_digit)(i).and_then(|(i, v)| { |
| 43 | − btoi::<i32>(v) | |
| 44 | + btoi::<OffsetInSeconds>(v) | |
| 44 | 45 | .map(|v| (i, v)) |
| 45 | 46 | .map_err(|_| nom::Err::Error(E::from_error_kind(i, nom::error::ErrorKind::MapRes))) |
| 46 | 47 | }) |
| @@ -58,8 +59,8 @@ pub(crate) mod function { · 11 unmodified lines | ||
| 58 | 59 | name: identity.name, |
| 59 | 60 | email: identity.email, |
| 60 | 61 | time: Time { |
| 61 | − seconds_since_unix_epoch: time, | |
| 62 | − offset_in_seconds: offset, | |
| 62 | + seconds: time, | |
| 63 | + offset: offset, | |
| 63 | 64 | sign, |
| 64 | 65 | }, |
| 65 | 66 | }, |
| @@ -93,6 +94,7 @@ pub use function::identity; · 27 unmodified lines | ||
| 93 | 94 | mod tests { |
| 94 | 95 | mod parse_signature { |
| 95 | 96 | use bstr::ByteSlice; |
| 97 | + use gix_date::{OffsetInSeconds, SecondsSinceUnixEpoch}; | |
| 96 | 98 | use gix_testtools::to_bstr_err; |
| 97 | 99 | use nom::IResult; |
| 98 | 100 | |
| @@ -105,18 +107,14 @@ mod tests { · 6 unmodified lines | ||
| 105 | 107 | fn signature( |
| 106 | 108 | name: &'static str, |
| 107 | 109 | email: &'static str, |
| 108 | − time: u32, | |
| 110 | + seconds: SecondsSinceUnixEpoch, | |
| 109 | 111 | sign: Sign, |
| 110 | − offset: i32, | |
| 112 | + offset: OffsetInSeconds, | |
| 111 | 113 | ) -> SignatureRef<'static> { |
| 112 | 114 | SignatureRef { |
| 113 | 115 | name: name.as_bytes().as_bstr(), |
| 114 | 116 | email: email.as_bytes().as_bstr(), |
| 115 | − time: Time { | |
| 116 | − seconds_since_unix_epoch: time, | |
| 117 | − offset_in_seconds: offset, | |
| 118 | − sign, | |
| 119 | − }, | |
| 117 | + time: Time { seconds, offset, sign }, | |
| 120 | 118 | } |
| 121 | 119 | } |
| 122 | 120 | |
| @@ -43,8 +43,8 @@ mod write_to { · 42 unmodified lines | ||
| 43 | 43 | |
| 44 | 44 | fn default_time() -> Time { |
| 45 | 45 | Time { |
| 46 | − seconds_since_unix_epoch: 0, | |
| 47 | − offset_in_seconds: 0, | |
| 46 | + seconds: 0, | |
| 47 | + offset: 0, | |
| 48 | 48 | sign: Sign::Plus, |
| 49 | 49 | } |
| 50 | 50 | } |
| @@ -119,8 +119,8 @@ fn signature(name: &str, email: &str) -> gix_actor::Signature { · 118 unmodified lines | ||
| 119 | 119 | email: email.into(), |
| 120 | 120 | time: gix_actor::Time { |
| 121 | 121 | // marker |
| 122 | − seconds_since_unix_epoch: 42, | |
| 123 | − offset_in_seconds: 53, | |
| 122 | + seconds: 42, | |
| 123 | + offset: 53, | |
| 124 | 124 | sign: gix_actor::Sign::Minus, |
| 125 | 125 | }, |
| 126 | 126 | } |
| @@ -139,8 +139,8 @@ fn with_trailer() -> crate::Result { · 138 unmodified lines | ||
| 139 | 139 | name: "Kim Altintop".into(), |
| 140 | 140 | email: "kim@eagain.st".into(), |
| 141 | 141 | time: Time { |
| 142 | − seconds_since_unix_epoch: 1631514803, | |
| 143 | − offset_in_seconds: 7200, | |
| 142 | + seconds: 1631514803, | |
| 143 | + offset: 7200, | |
| 144 | 144 | sign: Sign::Plus, |
| 145 | 145 | }, |
| 146 | 146 | }; |
| @@ -236,8 +236,8 @@ mod summary { · 235 unmodified lines | ||
| 236 | 236 | name: "name".into(), |
| 237 | 237 | email: "email".into(), |
| 238 | 238 | time: Time { |
| 239 | − seconds_since_unix_epoch: 0, | |
| 240 | − offset_in_seconds: 0, | |
| 239 | + seconds: 0, | |
| 240 | + offset: 0, | |
| 241 | 241 | sign: Sign::Plus, |
| 242 | 242 | }, |
| 243 | 243 | }; |
| @@ -63,14 +63,14 @@ fn hex_to_id(hex: &str) -> ObjectId { · 62 unmodified lines | ||
| 63 | 63 | |
| 64 | 64 | use gix_actor::{Sign, Time}; |
| 65 | 65 | |
| 66 | −fn signature(time: u32) -> gix_actor::SignatureRef<'static> { | |
| 66 | +fn signature(seconds: u32) -> gix_actor::SignatureRef<'static> { | |
| 67 | 67 | use gix_object::bstr::ByteSlice; |
| 68 | 68 | gix_actor::SignatureRef { |
| 69 | 69 | name: b"Sebastian Thiel".as_bstr(), |
| 70 | 70 | email: b"sebastian.thiel@icloud.com".as_bstr(), |
| 71 | 71 | time: Time { |
| 72 | − seconds_since_unix_epoch: time, | |
| 73 | − offset_in_seconds: 28800, | |
| 72 | + seconds, | |
| 73 | + offset: 28800, | |
| 74 | 74 | sign: Sign::Plus, |
| 75 | 75 | }, |
| 76 | 76 | } |
| @@ -82,8 +82,8 @@ fn linus_signature(time: u32) -> gix_actor::SignatureRef<'static> { · 5 unmodified lines | ||
| 82 | 82 | name: b"Linus Torvalds".as_bstr(), |
| 83 | 83 | email: b"torvalds@linux-foundation.org".as_bstr(), |
| 84 | 84 | time: Time { |
| 85 | − seconds_since_unix_epoch: time, | |
| 86 | − offset_in_seconds: -25200, | |
| 85 | + seconds: time, | |
| 86 | + offset: -25200, | |
| 87 | 87 | sign: Sign::Minus, |
| 88 | 88 | }, |
| 89 | 89 | } |
| @@ -239,8 +239,8 @@ cjHJZXWmV4CcRfmLsXzU8s2cR9A0DBvOxhPD1TlKC2JhBFXigjuL9U4Rbq9tdegB · 238 unmodified lines | ||
| 239 | 239 | name: b"Sebastian Thiel".as_bstr(), |
| 240 | 240 | email: b"byronimo@gmail.com".as_bstr(), |
| 241 | 241 | time: gix_actor::Time { |
| 242 | − seconds_since_unix_epoch: 1528473343, | |
| 243 | − offset_in_seconds: offset, | |
| 242 | + seconds: 1528473343, | |
| 243 | + offset: offset, | |
| 244 | 244 | sign: gix_actor::Sign::Plus, |
| 245 | 245 | }, |
| 246 | 246 | }), |
| @@ -430,8 +430,8 @@ fn signature(time: u32) -> gix_actor::SignatureRef<'static> { · 429 unmodified lines | ||
| 430 | 430 | name: b"Sebastian Thiel".as_bstr(), |
| 431 | 431 | email: b"byronimo@gmail.com".as_bstr(), |
| 432 | 432 | time: Time { |
| 433 | − seconds_since_unix_epoch: time, | |
| 434 | − offset_in_seconds: 7200, | |
| 433 | + seconds: time, | |
| 434 | + offset: 7200, | |
| 435 | 435 | sign: Sign::Plus, |
| 436 | 436 | }, |
| 437 | 437 | } |
| @@ -225,8 +225,8 @@ pub mod decode { · 224 unmodified lines | ||
| 225 | 225 | name: b"name".as_bstr(), |
| 226 | 226 | email: b"foo@example.com".as_bstr(), |
| 227 | 227 | time: Time { |
| 228 | − seconds_since_unix_epoch: 1234567890, | |
| 229 | − offset_in_seconds: 0, | |
| 228 | + seconds: 1234567890, | |
| 229 | + offset: 0, | |
| 230 | 230 | sign: Sign::Minus |
| 231 | 231 | } |
| 232 | 232 | }, |
| @@ -251,8 +251,8 @@ pub mod decode { · 18 unmodified lines | ||
| 251 | 251 | name: b"Sebastian Thiel".as_bstr(), |
| 252 | 252 | email: b"foo@example.com".as_bstr(), |
| 253 | 253 | time: Time { |
| 254 | − seconds_since_unix_epoch: 1618030561, | |
| 255 | − offset_in_seconds: 28800, | |
| 254 | + seconds: 1618030561, | |
| 255 | + offset: 28800, | |
| 256 | 256 | sign: Sign::Plus, |
| 257 | 257 | }, |
| 258 | 258 | }, |
| @@ -54,8 +54,8 @@ fn missing_reflog_creates_it_even_if_similarly_named_empty_dir_exists_and_append · 53 unmodified lines | ||
| 54 | 54 | name: "committer".into(), |
| 55 | 55 | email: "committer@example.com".into(), |
| 56 | 56 | time: Time { |
| 57 | − seconds_since_unix_epoch: 1234, | |
| 58 | − offset_in_seconds: 1800, | |
| 57 | + seconds: 1234, | |
| 58 | + offset: 1800, | |
| 59 | 59 | sign: Sign::Plus, |
| 60 | 60 | }, |
| 61 | 61 | }; |
| @@ -33,8 +33,8 @@ pub(crate) mod prepare_and_commit { · 32 unmodified lines | ||
| 33 | 33 | name: "committer".into(), |
| 34 | 34 | email: "committer@example.com".into(), |
| 35 | 35 | time: Time { |
| 36 | − seconds_since_unix_epoch: 1234, | |
| 37 | − offset_in_seconds: 1800, | |
| 36 | + seconds: 1234, | |
| 37 | + offset: 1800, | |
| 38 | 38 | sign: Sign::Plus, |
| 39 | 39 | }, |
| 40 | 40 | } |
| @@ -20,10 +20,7 @@ impl<'graph> LazyCommit<'graph> { · 19 unmodified lines | ||
| 20 | 20 | pub fn committer_timestamp(&self) -> Result<CommitterTimestamp, gix_object::decode::Error> { |
| 21 | 21 | Ok(match &self.backing { |
| 22 | 22 | Either::Left(buf) => { |
| 23 | − gix_object::CommitRefIter::from_bytes(buf) | |
| 24 | − .committer()? | |
| 25 | − .time | |
| 26 | − .seconds_since_unix_epoch as CommitterTimestamp | |
| 23 | + gix_object::CommitRefIter::from_bytes(buf).committer()?.time.seconds as CommitterTimestamp | |
| 27 | 24 | } |
| 28 | 25 | Either::Right((cache, pos)) => cache.commit_at(*pos).committer_timestamp(), |
| 29 | 26 | }) |
| @@ -53,7 +50,7 @@ impl<'graph> LazyCommit<'graph> { · 23 unmodified lines | ||
| 53 | 50 | Token::Parent { id } => parents.push(id), |
| 54 | 51 | Token::Author { .. } => {} |
| 55 | 52 | Token::Committer { signature } => { |
| 56 | − timestamp = Some(signature.time.seconds_since_unix_epoch as CommitterTimestamp); | |
| 53 | + timestamp = Some(signature.time.seconds as CommitterTimestamp); | |
| 57 | 54 | break; |
| 58 | 55 | } |
| 59 | 56 | _ => { |
| @@ -170,7 +170,7 @@ pub mod ancestors { · 169 unmodified lines | ||
| 170 | 170 | oid: commit_id, |
| 171 | 171 | source: err.into(), |
| 172 | 172 | })?; |
| 173 | − let time = commit_iter.committer()?.time.seconds_since_unix_epoch; | |
| 173 | + let time = commit_iter.committer()?.time.seconds; | |
| 174 | 174 | match cutoff_time { |
| 175 | 175 | Some(cutoff_time) if time >= cutoff_time => { |
| 176 | 176 | state.queue.insert(time, commit_id); |
| @@ -383,12 +383,7 @@ pub mod ancestors { · 206 unmodified lines | ||
| 383 | 383 | |
| 384 | 384 | let parent = (self.find)(id.as_ref(), &mut state.parents_buf).ok(); |
| 385 | 385 | let parent_commit_time = parent |
| 386 | − .and_then(|parent| { | |
| 387 | − parent | |
| 388 | − .committer() | |
| 389 | − .ok() | |
| 390 | − .map(|committer| committer.time.seconds_since_unix_epoch) | |
| 391 | − }) | |
| 386 | + .and_then(|parent| parent.committer().ok().map(|committer| committer.time.seconds)) | |
| 392 | 387 | .unwrap_or_default(); |
| 393 | 388 | |
| 394 | 389 | match cutoff_older_than { |
| @@ -91,7 +91,7 @@ pub mod describe { · 90 unmodified lines | ||
| 91 | 91 | let (prio, tag_time) = match target_id { |
| 92 | 92 | Some(target_id) if peeled_id != *target_id => { |
| 93 | 93 | let tag = repo.find_object(target_id).ok()?.try_into_tag().ok()?; |
| 94 | − (1, tag.tagger().ok()??.time.seconds_since_unix_epoch) | |
| 94 | + (1, tag.tagger().ok()??.time.seconds) | |
| 95 | 95 | } |
| 96 | 96 | _ => (0, 0), |
| 97 | 97 | }; |
| @@ -124,11 +124,7 @@ pub mod describe { · 26 unmodified lines | ||
| 124 | 124 | // TODO: we assume direct refs for tags, which is the common case, but it doesn't have to be |
| 125 | 125 | // so rather follow symrefs till the first object and then peel tags after the first object was found. |
| 126 | 126 | let tag = r.try_id()?.object().ok()?.try_into_tag().ok()?; |
| 127 | − let tag_time = tag | |
| 128 | − .tagger() | |
| 129 | − .ok() | |
| 130 | − .and_then(|s| s.map(|s| s.time.seconds_since_unix_epoch)) | |
| 131 | − .unwrap_or(0); | |
| 127 | + let tag_time = tag.tagger().ok().and_then(|s| s.map(|s| s.time.seconds)).unwrap_or(0); | |
| 132 | 128 | let commit_id = tag.target_id().ok()?.object().ok()?.try_into_commit().ok()?.id; |
| 133 | 129 | Some((commit_id, tag_time, Cow::<BStr>::from(r.name().shorten().to_owned()))) |
| 134 | 130 | }) |
| @@ -348,14 +348,14 @@ fn add_shallow_args( · 347 unmodified lines | ||
| 348 | 348 | args.deepen_relative(); |
| 349 | 349 | } |
| 350 | 350 | Shallow::Since { cutoff } => { |
| 351 | − args.deepen_since(cutoff.seconds_since_unix_epoch as usize); | |
| 351 | + args.deepen_since(cutoff.seconds as usize); | |
| 352 | 352 | } |
| 353 | 353 | Shallow::Exclude { |
| 354 | 354 | remote_refs, |
| 355 | 355 | since_cutoff, |
| 356 | 356 | } => { |
| 357 | 357 | if let Some(cutoff) = since_cutoff { |
| 358 | − args.deepen_since(cutoff.seconds_since_unix_epoch as usize); | |
| 358 | + args.deepen_since(cutoff.seconds as usize); | |
| 359 | 359 | } |
| 360 | 360 | for ref_ in remote_refs { |
| 361 | 361 | args.deepen_not(ref_.as_ref().as_bstr()); |
| @@ -126,7 +126,7 @@ pub(crate) fn update( · 125 unmodified lines | ||
| 126 | 126 | .try_into_commit() |
| 127 | 127 | .map_err(|_| ()) |
| 128 | 128 | .and_then(|c| { |
| 129 | − c.committer().map(|a| a.time.seconds_since_unix_epoch).map_err(|_| ()) | |
| 129 | + c.committer().map(|a| a.time.seconds).map_err(|_| ()) | |
| 130 | 130 | }).and_then(|local_commit_time| |
| 131 | 131 | remote_id |
| 132 | 132 | .to_owned() |
| @@ -48,8 +48,8 @@ fn author_and_committer_and_fallback() -> crate::Result { · 47 unmodified lines | ||
| 48 | 48 | name: "author".into(), |
| 49 | 49 | email: "author@email".into(), |
| 50 | 50 | time: gix_date::Time { |
| 51 | − seconds_since_unix_epoch: 1659329106, | |
| 52 | − offset_in_seconds: 28800, | |
| 51 | + seconds: 1659329106, | |
| 52 | + offset: 28800, | |
| 53 | 53 | sign: gix_date::time::Sign::Plus |
| 54 | 54 | } |
| 55 | 55 | } |
| @@ -61,8 +61,8 @@ fn author_and_committer_and_fallback() -> crate::Result { · 5 unmodified lines | ||
| 61 | 61 | name: "committer".into(), |
| 62 | 62 | email: "committer@email".into(), |
| 63 | 63 | time: gix_date::Time { |
| 64 | − seconds_since_unix_epoch: 1659365106, | |
| 65 | − offset_in_seconds: -7200, | |
| 64 | + seconds: 1659365106, | |
| 65 | + offset: -7200, | |
| 66 | 66 | sign: gix_date::time::Sign::Minus |
| 67 | 67 | } |
| 68 | 68 | } |
| @@ -167,8 +167,8 @@ fn author_from_different_config_sections() -> crate::Result { · 98 unmodified lines | ||
| 167 | 167 | name: "global name".into(), |
| 168 | 168 | email: "local@example.com".into(), |
| 169 | 169 | time: gix_date::Time { |
| 170 | − seconds_since_unix_epoch: 42, | |
| 171 | − offset_in_seconds: 1800, | |
| 170 | + seconds: 42, | |
| 171 | + offset: 1800, | |
| 172 | 172 | sign: gix_date::time::Sign::Plus |
| 173 | 173 | } |
| 174 | 174 | }), |
| @@ -181,8 +181,8 @@ fn author_from_different_config_sections() -> crate::Result { · 6 unmodified lines | ||
| 181 | 181 | name: "local committer".into(), |
| 182 | 182 | email: "global-committer@example.com".into(), |
| 183 | 183 | time: gix_date::Time { |
| 184 | − seconds_since_unix_epoch: 320437800, | |
| 185 | − offset_in_seconds: 0, | |
| 184 | + seconds: 320437800, | |
| 185 | + offset: 0, | |
| 186 | 186 | sign: gix_date::time::Sign::Plus, |
| 187 | 187 | } |
| 188 | 188 | }), |