|
1 | 1 | use gix_actor::SignatureRef;
|
2 |
| -use gix_object::{bstr::ByteSlice, commit::message::body::TrailerRef, CommitRef}; |
| 2 | +use gix_object::{bstr::ByteSlice, commit::message::body::TrailerRef, CommitRef, WriteTo}; |
3 | 3 | use smallvec::SmallVec;
|
4 | 4 |
|
5 | 5 | use crate::{
|
6 | 6 | commit::{LONG_MESSAGE, MERGE_TAG, SIGNATURE},
|
7 |
| - fixture_name, linus_signature, signature, |
| 7 | + fixture_name, hex_to_id, linus_signature, signature, |
8 | 8 | };
|
9 | 9 |
|
10 | 10 | #[test]
|
@@ -347,15 +347,22 @@ fn newline_right_after_signature_multiline_header() -> crate::Result {
|
347 | 347 | fn bogus_multi_gpgsig_header() -> crate::Result {
|
348 | 348 | let fixture = fixture_name("commit", "bogus-gpgsig-lines-in-git.git.txt");
|
349 | 349 | let commit = CommitRef::from_bytes(&fixture)?;
|
350 |
| - let pgp_sig = crate::commit::BEGIN_PGP_SIGNATURE.as_bstr(); |
351 |
| - assert_eq!(commit.extra_headers[0].1.as_ref(), pgp_sig); |
| 350 | + let pgp_sig = b"-----BEGIN PGP SIGNATURE-----".as_bstr(); |
352 | 351 | assert_eq!(commit.extra_headers().pgp_signature(), Some(pgp_sig));
|
353 | 352 | assert_eq!(
|
354 |
| - commit.extra_headers().find(gix_object::commit::SIGNATURE_FIELD_NAME), |
355 |
| - Some(pgp_sig) |
| 353 | + commit.extra_headers().find_all("gpgsig").count(), |
| 354 | + 17, |
| 355 | + "Each signature header line is prefixed with `gpgsig` here, so we parse it as extra header" |
356 | 356 | );
|
357 |
| - assert_eq!(commit.extra_headers().find_pos("gpgsig"), Some(0)); |
358 |
| - assert_eq!(commit.extra_headers().find_pos("something else"), None); |
359 | 357 | assert!(commit.message.starts_with(b"pretty: %G[?GS] placeholders"));
|
| 358 | + |
| 359 | + let mut buf = Vec::<u8>::new(); |
| 360 | + commit.write_to(&mut buf)?; |
| 361 | + let actual = gix_object::compute_hash(gix_hash::Kind::Sha1, gix_object::Kind::Commit, &buf)?; |
| 362 | + assert_eq!( |
| 363 | + actual, |
| 364 | + hex_to_id("5f549aa2f78314ac37bbd436c8f80aea4c752e07"), |
| 365 | + "round-tripping works despite the strangeness" |
| 366 | + ); |
360 | 367 | Ok(())
|
361 | 368 | }
|
0 commit comments