mirror of
https://github.com/orhun/git-cliff.git
synced 2024-11-29 15:42:15 +03:00
refactor(dep): use git-conventional crate from crates.io
Signed-off-by: orhun <orhunparmaksiz@gmail.com>
This commit is contained in:
parent
edb64553bb
commit
73bd992802
7
Cargo.lock
generated
7
Cargo.lock
generated
@ -1,7 +1,5 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
version = "0.7.18"
|
||||
@ -288,8 +286,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "git-conventional"
|
||||
version = "0.9.1"
|
||||
source = "git+https://github.com/orhun/git-conventional?branch=master#cb19e480b1a933ef16cd80091d02f6d3a7986ee3"
|
||||
version = "0.9.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f9b9c51fa5f3d70c39e34d3fa551c3e7d746f11d32dc9443958b74769af5dfe2"
|
||||
dependencies = [
|
||||
"doc-comment",
|
||||
"nom 6.1.2",
|
||||
|
@ -29,6 +29,5 @@ features = ["toml"]
|
||||
pretty_assertions = "0.7"
|
||||
|
||||
[dependencies.git-conventional]
|
||||
git = "https://github.com/orhun/git-conventional"
|
||||
branch = "master"
|
||||
version = "0.9.2"
|
||||
features = ["serde"]
|
||||
|
@ -22,7 +22,7 @@ pub struct Commit<'a> {
|
||||
pub message: String,
|
||||
/// Conventional commit.
|
||||
#[serde(skip_deserializing)]
|
||||
pub conv: ConventionalCommit<'a>,
|
||||
pub conv: Option<ConventionalCommit<'a>>,
|
||||
/// Commit group based on a group parser or its conventional type.
|
||||
pub group: Option<String>,
|
||||
}
|
||||
@ -42,7 +42,7 @@ impl Commit<'_> {
|
||||
Self {
|
||||
id,
|
||||
message,
|
||||
conv: ConventionalCommit::default(),
|
||||
conv: None,
|
||||
group: None,
|
||||
}
|
||||
}
|
||||
@ -64,7 +64,7 @@ impl Commit<'_> {
|
||||
self.message.to_string().into_boxed_str(),
|
||||
)) {
|
||||
Ok(conv) => {
|
||||
self.conv = conv;
|
||||
self.conv = Some(conv);
|
||||
Ok(self)
|
||||
}
|
||||
Err(e) => Err(AppError::ParseError(e)),
|
||||
@ -100,13 +100,19 @@ impl Serialize for Commit<'_> {
|
||||
{
|
||||
let mut commit = serializer.serialize_struct("Commit", 3)?;
|
||||
commit.serialize_field("id", &self.id)?;
|
||||
commit.serialize_field("message", &self.conv.description())?;
|
||||
commit.serialize_field(
|
||||
"group",
|
||||
self.group
|
||||
.as_ref()
|
||||
.unwrap_or(&self.conv.type_().to_string()),
|
||||
)?;
|
||||
match &self.conv {
|
||||
Some(conv) => {
|
||||
commit.serialize_field("message", conv.description())?;
|
||||
commit.serialize_field(
|
||||
"group",
|
||||
self.group.as_ref().unwrap_or(&conv.type_().to_string()),
|
||||
)?;
|
||||
}
|
||||
None => {
|
||||
commit.serialize_field("message", &self.message)?;
|
||||
commit.serialize_field("group", &self.group)?;
|
||||
}
|
||||
}
|
||||
commit.end()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user