Struct git_object::commit::MessageRef
source · Expand description
A parsed commit message that assumes a title separated from the body by two consecutive newlines.
Titles can have any amount of whitespace
Fields
title: &'a BStr
The title of the commit, as separated from the body with two consecutive newlines. The newlines are not included.
body: Option<&'a BStr>
All bytes not consumed by the title, excluding the separating newlines.
The body is None
if there was now title separation or the body was empty after the separator.
Implementations
sourceimpl<'a> MessageRef<'a>
impl<'a> MessageRef<'a>
sourcepub fn from_bytes(input: &'a [u8]) -> Self
pub fn from_bytes(input: &'a [u8]) -> Self
Parse the given input
as message.
Note that this cannot fail as everything will be interpreted as title if there is no body separator.
sourcepub fn summary(&self) -> Cow<'a, BStr>
pub fn summary(&self) -> Cow<'a, BStr>
Produce a short commit summary for the message title.
This means the following
- Take the subject line which is delimited by two newlines (\n\n)
- transform intermediate consecutive whitespace including \r into one space
The resulting summary will have folded whitespace before a newline into spaces and stopped that process once two consecutive newlines are encountered.
Trait Implementations
sourceimpl<'a> Clone for MessageRef<'a>
impl<'a> Clone for MessageRef<'a>
sourcefn clone(&self) -> MessageRef<'a>
fn clone(&self) -> MessageRef<'a>
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresourceimpl<'a> Debug for MessageRef<'a>
impl<'a> Debug for MessageRef<'a>
sourceimpl<'de: 'a, 'a> Deserialize<'de> for MessageRef<'a>
impl<'de: 'a, 'a> Deserialize<'de> for MessageRef<'a>
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
sourceimpl<'a> Hash for MessageRef<'a>
impl<'a> Hash for MessageRef<'a>
sourceimpl<'a> Ord for MessageRef<'a>
impl<'a> Ord for MessageRef<'a>
sourcefn cmp(&self, other: &MessageRef<'a>) -> Ordering
fn cmp(&self, other: &MessageRef<'a>) -> Ordering
1.21.0 · sourcefn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 · sourcefn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
sourceimpl<'a> PartialEq<MessageRef<'a>> for MessageRef<'a>
impl<'a> PartialEq<MessageRef<'a>> for MessageRef<'a>
sourcefn eq(&self, other: &MessageRef<'a>) -> bool
fn eq(&self, other: &MessageRef<'a>) -> bool
sourceimpl<'a> PartialOrd<MessageRef<'a>> for MessageRef<'a>
impl<'a> PartialOrd<MessageRef<'a>> for MessageRef<'a>
sourcefn partial_cmp(&self, other: &MessageRef<'a>) -> Option<Ordering>
fn partial_cmp(&self, other: &MessageRef<'a>) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more