pub struct CommitData<Tree, Parent> { /* private fields */ }Expand description
A git commit in its object description form, i.e. the output of
git cat-file for a commit object.
Implementations§
Source§impl<Tree, Parent> CommitData<Tree, Parent>
impl<Tree, Parent> CommitData<Tree, Parent>
pub fn new<P, I, T>( tree: Tree, parents: P, author: Author, committer: Author, headers: Headers, message: String, trailers: I, ) -> Self
Sourcepub fn parents(&self) -> impl Iterator<Item = Parent> + '_where
Parent: Clone,
pub fn parents(&self) -> impl Iterator<Item = Parent> + '_where
Parent: Clone,
The parents of this commit.
The author of this commit, i.e. the header corresponding to author.
Sourcepub fn committer(&self) -> &Author
pub fn committer(&self) -> &Author
The committer of this commit, i.e. the header corresponding to
committer.
Sourcepub fn signatures(&self) -> impl Iterator<Item = Signature<'_>> + '_
pub fn signatures(&self) -> impl Iterator<Item = Signature<'_>> + '_
The Signatures found in this commit, i.e. the headers corresponding
to gpgsig.
pub fn strip_signatures(self) -> Self
Sourcepub fn headers(&self) -> impl Iterator<Item = (&str, &str)>
pub fn headers(&self) -> impl Iterator<Item = (&str, &str)>
The Headers found in this commit.
Note: these do not include tree, parent, author, and committer.
Sourcepub fn values<'a>(&'a self, name: &'a str) -> impl Iterator<Item = &'a str> + 'a
pub fn values<'a>(&'a self, name: &'a str) -> impl Iterator<Item = &'a str> + 'a
Iterate over the Headers values that match the provided name.
Sourcepub fn push_header(&mut self, name: &str, value: &str)
pub fn push_header(&mut self, name: &str, value: &str)
Push a header to the end of the headers section.
pub fn trailers(&self) -> impl Iterator<Item = &OwnedTrailer>
Sourcepub fn map_tree<U, E, F>(self, f: F) -> Result<CommitData<U, Parent>, E>
pub fn map_tree<U, E, F>(self, f: F) -> Result<CommitData<U, Parent>, E>
Convert the CommitData::tree into a value of type U. The
conversion function f can be fallible.
For example, map_tree can be used to turn raw tree data into
an Oid by writing it to a repository.
Sourcepub fn map_parents<U, E, F>(self, f: F) -> Result<CommitData<Tree, U>, E>
pub fn map_parents<U, E, F>(self, f: F) -> Result<CommitData<Tree, U>, E>
Convert the CommitData::parents into a vector containing
values of type U. The conversion function f can be
fallible.
For example, this can be used to resolve the object identifiers to their respective full commits.
Source§impl<Tree, Parent> CommitData<Tree, Parent>
impl<Tree, Parent> CommitData<Tree, Parent>
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self, ParseError>
pub fn from_bytes(bytes: &[u8]) -> Result<Self, ParseError>
Parse a CommitData from its raw git object bytes.
This is the inverse of the fmt::Display implementation. The bytes
are expected to be valid UTF-8 and in the standard git commit object
format produced by git cat-file -p <commit>.
Trailers are detected by scanning the last paragraph of the message
body (the section after the final blank line). If every non-empty line
in that paragraph is a valid Token: value pair, those lines are
parsed as trailers and stored separately; otherwise the whole body is
kept as the message with no trailers.
Trait Implementations§
Source§impl<Tree: Clone, Parent: Clone> Clone for CommitData<Tree, Parent>
impl<Tree: Clone, Parent: Clone> Clone for CommitData<Tree, Parent>
Source§fn clone(&self) -> CommitData<Tree, Parent>
fn clone(&self) -> CommitData<Tree, Parent>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more