@@ -9,19 +9,14 @@ use crate::{
99
1010#[ test]
1111fn invalid_timestsamp ( ) {
12- let actor = gix_actor:: SignatureRef {
13- name : b"Name" . as_bstr ( ) ,
14- email : b"name@example.com" . as_bstr ( ) ,
15- time : "1312735823 +051800" ,
16- } ;
1712 assert_eq ! (
1813 CommitRef :: from_bytes( & fixture_name( "commit" , "invalid-timestamp.txt" ) )
1914 . expect( "auto-correct invalid timestamp by discarding it (time is still valid UTC)" ) ,
2015 CommitRef {
2116 tree: b"7989dfb2ec2f41914611a22fb30bbc2b3849df9a" . as_bstr( ) ,
2217 parents: [ b"8845ae683e2688bc619baade49510c17e978518f" . as_bstr( ) ] . into( ) ,
23- author: actor ,
24- committer: actor ,
18+ author: b"Name <name@example.com> 1312735823 +051800" . as_bstr ( ) ,
19+ committer: b"Name <name@example.com> 1312735823 +051800" . as_bstr ( ) ,
2520 encoding: None ,
2621 message: b"edit changelog to mention about x_sendfile_header default change" . as_bstr( ) ,
2722 extra_headers: vec![ ]
@@ -43,8 +38,8 @@ fn invalid_email_of_committer() {
4338 CommitRef {
4439 tree: b"220738fd4199e95a2b244465168366a73ebdf271" . as_bstr( ) ,
4540 parents: [ b"209fbe2d632761b30b7b17422914e11b93692833" . as_bstr( ) ] . into( ) ,
46- author: actor ,
47- committer: actor ,
41+ author: b"Gregor Hartmann<gh <Gregor Hartmann<gh@openoffice.org>> 1282910542 +0200" . as_bstr ( ) ,
42+ committer: b"Gregor Hartmann<gh <Gregor Hartmann<gh@openoffice.org>> 1282910542 +0200" . as_bstr ( ) ,
4843 encoding: None ,
4944 message: b"build breakers" . as_bstr( ) ,
5045 extra_headers: vec![ ]
@@ -59,8 +54,8 @@ fn unsigned() -> crate::Result {
5954 CommitRef {
6055 tree: b"1b2dfb4ac5e42080b682fc676e9738c94ce6d54d" . as_bstr( ) ,
6156 parents: SmallVec :: default ( ) ,
62- author: signature ( " 1592437401 +0800") ,
63- committer: signature ( " 1592437401 +0800") ,
57+ author: b"Sebastian Thiel <sebastian.thiel@icloud.com> 1592437401 +0800". as_bstr ( ) ,
58+ committer: b"Sebastian Thiel <sebastian.thiel@icloud.com> 1592437401 +0800". as_bstr ( ) ,
6459 encoding: None ,
6560 message: b"without sig" . as_bstr( ) ,
6661 extra_headers: vec![ ]
@@ -76,8 +71,8 @@ fn whitespace() -> crate::Result {
7671 CommitRef {
7772 tree: b"9bed6275068a0575243ba8409253e61af81ab2ff" . as_bstr( ) ,
7873 parents: SmallVec :: from( vec![ b"26b4df046d1776c123ac69d918f5aec247b58cc6" . as_bstr( ) ] ) ,
79- author: signature ( " 1592448450 +0800") ,
80- committer: signature ( " 1592448450 +0800") ,
74+ author: b"Sebastian Thiel <sebastian.thiel@icloud.com> 1592448450 +0800". as_bstr ( ) ,
75+ committer: b"Sebastian Thiel <sebastian.thiel@icloud.com> 1592448450 +0800". as_bstr ( ) ,
8176 encoding: None ,
8277 message: b" nl" . as_bstr( ) , // this one had a \n trailing it, but git seems to trim that
8378 extra_headers: vec![ ]
@@ -93,8 +88,8 @@ fn signed_singleline() -> crate::Result {
9388 CommitRef {
9489 tree: b"00fc39317701176e326974ce44f5bd545a32ec0b" . as_bstr( ) ,
9590 parents: SmallVec :: from( vec![ b"09d8d3a12e161a7f6afb522dbe8900a9c09bce06" . as_bstr( ) ] ) ,
96- author: signature ( " 1592391367 +0800") ,
97- committer: signature ( " 1592391367 +0800") ,
91+ author: b"Sebastian Thiel <sebastian.thiel@icloud.com> 1592391367 +0800". as_bstr ( ) ,
92+ committer: b"Sebastian Thiel <sebastian.thiel@icloud.com> 1592391367 +0800". as_bstr ( ) ,
9893 encoding: None ,
9994 message: b"update tasks\n " . as_bstr( ) ,
10095 extra_headers: vec![ ( b"gpgsig" . as_bstr( ) , b"magic:signature" . as_bstr( ) . into( ) ) ]
@@ -112,8 +107,8 @@ fn mergetag() -> crate::Result {
112107 b"44ebe016df3aad96e3be8f95ec52397728dd7701" . as_bstr( ) ,
113108 b"8d485da0ddee79d0e6713405694253d401e41b93" . as_bstr( ) ,
114109 ] ) ,
115- author : linus_signature ( " 1591996221 -0700") ,
116- committer : linus_signature ( " 1591996221 -0700") ,
110+ author : b"Linus Torvalds <torvalds@linux-foundation.org> 1591996221 -0700". as_bstr ( ) ,
111+ committer : b"Linus Torvalds <torvalds@linux-foundation.org> 1591996221 -0700". as_bstr ( ) ,
117112 encoding : None ,
118113 message : LONG_MESSAGE . as_bytes ( ) . as_bstr ( ) ,
119114 extra_headers : vec ! [ (
@@ -134,8 +129,8 @@ fn signed() -> crate::Result {
134129 CommitRef {
135130 tree: b"00fc39317701176e326974ce44f5bd545a32ec0b" . as_bstr( ) ,
136131 parents: SmallVec :: from( vec![ b"09d8d3a12e161a7f6afb522dbe8900a9c09bce06" . as_bstr( ) ] ) ,
137- author: signature ( " 1592391367 +0800") ,
138- committer: signature ( " 1592391367 +0800") ,
132+ author: b"Sebastian Thiel <sebastian.thiel@icloud.com> 1592391367 +0800". as_bstr ( ) ,
133+ committer: b"Sebastian Thiel <sebastian.thiel@icloud.com> 1592391367 +0800". as_bstr ( ) ,
139134 encoding: None ,
140135 message: b"update tasks\n " . as_bstr( ) ,
141136 extra_headers: vec![ ( b"gpgsig" . as_bstr( ) , b"-----BEGIN PGP SIGNATURE-----\n \n iQEzBAABCAAdFiEEdjYp/sh4j8NRKLX27gKdHl60AwAFAl7p9tgACgkQ7gKdHl60\n AwBpegf+KQciv9AOIN7+yPmowecGxBnSfpKWTDzFxnyGR8dq63SpWT8WEKG5mf3a\n G6iUqpsDWaMHlzihaMKRvgRpZxFRbjnNPFBj6F4RRqfE+5R7k6DRSLUV5PqnsdSH\n uccfIDWi1imhsm7AaP5trwl1t+83U2JhHqPcPVFLMODYwWeO6NLR/JCzGSTQRa8t\n RgaVMKI19O/fge5OT5Ua8D47VKEhsJX0LfmkP5RfZQ8JJvNd40TupqKRdlv0sAzP\n ya7NXkSHXCavHNR6kA+KpWxn900UoGK8/IDlwU6MeOkpPVawb3NFMqnc7KJDaC2p\n SMzpuEG8LTrCx2YSpHNLqHyzvQ1CZA==\n =5ITV\n -----END PGP SIGNATURE-----\n " . as_bstr( ) . into( ) ) ]
@@ -151,8 +146,8 @@ fn signed_with_encoding() -> crate::Result {
151146 CommitRef {
152147 tree: b"1973afa74d87b2bb73fa884aaaa8752aec43ea88" . as_bstr( ) ,
153148 parents: SmallVec :: from( vec![ b"79c51cc86923e2b8ca0ee5c4eb75e48027133f9a" . as_bstr( ) ] ) ,
154- author: signature ( " 1592448995 +0800") ,
155- committer: signature ( " 1592449083 +0800") ,
149+ author: b"Sebastian Thiel <sebastian.thiel@icloud.com> 1592448995 +0800". as_bstr ( ) ,
150+ committer: b"Sebastian Thiel <sebastian.thiel@icloud.com> 1592449083 +0800". as_bstr ( ) ,
156151 encoding: Some ( b"ISO-8859-1" . as_bstr( ) ) ,
157152 message: b"encoding & sig" . as_bstr( ) ,
158153 extra_headers: vec![ ( b"gpgsig" . as_bstr( ) , SIGNATURE . as_bstr( ) . into( ) ) ]
@@ -168,8 +163,8 @@ fn with_encoding() -> crate::Result {
168163 CommitRef {
169164 tree: b"4a1c03029e7407c0afe9fc0320b3258e188b115e" . as_bstr( ) ,
170165 parents: SmallVec :: from( vec![ b"7ca98aad461a5c302cb4c9e3acaaa6053cc67a62" . as_bstr( ) ] ) ,
171- author: signature ( " 1592438199 +0800") ,
172- committer: signature ( " 1592438199 +0800") ,
166+ author: b"Sebastian Thiel <sebastian.thiel@icloud.com> 1592438199 +0800". as_bstr ( ) ,
167+ committer: b"Sebastian Thiel <sebastian.thiel@icloud.com> 1592438199 +0800". as_bstr ( ) ,
173168 encoding: Some ( "ISO-8859-1" . into( ) ) ,
174169 message: b"commit with encoding" . as_bstr( ) ,
175170 extra_headers: vec![ ]
@@ -180,18 +175,13 @@ fn with_encoding() -> crate::Result {
180175
181176#[ test]
182177fn pre_epoch ( ) -> crate :: Result {
183- let signature = || SignatureRef {
184- name : "Législateur" . into ( ) ,
185- email : "" . into ( ) ,
186- time : "-5263834140 +0009" ,
187- } ;
188178 assert_eq ! (
189179 CommitRef :: from_bytes( & fixture_name( "commit" , "pre-epoch.txt" ) ) ?,
190180 CommitRef {
191181 tree: b"71cdd4015386b764b178005cad4c88966bc9d61a" . as_bstr( ) ,
192182 parents: SmallVec :: default ( ) ,
193- author: signature ( ) ,
194- committer: signature ( ) ,
183+ author: "Législateur <> -5263834140 +0009" . as_bytes ( ) . as_bstr ( ) ,
184+ committer: "Législateur <> -5263834140 +0009" . as_bytes ( ) . as_bstr ( ) ,
195185 encoding: None ,
196186 message: "Version consolidée au 14 mars 1803\n " . into( ) ,
197187 extra_headers: vec![ ]
@@ -202,18 +192,13 @@ fn pre_epoch() -> crate::Result {
202192
203193#[ test]
204194fn double_dash_special_time_offset ( ) -> crate :: Result {
205- let signature = || SignatureRef {
206- name : "name" . into ( ) ,
207- email : "name@example.com" . into ( ) ,
208- time : "1288373970 --700" ,
209- } ;
210195 assert_eq ! (
211196 CommitRef :: from_bytes( & fixture_name( "commit" , "double-dash-date-offset.txt" ) ) ?,
212197 CommitRef {
213198 tree: b"0a851d7a2a66084ab10516c406a405d147e974ad" . as_bstr( ) ,
214199 parents: SmallVec :: from( vec![ b"31350f4f0f459485eff2131517e3450cf251f6fa" . as_bstr( ) ] ) ,
215- author: signature ( ) ,
216- committer: signature ( ) ,
200+ author: "name <name@example.com> 1288373970 --700" . as_bytes ( ) . as_bstr ( ) ,
201+ committer: "name <name@example.com> 1288373970 --700" . as_bytes ( ) . as_bstr ( ) ,
217202 encoding: None ,
218203 message: "msg\n " . into( ) ,
219204 extra_headers: vec![ ]
@@ -236,8 +221,8 @@ fn with_trailer() -> crate::Result {
236221 CommitRef {
237222 tree: b"25a19c29c5e36884c1ad85d8faf23f1246b7961b" . as_bstr( ) ,
238223 parents: SmallVec :: from( vec![ b"699ae71105dddfcbb9711ed3a92df09e91a04e90" . as_bstr( ) ] ) ,
239- author: kim,
240- committer: kim,
224+ author: "Kim Altintop < kim@eagain.st> 1631514803 +0200" . as_bytes ( ) . as_bstr ( ) ,
225+ committer: "Kim Altintop < kim@eagain.st> 1631514803 +0200" . as_bytes ( ) . as_bstr ( ) ,
241226 encoding: None ,
242227 message: b"test: use gitoxide for link-git-protocol tests
243228
@@ -253,6 +238,8 @@ Signed-off-by: Kim Altintop <kim@eagain.st>"
253238 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( ) ) ]
254239 }
255240 ) ;
241+ assert_eq ! ( commit. author( ) , kim) ;
242+ assert_eq ! ( commit. committer( ) , kim) ;
256243 let message = commit. message ( ) ;
257244 assert_eq ! ( message. title, "test: use gitoxide for link-git-protocol tests" ) ;
258245 assert_eq ! (
@@ -316,8 +303,8 @@ fn merge() -> crate::Result {
316303 b"6a6054db4ce3c1e4e6a37f8c4d7acb63a4d6ad71" . as_bstr( ) ,
317304 b"c91d592913d47ac4e4a76daf16fd649b276e211e" . as_bstr( )
318305 ] ) ,
319- author: signature ( " 1592454703 +0800") ,
320- committer: signature ( " 1592454738 +0800") ,
306+ author: b"Sebastian Thiel <sebastian.thiel@icloud.com> 1592454703 +0800". as_bstr ( ) ,
307+ committer: b"Sebastian Thiel <sebastian.thiel@icloud.com> 1592454738 +0800". as_bstr ( ) ,
321308 encoding: Some ( "ISO-8859-1" . into( ) ) ,
322309 message: b"Merge branch 'branch'" . as_bstr( ) ,
323310 extra_headers: vec![ ]
@@ -366,3 +353,11 @@ fn bogus_multi_gpgsig_header() -> crate::Result {
366353 ) ;
367354 Ok ( ( ) )
368355}
356+
357+ #[ test]
358+ fn author_method_returns_trimmed_signature ( ) -> crate :: Result {
359+ let commit = CommitRef :: from_bytes ( & fixture_name ( "commit" , "unsigned.txt" ) ) ?;
360+ assert_eq ! ( commit. author( ) , signature( "1592437401 +0800" ) ) ;
361+ assert_eq ! ( commit. committer( ) , signature( "1592437401 +0800" ) ) ;
362+ Ok ( ( ) )
363+ }
0 commit comments