pub struct Commit {
pub hash: String,
pub short_hash: String,
pub message: String,
pub author: String,
pub author_email: String,
pub date: DateTime<Utc>,
pub files_changed: Vec<String>,
pub commit_type: Option<CommitType>,
pub scope: Option<String>,
pub breaking: bool,
pub body: Option<String>,
}Expand description
A git commit
Represents a git commit with parsed conventional commit metadata.
§Examples
use governor_core::domain::commit::Commit;
use chrono::Utc;
let commit = Commit::new(
"abc123def".to_string(),
"feat: add new feature".to_string(),
"Alice".to_string(),
"alice@example.com".to_string(),
Utc::now(),
);Fields§
§hash: StringFull commit hash
short_hash: StringShort commit hash (7 characters)
message: StringCommit message
Commit author
Commit author email
date: DateTime<Utc>Commit date
files_changed: Vec<String>Files changed in this commit
commit_type: Option<CommitType>Conventional commit type (if parsed)
scope: Option<String>Conventional commit scope (if present)
breaking: boolWhether this is a breaking change
body: Option<String>Commit body
Implementations§
Source§impl Commit
impl Commit
Sourcepub fn new(
hash: String,
message: String,
author: String,
author_email: String,
date: DateTime<Utc>,
) -> Self
pub fn new( hash: String, message: String, author: String, author_email: String, date: DateTime<Utc>, ) -> Self
Create a new commit
Sourcepub const fn commit_type(&self) -> Option<CommitType>
pub const fn commit_type(&self) -> Option<CommitType>
Get the commit type
Sourcepub const fn is_conventional(&self) -> bool
pub const fn is_conventional(&self) -> bool
Check if this is a conventional commit
Sourcepub fn affects_scope(&self, scope: &str) -> bool
pub fn affects_scope(&self, scope: &str) -> bool
Check if this commit affects a specific scope
Sourcepub fn is_type(&self, commit_type: CommitType) -> bool
pub fn is_type(&self, commit_type: CommitType) -> bool
Check if this commit is of a specific type
Sourcepub fn short_message(&self) -> &str
pub fn short_message(&self) -> &str
Get a shortened message (first line)
Sourcepub fn changelog_message(&self) -> &str
pub fn changelog_message(&self) -> &str
Get the normalized changelog description without the conventional prefix.
Trait Implementations§
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>,
Deserialize this value from the given Serde deserializer. Read more
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> 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
Mutably borrows from an owned value. Read more