From 10771f43c0f252dec9ad414b780bb22d866d00e2 Mon Sep 17 00:00:00 2001 From: pataar Date: Tue, 19 Oct 2021 20:45:36 +0200 Subject: [PATCH] fix(changelog): add support for special characters in scopes (#26) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: add support for special characters in scopes Fixes #25 * test: fix newlines of non-scoped commits * style(tests): update formatting Co-authored-by: Orhun Parmaksız --- Cargo.lock | 4 +- git-cliff-core/Cargo.toml | 2 +- git-cliff-core/tests/integration_test.rs | 54 +++++++++++++++--------- 3 files changed, 37 insertions(+), 23 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8322fceae4..60aa61b955 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -358,9 +358,9 @@ dependencies = [ [[package]] name = "git-conventional" -version = "0.10.2" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc574c897f85ed0a16517cb9318409cd4f8213475c25ffd413bedb2c4d917def" +checksum = "b6fba08a8b40d1967e1396a2b42680af39da750a6e28476f48b5ca4033f15f27" dependencies = [ "doc-comment", "nom 7.0.0", diff --git a/git-cliff-core/Cargo.toml b/git-cliff-core/Cargo.toml index 12e0a74d20..eb695179c8 100644 --- a/git-cliff-core/Cargo.toml +++ b/git-cliff-core/Cargo.toml @@ -29,7 +29,7 @@ default-features = false features = ["toml", "yaml"] [dependencies.git-conventional] -version = "0.10.2" +version = "0.11.0" features = ["serde"] [dependencies.rust-embed] diff --git a/git-cliff-core/tests/integration_test.rs b/git-cliff-core/tests/integration_test.rs index ac8a0221d9..7c5253a68a 100644 --- a/git-cliff-core/tests/integration_test.rs +++ b/git-cliff-core/tests/integration_test.rs @@ -19,10 +19,18 @@ fn generate_changelog() -> Result<()> { r#" ## Release {{ version }} {% for group, commits in commits | group_by(attribute="group") %} - ### {{ group }} + ### {{ group }} {% for commit in commits %} - - {{ commit.message }}{% endfor %} - {% endfor %}"#, + {%- if commit.scope -%} + - *({{commit.scope}})* {{ commit.message }} + {% else -%} + - {{ commit.message }} + {% endif -%} + {% if commit.breaking -%} + {% raw %} {% endraw %}- **BREAKING**: {{commit.breaking_description}} + {% endif -%} + {% endfor -%} +{% endfor %}"#, ), footer: Some(String::from("eoc - end of changelog")), trim: None, @@ -56,7 +64,15 @@ fn generate_changelog() -> Result<()> { commits: vec![ Commit::new(String::from("abc123"), String::from("feat: add xyz")), Commit::new(String::from("abc124"), String::from("feat: add zyx")), + Commit::new( + String::from("abc124"), + String::from("feat(random-scope): add random feature"), + ), Commit::new(String::from("def789"), String::from("invalid commit")), + Commit::new( + String::from("def789"), + String::from("feat(big-feature)!: this is a breaking change"), + ), Commit::new(String::from("qwerty"), String::from("fix: fix abc")), Commit::new( String::from("qwop"), @@ -121,29 +137,27 @@ fn generate_changelog() -> Result<()> { ## Release v2.0.0 - ### fix bugs - - - fix abc + ### fix bugs + - fix abc - ### shiny features - - - add xyz - - add zyx + ### shiny features + - add xyz + - add zyx + - *(random-scope)* add random feature + - *(big-feature)* this is a breaking change + - **BREAKING**: this is a breaking change ## Release v1.0.0 - ### chore - - - do nothing - - ### feat - - - add cool features + ### chore + - do nothing - ### fix + ### feat + - add cool features - - fix stuff - - fix more stuff + ### fix + - fix stuff + - fix more stuff eoc - end of changelog\n", out );