Skip to content

Commit d575336

Browse files
committed
adapt to changes in gix-date
1 parent 4bc0ae1 commit d575336

File tree

20 files changed

+58
-79
lines changed

20 files changed

+58
-79
lines changed

cargo-smart-release/src/utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ mod tests {
300300
}
301301

302302
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)
304304
.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"))
306306
}

gitoxide-core/src/hours/core.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,7 @@ pub fn estimate_hours(
2424
let hours_for_commits = commits.iter().map(|t| &t.1).rev().tuple_windows().fold(
2525
0_f32,
2626
|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;
3228
if change_in_minutes < MAX_COMMIT_DIFFERENCE_IN_MINUTES {
3329
hours + change_in_minutes / MINUTES_PER_HOUR
3430
} else {

gitoxide-core/src/hours/mod.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,9 @@ where
9595
}
9696
out.shrink_to_fit();
9797
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())
104101
});
105102
Ok(out)
106103
});

gix-actor/src/signature/decode.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
pub(crate) mod function {
22
use bstr::ByteSlice;
33
use btoi::btoi;
4+
use gix_date::{OffsetInSeconds, SecondsSinceUnixEpoch};
45
use nom::{
56
branch::alt,
67
bytes::complete::{tag, take, take_until, take_while_m_n},
@@ -25,22 +26,22 @@ pub(crate) mod function {
2526
tag(b" "),
2627
context("<timestamp>", |i| {
2728
terminated(take_until(SPACE), take(1usize))(i).and_then(|(i, v)| {
28-
btoi::<u32>(v)
29+
btoi::<SecondsSinceUnixEpoch>(v)
2930
.map(|v| (i, v))
3031
.map_err(|_| nom::Err::Error(E::from_error_kind(i, nom::error::ErrorKind::MapRes)))
3132
})
3233
}),
3334
context("+|-", alt((tag(b"-"), tag(b"+")))),
3435
context("HH", |i| {
3536
take_while_m_n(2usize, 2, is_digit)(i).and_then(|(i, v)| {
36-
btoi::<i32>(v)
37+
btoi::<OffsetInSeconds>(v)
3738
.map(|v| (i, v))
3839
.map_err(|_| nom::Err::Error(E::from_error_kind(i, nom::error::ErrorKind::MapRes)))
3940
})
4041
}),
4142
context("MM", |i| {
4243
take_while_m_n(2usize, 2, is_digit)(i).and_then(|(i, v)| {
43-
btoi::<i32>(v)
44+
btoi::<OffsetInSeconds>(v)
4445
.map(|v| (i, v))
4546
.map_err(|_| nom::Err::Error(E::from_error_kind(i, nom::error::ErrorKind::MapRes)))
4647
})
@@ -58,8 +59,8 @@ pub(crate) mod function {
5859
name: identity.name,
5960
email: identity.email,
6061
time: Time {
61-
seconds_since_unix_epoch: time,
62-
offset_in_seconds: offset,
62+
seconds: time,
63+
offset: offset,
6364
sign,
6465
},
6566
},
@@ -93,6 +94,7 @@ pub use function::identity;
9394
mod tests {
9495
mod parse_signature {
9596
use bstr::ByteSlice;
97+
use gix_date::{OffsetInSeconds, SecondsSinceUnixEpoch};
9698
use gix_testtools::to_bstr_err;
9799
use nom::IResult;
98100

@@ -105,18 +107,14 @@ mod tests {
105107
fn signature(
106108
name: &'static str,
107109
email: &'static str,
108-
time: u32,
110+
seconds: SecondsSinceUnixEpoch,
109111
sign: Sign,
110-
offset: i32,
112+
offset: OffsetInSeconds,
111113
) -> SignatureRef<'static> {
112114
SignatureRef {
113115
name: name.as_bytes().as_bstr(),
114116
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 },
120118
}
121119
}
122120

gix-actor/tests/signature/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ mod write_to {
4343

4444
fn default_time() -> Time {
4545
Time {
46-
seconds_since_unix_epoch: 0,
47-
offset_in_seconds: 0,
46+
seconds: 0,
47+
offset: 0,
4848
sign: Sign::Plus,
4949
}
5050
}

gix-mailmap/tests/snapshot/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ fn signature(name: &str, email: &str) -> gix_actor::Signature {
119119
email: email.into(),
120120
time: gix_actor::Time {
121121
// marker
122-
seconds_since_unix_epoch: 42,
123-
offset_in_seconds: 53,
122+
seconds: 42,
123+
offset: 53,
124124
sign: gix_actor::Sign::Minus,
125125
},
126126
}

gix-object/tests/commit/from_bytes.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ fn with_trailer() -> crate::Result {
139139
name: "Kim Altintop".into(),
140140
email: "kim@eagain.st".into(),
141141
time: Time {
142-
seconds_since_unix_epoch: 1631514803,
143-
offset_in_seconds: 7200,
142+
seconds: 1631514803,
143+
offset: 7200,
144144
sign: Sign::Plus,
145145
},
146146
};

gix-object/tests/commit/message.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,8 @@ mod summary {
236236
name: "name".into(),
237237
email: "email".into(),
238238
time: Time {
239-
seconds_since_unix_epoch: 0,
240-
offset_in_seconds: 0,
239+
seconds: 0,
240+
offset: 0,
241241
sign: Sign::Plus,
242242
},
243243
};

gix-object/tests/object.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ fn hex_to_id(hex: &str) -> ObjectId {
6363

6464
use gix_actor::{Sign, Time};
6565

66-
fn signature(time: u32) -> gix_actor::SignatureRef<'static> {
66+
fn signature(seconds: u32) -> gix_actor::SignatureRef<'static> {
6767
use gix_object::bstr::ByteSlice;
6868
gix_actor::SignatureRef {
6969
name: b"Sebastian Thiel".as_bstr(),
7070
email: b"sebastian.thiel@icloud.com".as_bstr(),
7171
time: Time {
72-
seconds_since_unix_epoch: time,
73-
offset_in_seconds: 28800,
72+
seconds,
73+
offset: 28800,
7474
sign: Sign::Plus,
7575
},
7676
}
@@ -82,8 +82,8 @@ fn linus_signature(time: u32) -> gix_actor::SignatureRef<'static> {
8282
name: b"Linus Torvalds".as_bstr(),
8383
email: b"torvalds@linux-foundation.org".as_bstr(),
8484
time: Time {
85-
seconds_since_unix_epoch: time,
86-
offset_in_seconds: -25200,
85+
seconds: time,
86+
offset: -25200,
8787
sign: Sign::Minus,
8888
},
8989
}

gix-object/tests/tag/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,8 @@ cjHJZXWmV4CcRfmLsXzU8s2cR9A0DBvOxhPD1TlKC2JhBFXigjuL9U4Rbq9tdegB
239239
name: b"Sebastian Thiel".as_bstr(),
240240
email: b"byronimo@gmail.com".as_bstr(),
241241
time: gix_actor::Time {
242-
seconds_since_unix_epoch: 1528473343,
243-
offset_in_seconds: offset,
242+
seconds: 1528473343,
243+
offset: offset,
244244
sign: gix_actor::Sign::Plus,
245245
},
246246
}),

gix-odb/tests/odb/store/loose.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,8 +430,8 @@ fn signature(time: u32) -> gix_actor::SignatureRef<'static> {
430430
name: b"Sebastian Thiel".as_bstr(),
431431
email: b"byronimo@gmail.com".as_bstr(),
432432
time: Time {
433-
seconds_since_unix_epoch: time,
434-
offset_in_seconds: 7200,
433+
seconds: time,
434+
offset: 7200,
435435
sign: Sign::Plus,
436436
},
437437
}

gix-ref/src/store/file/log/line.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,8 @@ pub mod decode {
225225
name: b"name".as_bstr(),
226226
email: b"foo@example.com".as_bstr(),
227227
time: Time {
228-
seconds_since_unix_epoch: 1234567890,
229-
offset_in_seconds: 0,
228+
seconds: 1234567890,
229+
offset: 0,
230230
sign: Sign::Minus
231231
}
232232
},
@@ -251,8 +251,8 @@ pub mod decode {
251251
name: b"Sebastian Thiel".as_bstr(),
252252
email: b"foo@example.com".as_bstr(),
253253
time: Time {
254-
seconds_since_unix_epoch: 1618030561,
255-
offset_in_seconds: 28800,
254+
seconds: 1618030561,
255+
offset: 28800,
256256
sign: Sign::Plus,
257257
},
258258
},

gix-ref/src/store/file/loose/reflog/create_or_update/tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ fn missing_reflog_creates_it_even_if_similarly_named_empty_dir_exists_and_append
5454
name: "committer".into(),
5555
email: "committer@example.com".into(),
5656
time: Time {
57-
seconds_since_unix_epoch: 1234,
58-
offset_in_seconds: 1800,
57+
seconds: 1234,
58+
offset: 1800,
5959
sign: Sign::Plus,
6060
},
6161
};

gix-ref/tests/file/transaction/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ pub(crate) mod prepare_and_commit {
3333
name: "committer".into(),
3434
email: "committer@example.com".into(),
3535
time: Time {
36-
seconds_since_unix_epoch: 1234,
37-
offset_in_seconds: 1800,
36+
seconds: 1234,
37+
offset: 1800,
3838
sign: Sign::Plus,
3939
},
4040
}

gix-revwalk/src/graph/commit.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@ impl<'graph> LazyCommit<'graph> {
2020
pub fn committer_timestamp(&self) -> Result<CommitterTimestamp, gix_object::decode::Error> {
2121
Ok(match &self.backing {
2222
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
2724
}
2825
Either::Right((cache, pos)) => cache.commit_at(*pos).committer_timestamp(),
2926
})
@@ -53,7 +50,7 @@ impl<'graph> LazyCommit<'graph> {
5350
Token::Parent { id } => parents.push(id),
5451
Token::Author { .. } => {}
5552
Token::Committer { signature } => {
56-
timestamp = Some(signature.time.seconds_since_unix_epoch as CommitterTimestamp);
53+
timestamp = Some(signature.time.seconds as CommitterTimestamp);
5754
break;
5855
}
5956
_ => {

gix-traverse/src/commit.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ pub mod ancestors {
170170
oid: commit_id,
171171
source: err.into(),
172172
})?;
173-
let time = commit_iter.committer()?.time.seconds_since_unix_epoch;
173+
let time = commit_iter.committer()?.time.seconds;
174174
match cutoff_time {
175175
Some(cutoff_time) if time >= cutoff_time => {
176176
state.queue.insert(time, commit_id);
@@ -383,12 +383,7 @@ pub mod ancestors {
383383

384384
let parent = (self.find)(id.as_ref(), &mut state.parents_buf).ok();
385385
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))
392387
.unwrap_or_default();
393388

394389
match cutoff_older_than {

gix/src/commit.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ pub mod describe {
9191
let (prio, tag_time) = match target_id {
9292
Some(target_id) if peeled_id != *target_id => {
9393
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)
9595
}
9696
_ => (0, 0),
9797
};
@@ -124,11 +124,7 @@ pub mod describe {
124124
// TODO: we assume direct refs for tags, which is the common case, but it doesn't have to be
125125
// so rather follow symrefs till the first object and then peel tags after the first object was found.
126126
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);
132128
let commit_id = tag.target_id().ok()?.object().ok()?.try_into_commit().ok()?.id;
133129
Some((commit_id, tag_time, Cow::<BStr>::from(r.name().shorten().to_owned())))
134130
})

gix/src/remote/connection/fetch/receive_pack.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,14 +348,14 @@ fn add_shallow_args(
348348
args.deepen_relative();
349349
}
350350
Shallow::Since { cutoff } => {
351-
args.deepen_since(cutoff.seconds_since_unix_epoch as usize);
351+
args.deepen_since(cutoff.seconds as usize);
352352
}
353353
Shallow::Exclude {
354354
remote_refs,
355355
since_cutoff,
356356
} => {
357357
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);
359359
}
360360
for ref_ in remote_refs {
361361
args.deepen_not(ref_.as_ref().as_bstr());

gix/src/remote/connection/fetch/update_refs/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ pub(crate) fn update(
126126
.try_into_commit()
127127
.map_err(|_| ())
128128
.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(|_| ())
130130
}).and_then(|local_commit_time|
131131
remote_id
132132
.to_owned()

gix/tests/repository/config/identity.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ fn author_and_committer_and_fallback() -> crate::Result {
4848
name: "author".into(),
4949
email: "author@email".into(),
5050
time: gix_date::Time {
51-
seconds_since_unix_epoch: 1659329106,
52-
offset_in_seconds: 28800,
51+
seconds: 1659329106,
52+
offset: 28800,
5353
sign: gix_date::time::Sign::Plus
5454
}
5555
}
@@ -61,8 +61,8 @@ fn author_and_committer_and_fallback() -> crate::Result {
6161
name: "committer".into(),
6262
email: "committer@email".into(),
6363
time: gix_date::Time {
64-
seconds_since_unix_epoch: 1659365106,
65-
offset_in_seconds: -7200,
64+
seconds: 1659365106,
65+
offset: -7200,
6666
sign: gix_date::time::Sign::Minus
6767
}
6868
}
@@ -167,8 +167,8 @@ fn author_from_different_config_sections() -> crate::Result {
167167
name: "global name".into(),
168168
email: "local@example.com".into(),
169169
time: gix_date::Time {
170-
seconds_since_unix_epoch: 42,
171-
offset_in_seconds: 1800,
170+
seconds: 42,
171+
offset: 1800,
172172
sign: gix_date::time::Sign::Plus
173173
}
174174
}),
@@ -181,8 +181,8 @@ fn author_from_different_config_sections() -> crate::Result {
181181
name: "local committer".into(),
182182
email: "global-committer@example.com".into(),
183183
time: gix_date::Time {
184-
seconds_since_unix_epoch: 320437800,
185-
offset_in_seconds: 0,
184+
seconds: 320437800,
185+
offset: 0,
186186
sign: gix_date::time::Sign::Plus,
187187
}
188188
}),

0 commit comments

Comments
 (0)