Skip to main content

Commit

Struct Commit 

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

Full commit hash

§short_hash: String

Short commit hash (7 characters)

§message: String

Commit message

§author: String

Commit author

§author_email: String

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: bool

Whether this is a breaking change

§body: Option<String>

Commit body

Implementations§

Source§

impl Commit

Source

pub fn new( hash: String, message: String, author: String, author_email: String, date: DateTime<Utc>, ) -> Self

Create a new commit

Source

pub const fn commit_type(&self) -> Option<CommitType>

Get the commit type

Source

pub const fn is_conventional(&self) -> bool

Check if this is a conventional commit

Source

pub fn affects_scope(&self, scope: &str) -> bool

Check if this commit affects a specific scope

Source

pub fn is_type(&self, commit_type: CommitType) -> bool

Check if this commit is of a specific type

Source

pub fn short_message(&self) -> &str

Get a shortened message (first line)

Source

pub fn changelog_message(&self) -> &str

Get the normalized changelog description without the conventional prefix.

Trait Implementations§

Source§

impl Clone for Commit

Source§

fn clone(&self) -> Commit

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 Debug for Commit

Source§

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

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

impl<'de> Deserialize<'de> for Commit

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Commit

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

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, 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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,