pub struct Commit {
pub id: SHA1,
pub tree_id: SHA1,
pub parent_commit_ids: Vec<SHA1>,
pub author: Signature,
pub committer: Signature,
pub message: String,
}Expand description
The Commit struct is used to represent a commit object.
- The tree object SHA points to the top level tree for this commit, which reflects the complete state of the repository at the time of the commit. The tree object in turn points to blobs and subtrees which represent the files in the repository.
- The parent commit SHAs allow Git to construct a linked list of commits and build the full commit history. By chaining together commits in this fashion, Git is able to represent the entire history of a repository with a single commit object at its root.
- The author and committer fields contain the name, email address, timestamp and timezone.
- The message field contains the commit message, which maybe include signed or DCO.
Fields§
§id: SHA1§tree_id: SHA1§parent_commit_ids: Vec<SHA1>§committer: Signature§message: StringImplementations§
Source§impl Commit
impl Commit
pub fn new( author: Signature, committer: Signature, tree_id: SHA1, parent_commit_ids: Vec<SHA1>, message: &str, ) -> Commit
Sourcepub fn from_tree_id(
tree_id: SHA1,
parent_commit_ids: Vec<SHA1>,
message: &str,
) -> Commit
pub fn from_tree_id( tree_id: SHA1, parent_commit_ids: Vec<SHA1>, message: &str, ) -> Commit
Creates a new commit object from a tree ID and a list of parent commit IDs. This function generates the author and committer signatures using the current time and a fixed email address. It also sets the commit message to the provided string.
§Arguments
tree_id: The SHA1 hash of the tree object that this commit points to.parent_commit_ids: A vector of SHA1 hashes of the parent commits.message: A string containing the commit message.
§Returns
A new Commit object with the specified tree ID, parent commit IDs, and commit message.
The author and committer signatures are generated using the current time and a fixed email address.
Sourcepub fn format_message(&self) -> String
pub fn format_message(&self) -> String
Formats the commit message by extracting the first meaningful line.
If the message contains a PGP signature, it returns the first non-empty line after the signature block. Otherwise, it returns the first non-empty line in the message. If no such line exists, it returns the original message.
Trait Implementations§
Source§impl<'__de, __Context> BorrowDecode<'__de, __Context> for Commit
impl<'__de, __Context> BorrowDecode<'__de, __Context> for Commit
Source§fn borrow_decode<__D: BorrowDecoder<'__de, Context = __Context>>(
decoder: &mut __D,
) -> Result<Self, DecodeError>
fn borrow_decode<__D: BorrowDecoder<'__de, Context = __Context>>( decoder: &mut __D, ) -> Result<Self, DecodeError>
Source§impl<'de> Deserialize<'de> for Commit
impl<'de> Deserialize<'de> for Commit
Source§fn 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>,
Source§impl ObjectTrait for Commit
impl ObjectTrait for Commit
impl Eq for Commit
Auto Trait Implementations§
impl Freeze for Commit
impl RefUnwindSafe for Commit
impl Send for Commit
impl Sync for Commit
impl Unpin for Commit
impl UnwindSafe for Commit
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> FileLoadStore for Twhere
T: Serialize + for<'a> Deserialize<'a>,
impl<T> FileLoadStore for Twhere
T: Serialize + for<'a> Deserialize<'a>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more