From 2ab2c8fb5e0c56b5ec51689ea33ebd4ec98a5310 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orhun=20Parmaks=C4=B1z?= Date: Sun, 2 Apr 2023 21:46:45 +0300 Subject: [PATCH] refactor(lib)!: move changelog module to git-cliff-core This will reduce the number of pulled dependencies if you want to use git-cliff as a library in your Rust project. --- Cargo.lock | 1 + Cargo.toml | 6 ++---- git-cliff-core/Cargo.toml | 1 + {git-cliff => git-cliff-core}/src/changelog.rs | 12 ++++++------ git-cliff-core/src/lib.rs | 5 +++++ git-cliff/Cargo.toml | 2 +- git-cliff/src/lib.rs | 4 +--- 7 files changed, 17 insertions(+), 14 deletions(-) rename {git-cliff => git-cliff-core}/src/changelog.rs (98%) diff --git a/Cargo.lock b/Cargo.lock index 190b8af..f89dcdd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -486,6 +486,7 @@ dependencies = [ "glob", "indexmap", "lazy-regex", + "log", "pretty_assertions", "regex", "rust-embed", diff --git a/Cargo.toml b/Cargo.toml index 4836edf..5a02f2e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,12 +1,10 @@ [workspace] -members = [ - "git-cliff-core", - "git-cliff", -] +members = ["git-cliff-core", "git-cliff"] [workspace.dependencies] regex = "1.6.0" glob = "0.3.0" +log = "0.4.17" [profile.dev] opt-level = 0 diff --git a/git-cliff-core/Cargo.toml b/git-cliff-core/Cargo.toml index 5993015..291e350 100644 --- a/git-cliff-core/Cargo.toml +++ b/git-cliff-core/Cargo.toml @@ -13,6 +13,7 @@ rust-version = "1.60.0" [dependencies] glob.workspace = true regex.workspace = true +log.workspace = true thiserror = "1.0.38" serde = { version = "1.0.152", features = ["derive"] } serde_json = "1.0.91" diff --git a/git-cliff/src/changelog.rs b/git-cliff-core/src/changelog.rs similarity index 98% rename from git-cliff/src/changelog.rs rename to git-cliff-core/src/changelog.rs index 258a4be..8e96401 100644 --- a/git-cliff/src/changelog.rs +++ b/git-cliff-core/src/changelog.rs @@ -1,11 +1,11 @@ -use git_cliff_core::commit::Commit; -use git_cliff_core::config::Config; -use git_cliff_core::error::Result; -use git_cliff_core::release::{ +use crate::commit::Commit; +use crate::config::Config; +use crate::error::Result; +use crate::release::{ Release, Releases, }; -use git_cliff_core::template::Template; +use crate::template::Template; use std::io::Write; /// Changelog generator. @@ -176,7 +176,7 @@ impl<'a> Changelog<'a> { #[cfg(test)] mod test { use super::*; - use git_cliff_core::config::{ + use crate::config::{ ChangelogConfig, CommitParser, CommitPreprocessor, diff --git a/git-cliff-core/src/lib.rs b/git-cliff-core/src/lib.rs index 7672bdd..f4f8dc2 100644 --- a/git-cliff-core/src/lib.rs +++ b/git-cliff-core/src/lib.rs @@ -1,6 +1,8 @@ //! A highly customizable changelog generator #![warn(missing_docs, clippy::unwrap_used)] +/// Changelog generator. +pub mod changelog; /// Command runner. pub mod command; /// Git commit. @@ -18,5 +20,8 @@ pub mod repo; /// Template engine. pub mod template; +#[macro_use] +extern crate log; + /// Default configuration file. pub const DEFAULT_CONFIG: &str = "cliff.toml"; diff --git a/git-cliff/Cargo.toml b/git-cliff/Cargo.toml index 7de94fb..d751004 100644 --- a/git-cliff/Cargo.toml +++ b/git-cliff/Cargo.toml @@ -28,8 +28,8 @@ default = ["update-informer"] [dependencies] glob.workspace = true regex.workspace = true +log.workspace = true pretty_env_logger = "0.4.0" -log = "0.4.17" dirs-next = "2.0.0" clap_complete = "4.1.1" clap_mangen = "0.2.7" diff --git a/git-cliff/src/lib.rs b/git-cliff/src/lib.rs index 76264b2..5f40c5a 100644 --- a/git-cliff/src/lib.rs +++ b/git-cliff/src/lib.rs @@ -1,7 +1,5 @@ /// Command-line argument parser. pub mod args; -/// Changelog generator. -pub mod changelog; #[macro_use] extern crate log; @@ -11,8 +9,8 @@ use args::{ Sort, Strip, }; -use changelog::Changelog; use clap::ValueEnum; +use git_cliff_core::changelog::Changelog; use git_cliff_core::commit::Commit; use git_cliff_core::config::Config; use git_cliff_core::embed::EmbeddedConfig;