Skip to content

Commit

Permalink
refactor(lib): unify serde and serde_derive using derive feature (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
tranzystorekk authored Jan 31, 2022
1 parent d961b53 commit bedabc9
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 24 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions git-cliff-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ edition = "2021"

[dependencies]
thiserror = "1.0.30"
serde = "1.0.130"
serde_derive = "1.0.130"
serde = { version = "1.0.130", features = ["derive"] }
tera = "1.13.0"
regex = "1.5.4"
serde_regex = "1.1.0"
Expand Down
6 changes: 2 additions & 4 deletions git-cliff-core/src/commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use serde::ser::{
};

/// Common commit object that is parsed from a repository.
#[derive(Debug, Clone, PartialEq, serde_derive::Deserialize)]
#[derive(Debug, Clone, PartialEq, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Commit<'a> {
/// Commit ID.
Expand All @@ -35,9 +35,7 @@ pub struct Commit<'a> {
}

/// Object representing a link
#[derive(
Debug, Clone, PartialEq, serde_derive::Deserialize, serde_derive::Serialize,
)]
#[derive(Debug, Clone, PartialEq, serde::Deserialize, serde::Serialize)]
#[serde(rename_all = "camelCase")]
pub struct Link {
/// Text of the link.
Expand Down
14 changes: 5 additions & 9 deletions git-cliff-core/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::error::Result;
use regex::Regex;

/// Configuration values.
#[derive(Debug, Clone, serde_derive::Serialize, serde_derive::Deserialize)]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct Config {
/// Configuration values about changelog generation.
#[serde(default)]
Expand All @@ -13,9 +13,7 @@ pub struct Config {
}

/// Changelog configuration.
#[derive(
Debug, Default, Clone, serde_derive::Serialize, serde_derive::Deserialize,
)]
#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
pub struct ChangelogConfig {
/// Changelog header.
pub header: Option<String>,
Expand All @@ -28,9 +26,7 @@ pub struct ChangelogConfig {
}

/// Git configuration
#[derive(
Debug, Default, Clone, serde_derive::Serialize, serde_derive::Deserialize,
)]
#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
pub struct GitConfig {
/// Whether to enable parsing conventional commits.
pub conventional_commits: Option<bool>,
Expand All @@ -57,7 +53,7 @@ pub struct GitConfig {
}

/// Parser for grouping commits.
#[derive(Debug, Clone, serde_derive::Serialize, serde_derive::Deserialize)]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct CommitParser {
/// Regex for matching the commit message.
#[serde(with = "serde_regex", default)]
Expand All @@ -74,7 +70,7 @@ pub struct CommitParser {
}

/// Parser for extracting links in commits.
#[derive(Debug, Clone, serde_derive::Serialize, serde_derive::Deserialize)]
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct LinkParser {
/// Regex for finding links in the commit message.
#[serde(with = "serde_regex")]
Expand Down
9 changes: 1 addition & 8 deletions git-cliff-core/src/release.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
use crate::commit::Commit;

/// Representation of a release.
#[derive(
Default,
Debug,
Clone,
PartialEq,
serde_derive::Serialize,
serde_derive::Deserialize,
)]
#[derive(Default, Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Release<'a> {
/// Release version, git tag.
Expand Down

0 comments on commit bedabc9

Please sign in to comment.