pub struct Commit {
pub id: ObjectHash,
pub tree_id: ObjectHash,
pub parent_commit_ids: Vec<ObjectHash>,
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-1/SHA-256 hashpoints 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: ObjectHash§tree_id: ObjectHash§parent_commit_ids: Vec<ObjectHash>§committer: Signature§message: StringImplementations§
Source§impl Commit
impl Commit
pub fn new( author: Signature, committer: Signature, tree_id: ObjectHash, parent_commit_ids: Vec<ObjectHash>, message: &str, ) -> Commit
Sourcepub fn from_tree_id(
tree_id: ObjectHash,
parent_commit_ids: Vec<ObjectHash>,
message: &str,
) -> Commit
pub fn from_tree_id( tree_id: ObjectHash, parent_commit_ids: Vec<ObjectHash>, 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/ SHA-256 hash of the tree object that this commit points to.parent_commit_ids: A vector of SHA1/ SHA-256 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 Archive for Commit
impl Archive for Commit
Source§const COPY_OPTIMIZATION: CopyOptimization<Self>
const COPY_OPTIMIZATION: CopyOptimization<Self>
serialize. Read moreSource§type Archived = ArchivedCommit
type Archived = ArchivedCommit
Source§type Resolver = CommitResolver
type Resolver = CommitResolver
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<__D: Fallible + ?Sized> Deserialize<Commit, __D> for Archived<Commit>where
ObjectHash: Archive,
<ObjectHash as Archive>::Archived: Deserialize<ObjectHash, __D>,
Vec<ObjectHash>: Archive,
<Vec<ObjectHash> as Archive>::Archived: Deserialize<Vec<ObjectHash>, __D>,
Signature: Archive,
<Signature as Archive>::Archived: Deserialize<Signature, __D>,
String: Archive,
<String as Archive>::Archived: Deserialize<String, __D>,
impl<__D: Fallible + ?Sized> Deserialize<Commit, __D> for Archived<Commit>where
ObjectHash: Archive,
<ObjectHash as Archive>::Archived: Deserialize<ObjectHash, __D>,
Vec<ObjectHash>: Archive,
<Vec<ObjectHash> as Archive>::Archived: Deserialize<Vec<ObjectHash>, __D>,
Signature: Archive,
<Signature as Archive>::Archived: Deserialize<Signature, __D>,
String: Archive,
<String as Archive>::Archived: Deserialize<String, __D>,
Source§impl ObjectTrait for Commit
impl ObjectTrait for Commit
Source§fn from_bytes(data: &[u8], hash: ObjectHash) -> Result<Self, GitError>where
Self: Sized,
fn from_bytes(data: &[u8], hash: ObjectHash) -> Result<Self, GitError>where
Self: Sized,
Source§fn get_type(&self) -> ObjectType
fn get_type(&self) -> ObjectType
fn get_size(&self) -> usize
Source§fn from_buf_read<R: BufRead>(read: &mut ReadBoxed<R>, size: usize) -> Selfwhere
Self: Sized,
fn from_buf_read<R: BufRead>(read: &mut ReadBoxed<R>, size: usize) -> Selfwhere
Self: Sized,
ReadBoxed<BufRead>.
the input size,is only for new a vec with directive space allocation
the input data stream and output object should be plain base object .fn object_hash(&self) -> Result<ObjectHash, GitError>
Source§impl<__S: Fallible + ?Sized> Serialize<__S> for Commitwhere
ObjectHash: Serialize<__S>,
Vec<ObjectHash>: Serialize<__S>,
Signature: Serialize<__S>,
String: Serialize<__S>,
impl<__S: Fallible + ?Sized> Serialize<__S> for Commitwhere
ObjectHash: Serialize<__S>,
Vec<ObjectHash>: Serialize<__S>,
Signature: Serialize<__S>,
String: Serialize<__S>,
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 UnsafeUnpin for Commit
impl UnwindSafe for Commit
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> ArchiveUnsized for Twhere
T: Archive,
impl<T> ArchiveUnsized for Twhere
T: Archive,
Source§type Archived = <T as Archive>::Archived
type Archived = <T as Archive>::Archived
Archive, it may be
unsized. Read moreSource§fn archived_metadata(
&self,
) -> <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata
fn archived_metadata( &self, ) -> <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata
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<T> FileLoadStore for Twhere
T: Archive + for<'a> Serialize<Strategy<Serializer<AlignedVec, ArenaHandle<'a>, Share>, Error>>,
<T as Archive>::Archived: for<'a> CheckBytes<Strategy<Validator<ArchiveValidator<'a>, SharedValidator>, Error>> + Deserialize<T, Strategy<Pool, Error>>,
impl<T> FileLoadStore for Twhere
T: Archive + for<'a> Serialize<Strategy<Serializer<AlignedVec, ArenaHandle<'a>, Share>, Error>>,
<T as Archive>::Archived: for<'a> CheckBytes<Strategy<Validator<ArchiveValidator<'a>, SharedValidator>, Error>> + Deserialize<T, Strategy<Pool, Error>>,
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 moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.