Skip to main content

CommitData

Struct CommitData 

Source
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>

Source

pub fn new<P, I, T>( tree: Tree, parents: P, author: Author, committer: Author, headers: Headers, message: String, trailers: I, ) -> Self
where P: IntoIterator<Item = Parent>, I: IntoIterator<Item = T>, OwnedTrailer: From<T>,

Source

pub fn tree(&self) -> &Tree

The tree this commit points to.

Source

pub fn parents(&self) -> impl Iterator<Item = Parent> + '_
where Parent: Clone,

The parents of this commit.

Source

pub fn author(&self) -> &Author

The author of this commit, i.e. the header corresponding to author.

Source

pub fn committer(&self) -> &Author

The committer of this commit, i.e. the header corresponding to committer.

Source

pub fn message(&self) -> &str

The message body of this commit.

Source

pub fn signatures(&self) -> impl Iterator<Item = Signature<'_>> + '_

The Signatures found in this commit, i.e. the headers corresponding to gpgsig.

Source

pub fn strip_signatures(self) -> Self

Source

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.

Source

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.

Source

pub fn push_header(&mut self, name: &str, value: &str)

Push a header to the end of the headers section.

Source

pub fn trailers(&self) -> impl Iterator<Item = &OwnedTrailer>

Source

pub fn map_tree<U, E, F>(self, f: F) -> Result<CommitData<U, Parent>, E>
where F: FnOnce(Tree) -> Result<U, 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.

Source

pub fn map_parents<U, E, F>(self, f: F) -> Result<CommitData<Tree, U>, E>
where F: FnMut(Parent) -> Result<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>
where Tree: FromStr, Parent: FromStr, Tree::Err: Error + Send + Sync + 'static, Parent::Err: Error + Send + Sync + 'static,

Source

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>

Source§

fn clone(&self) -> CommitData<Tree, Parent>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<Tree: Debug, Parent: Debug> Debug for CommitData<Tree, Parent>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<Tree: Display, Parent: Display> Display for CommitData<Tree, Parent>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<Tree, Parent> FromStr for CommitData<Tree, Parent>
where Tree: FromStr, Parent: FromStr, Tree::Err: Error + Send + Sync + 'static, Parent::Err: Error + Send + Sync + 'static,

Source§

type Err = ParseError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl<Tree: Hash, Parent: Hash> Hash for CommitData<Tree, Parent>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<Tree: PartialEq, Parent: PartialEq> PartialEq for CommitData<Tree, Parent>

Source§

fn eq(&self, other: &CommitData<Tree, Parent>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<Tree: Eq, Parent: Eq> Eq for CommitData<Tree, Parent>

Source§

impl<Tree, Parent> StructuralPartialEq for CommitData<Tree, Parent>

Auto Trait Implementations§

§

impl<Tree, Parent> Freeze for CommitData<Tree, Parent>
where Tree: Freeze,

§

impl<Tree, Parent> RefUnwindSafe for CommitData<Tree, Parent>
where Tree: RefUnwindSafe, Parent: RefUnwindSafe,

§

impl<Tree, Parent> Send for CommitData<Tree, Parent>
where Tree: Send, Parent: Send,

§

impl<Tree, Parent> Sync for CommitData<Tree, Parent>
where Tree: Sync, Parent: Sync,

§

impl<Tree, Parent> Unpin for CommitData<Tree, Parent>
where Tree: Unpin, Parent: Unpin,

§

impl<Tree, Parent> UnsafeUnpin for CommitData<Tree, Parent>
where Tree: UnsafeUnpin,

§

impl<Tree, Parent> UnwindSafe for CommitData<Tree, Parent>
where Tree: UnwindSafe, Parent: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.