Skip to content

Commit ce5d79c

Browse files
pierrechevalier83Byron
authored andcommitted
Add test for tag missing timestamp in tagger (#1542)
This tag exists in an opensource repository: https://kernel.googlesource.com/pub/scm/network/bridge/bridge-utils/+/refs/tags/ChangeLog gitoxide can't parse it because it's got a tagger line, but no timestamp. git itself is more lenient about such cases, basically returning a timestamp of 0 if the timestamp is missing: https://github.com/git/git/blob/master/tag.c#L116 This is a new test to show the current behaviour.
1 parent 46cd1ae commit ce5d79c

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
object 4fcd840c4935e4c7a5ea3552710a0f26b9178c24
2+
type commit
3+
tag ChangeLog
4+
tagger shemminger <shemminger>

gix-object/tests/tag/mod.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,21 @@ KLMHist5yj0sw1E4hDTyQa0=
229229
);
230230
Ok(())
231231
}
232+
233+
#[test]
234+
fn tagger_without_timestamp() -> crate::Result {
235+
// Note: this behaviour is inconsistent with Git's
236+
// Git would successfully interpret this tag and set the timestamp to 0
237+
// See https://github.com/git/git/blob/3a7362eb9fad0c4838f5cfaa95ed3c51a4c18d93/tag.c#L116
238+
assert_eq!(
239+
format!(
240+
"{:?}",
241+
TagRef::from_bytes(&fixture_name("tag", "tagger-without-timestamp.txt"))
242+
),
243+
"Err(Error { inner: () })".to_string()
244+
);
245+
Ok(())
246+
}
232247
}
233248

234249
fn tag_fixture(offset: i32) -> TagRef<'static> {

0 commit comments

Comments
 (0)