@@ -4,7 +4,7 @@ use smallvec::SmallVec;
44
55use crate :: {
66 commit:: { LONG_MESSAGE , MERGE_TAG , SIGNATURE } ,
7- fixture_name, hex_to_id, linus_signature, signature ,
7+ fixture_name, hex_to_id, linus_signature,
88} ;
99
1010#[ test]
@@ -26,12 +26,14 @@ fn invalid_timestsamp() {
2626}
2727
2828#[ test]
29- fn invalid_email_of_committer ( ) {
29+ fn invalid_email_of_committer ( ) -> crate :: Result {
3030 let actor = gix_actor:: SignatureRef {
3131 name : b"Gregor Hartmann" . as_bstr ( ) ,
3232 email : b"gh <Gregor Hartmann<gh@openoffice.org" . as_bstr ( ) ,
3333 time : "1282910542 +0200" ,
3434 } ;
35+
36+ let mut buf = vec ! [ ] ;
3537 let backing = fixture_name ( "commit" , "invalid-actor.txt" ) ;
3638 let commit = CommitRef :: from_bytes ( & backing) . expect ( "ignore strangely formed actor format" ) ;
3739 assert_eq ! (
@@ -46,8 +48,17 @@ fn invalid_email_of_committer() {
4648 extra_headers: vec![ ]
4749 }
4850 ) ;
49- assert_eq ! ( commit. author( ) . unwrap( ) , actor) ;
50- assert_eq ! ( commit. committer( ) . unwrap( ) , actor) ;
51+ assert_eq ! ( commit. author( ) ?, actor) ;
52+ assert_eq ! ( commit. committer( ) ?, actor) ;
53+
54+ commit. write_to ( & mut buf) . expect ( "we can write invalid actors back" ) ;
55+ assert_eq ! (
56+ CommitRef :: from_bytes( & buf) . expect( "this is the same commit and it can be parsed" ) ,
57+ commit,
58+ "round-tripping works"
59+ ) ;
60+
61+ Ok ( ( ) )
5162}
5263
5364#[ test]
@@ -123,8 +134,8 @@ fn mergetag() -> crate::Result {
123134 assert_eq ! ( commit, expected) ;
124135 assert_eq ! ( commit. extra_headers( ) . find_all( "mergetag" ) . count( ) , 1 ) ;
125136 assert_eq ! ( commit. extra_headers( ) . mergetags( ) . count( ) , 1 ) ;
126- assert_eq ! ( commit. author( ) . unwrap ( ) , linus_signature( "1591996221 -0700" ) ) ;
127- assert_eq ! ( commit. committer( ) . unwrap ( ) , linus_signature( "1591996221 -0700" ) ) ;
137+ assert_eq ! ( commit. author( ) ? , linus_signature( "1591996221 -0700" ) ) ;
138+ assert_eq ! ( commit. committer( ) ? , linus_signature( "1591996221 -0700" ) ) ;
128139 Ok ( ( ) )
129140}
130141
@@ -244,8 +255,8 @@ Signed-off-by: Kim Altintop <kim@eagain.st>"
244255 extra_headers: vec![ ( b"gpgsig" . as_bstr( ) , b"-----BEGIN PGP SIGNATURE-----\n \n iHUEABYIAB0WIQSuZwcGWSQItmusNgR5URpSUCnwXQUCYT7xpAAKCRB5URpSUCnw\n XWB3AP9q323HlxnI8MyqszNOeYDwa7Y3yEZaUM2y/IRjz+z4YQEAq0yr1Syt3mrK\n OSFCqL2vDm3uStP+vF31f6FnzayhNg0=\n =Mhpp\n -----END PGP SIGNATURE-----\n " . as_bstr( ) . into( ) ) ]
245256 }
246257 ) ;
247- assert_eq ! ( commit. author( ) . unwrap ( ) , kim) ;
248- assert_eq ! ( commit. committer( ) . unwrap ( ) , kim) ;
258+ assert_eq ! ( commit. author( ) ? , kim) ;
259+ assert_eq ! ( commit. committer( ) ? , kim) ;
249260 let message = commit. message ( ) ;
250261 assert_eq ! ( message. title, "test: use gitoxide for link-git-protocol tests" ) ;
251262 assert_eq ! (
@@ -359,12 +370,3 @@ fn bogus_multi_gpgsig_header() -> crate::Result {
359370 ) ;
360371 Ok ( ( ) )
361372}
362-
363- #[ test]
364- fn author_method_returns_trimmed_signature ( ) -> crate :: Result {
365- let backing = fixture_name ( "commit" , "unsigned.txt" ) ;
366- let commit = CommitRef :: from_bytes ( & backing) ?;
367- assert_eq ! ( commit. author( ) . unwrap( ) , signature( "1592437401 +0800" ) ) ;
368- assert_eq ! ( commit. committer( ) . unwrap( ) , signature( "1592437401 +0800" ) ) ;
369- Ok ( ( ) )
370- }
0 commit comments