…which also saves parsing time.
Showing the changes to git-object/tests/immutable/commit (2 of 4 files). Show all
Unified · Split
| @@ -1,5 +1,5 @@ | |||
| 1 | use git_actor::{Sign, SignatureRef, Time}; | 1 | use git_actor::{Sign, SignatureRef, Time}; |
| 2 | use git_object::{bstr::ByteSlice, CommitRef}; | 2 | use git_object::{bstr::ByteSlice, commit::message::body::TrailerRef, CommitRef}; |
| 3 | use smallvec::SmallVec; | 3 | use smallvec::SmallVec; |
| 4 | 4 | ||
| 5 | use crate::immutable::{ | 5 | use crate::immutable::{ |
| @@ -185,7 +185,7 @@ Signed-off-by: Kim Altintop <kim@eagain.st>" · 179 unmodified lines | |||
| 185 | ) | 185 | ) |
| 186 | ); | 186 | ); |
| 187 | assert_eq!( | 187 | assert_eq!( |
| 188 | commit.summary(), | 188 | commit.message_summary(), |
| 189 | message.summary(), | 189 | message.summary(), |
| 190 | "both summaries are the same, but the commit one does less parsing" | 190 | "both summaries are the same, but the commit one does less parsing" |
| 191 | ); | 191 | ); |
| @@ -200,6 +200,24 @@ instead of depending directly on the lower-level crates. · 8 unmodified lines | |||
| 200 | .as_bstr(), | 200 | .as_bstr(), |
| 201 | "body doesn't contain footer" | 201 | "body doesn't contain footer" |
| 202 | ); | 202 | ); |
| 203 | assert_eq!( | ||
| 204 | body.trailers().collect::<Vec<_>>(), | ||
| 205 | vec![ | ||
| 206 | TrailerRef { | ||
| 207 | token: "Signed-off-by".into(), | ||
| 208 | value: "Sebastian Thiel <sebastian.thiel@icloud.com>".into() | ||
| 209 | }, | ||
| 210 | TrailerRef { | ||
| 211 | token: "Signed-off-by".into(), | ||
| 212 | value: "Kim Altintop <kim@eagain.st>".into() | ||
| 213 | } | ||
| 214 | ] | ||
| 215 | ); | ||
| 216 | assert_eq!( | ||
| 217 | body.trailers().collect::<Vec<_>>(), | ||
| 218 | commit.message_trailers().collect::<Vec<_>>(), | ||
| 219 | "messages trailers are accessible on commit level and yield the same result" | ||
| 220 | ); | ||
| 203 | Ok(()) | 221 | Ok(()) |
| 204 | } | 222 | } |
| 205 | 223 | ||
| @@ -250,7 +250,7 @@ mod summary { · 249 unmodified lines | |||
| 250 | message: input.as_bstr(), | 250 | message: input.as_bstr(), |
| 251 | extra_headers: vec![] | 251 | extra_headers: vec![] |
| 252 | } | 252 | } |
| 253 | .summary(), | 253 | .message_summary(), |
| 254 | summary, | 254 | summary, |
| 255 | "both versions create the same result" | 255 | "both versions create the same result" |
| 256 | ); | 256 | ); |