|
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]
|
@@ -342,3 +342,27 @@ fn newline_right_after_signature_multiline_header() -> crate::Result {
|
342 | 342 | assert!(commit.message.starts_with(b"Rollup"));
|
343 | 343 | Ok(())
|
344 | 344 | }
|
| 345 | + |
| 346 | +#[test] |
| 347 | +fn bogus_multi_gpgsig_header() -> crate::Result { |
| 348 | + let fixture = fixture_name("commit", "bogus-gpgsig-lines-in-git.git.txt"); |
| 349 | + let commit = CommitRef::from_bytes(&fixture)?; |
| 350 | + let pgp_sig = b"-----BEGIN PGP SIGNATURE-----".as_bstr(); |
| 351 | + assert_eq!(commit.extra_headers().pgp_signature(), Some(pgp_sig)); |
| 352 | + assert_eq!( |
| 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 | + ); |
| 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 | + ); |
| 367 | + Ok(()) |
| 368 | +} |
0 commit comments