Skip to content

Commit ab21083

Browse files
committed
fix: allow parsing of commits with broken timestamp (#1322).
Instead, default to UTC just like Git.
1 parent 741e373 commit ab21083

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

gix-object/tests/commit/from_bytes.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,33 @@ use crate::{
88
fixture_name, linus_signature, signature,
99
};
1010

11+
#[test]
12+
fn invalid_timestsamp() {
13+
let actor = gix_actor::SignatureRef {
14+
name: b"Name".as_bstr(),
15+
email: b"[email protected]".as_bstr(),
16+
time: Time {
17+
seconds: 1312735823,
18+
offset: 0,
19+
sign: Sign::Plus,
20+
},
21+
};
22+
assert_eq!(
23+
CommitRef::from_bytes(&fixture_name("commit", "invalid-timestamp.txt"))
24+
.expect("auto-correct invalid timestamp by discarding it (time is still valid UTC)"),
25+
CommitRef {
26+
tree: b"7989dfb2ec2f41914611a22fb30bbc2b3849df9a".as_bstr(),
27+
parents: [b"8845ae683e2688bc619baade49510c17e978518f".as_bstr()].into(),
28+
author: actor,
29+
committer: actor,
30+
encoding: None,
31+
message: b"edit changelog to mention about x_sendfile_header default change".as_bstr(),
32+
extra_headers: vec![]
33+
},
34+
"the offset of the actor is null, leaving the UTC time"
35+
);
36+
}
37+
1138
#[test]
1239
fn unsigned() -> crate::Result {
1340
assert_eq!(
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
tree 7989dfb2ec2f41914611a22fb30bbc2b3849df9a
2+
parent 8845ae683e2688bc619baade49510c17e978518f
3+
author Name <[email protected]> 1312735823 +051800
4+
committer Name <[email protected]> 1312735823 +051800
5+
6+
edit changelog to mention about x_sendfile_header default change

0 commit comments

Comments
 (0)