From bf146cfa80d67e8e8cc43043ed7543bc7f501899 Mon Sep 17 00:00:00 2001 From: pataar Date: Tue, 19 Oct 2021 18:35:55 +0200 Subject: [PATCH 1/3] fix: add support for special characters in scopes Fixes #25 --- Cargo.lock | 4 +-- git-cliff-core/Cargo.toml | 2 +- git-cliff-core/tests/integration_test.rs | 31 ++++++++++++++++++------ 3 files changed, 26 insertions(+), 11 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..3152a852c0 100644 --- a/git-cliff-core/tests/integration_test.rs +++ b/git-cliff-core/tests/integration_test.rs @@ -20,9 +20,24 @@ fn generate_changelog() -> Result<()> { ## Release {{ version }} {% for group, commits in commits | group_by(attribute="group") %} ### {{ group }} - {% for commit in commits %} - - {{ commit.message }}{% endfor %} - {% endfor %}"#, + {% for commit in commits + | filter(attribute="scope") + | sort(attribute="scope") %} + - *({{commit.scope}})* {{ commit.message }} + {%- if commit.breaking %} + {% raw %} {% endraw %}- **BREAKING**: {{commit.breaking_description}} + {%- endif -%} + {%- endfor -%} + {%- for commit in commits %} + {%- if commit.scope -%} + {% else -%} + - {{ commit.message }} + {% if commit.breaking -%} + {% raw %} {% endraw %}- **BREAKING**: {{commit.breaking_description}} + {% endif -%} + {% endif -%} + {% endfor -%} +{% endfor %}"#, ), footer: Some(String::from("eoc - end of changelog")), trim: None, @@ -56,7 +71,9 @@ 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"), @@ -122,26 +139,24 @@ fn generate_changelog() -> Result<()> { ## Release v2.0.0 ### fix bugs - - fix abc ### shiny features - - add xyz + - *(big-feature)* this is a breaking change + - **BREAKING**: this is a breaking change + - *(random-scope)* add random feature- add xyz - add zyx ## Release v1.0.0 ### chore - - do nothing ### feat - - add cool features ### fix - - fix stuff - fix more stuff eoc - end of changelog\n", From 41e91a349ee51da6b312a9f2cd6910836c0f7eb0 Mon Sep 17 00:00:00 2001 From: pataar Date: Tue, 19 Oct 2021 19:07:06 +0200 Subject: [PATCH 2/3] test: fix newlines of non-scoped commits --- git-cliff-core/tests/integration_test.rs | 45 ++++++++++-------------- 1 file changed, 19 insertions(+), 26 deletions(-) diff --git a/git-cliff-core/tests/integration_test.rs b/git-cliff-core/tests/integration_test.rs index 3152a852c0..00c93ed651 100644 --- a/git-cliff-core/tests/integration_test.rs +++ b/git-cliff-core/tests/integration_test.rs @@ -19,23 +19,16 @@ fn generate_changelog() -> Result<()> { r#" ## Release {{ version }} {% for group, commits in commits | group_by(attribute="group") %} - ### {{ group }} - {% for commit in commits - | filter(attribute="scope") - | sort(attribute="scope") %} - - *({{commit.scope}})* {{ commit.message }} - {%- if commit.breaking %} - {% raw %} {% endraw %}- **BREAKING**: {{commit.breaking_description}} - {%- endif -%} - {%- endfor -%} - {%- for commit in commits %} + ### {{ group }} + {% for commit in commits %} {%- if commit.scope -%} + - *({{commit.scope}})* {{ commit.message }} {% else -%} - - {{ commit.message }} + - {{ commit.message }} + {% endif -%} {% if commit.breaking -%} {% raw %} {% endraw %}- **BREAKING**: {{commit.breaking_description}} {% endif -%} - {% endif -%} {% endfor -%} {% endfor %}"#, ), @@ -138,27 +131,27 @@ fn generate_changelog() -> Result<()> { ## Release v2.0.0 - ### fix bugs - - fix abc - - ### shiny features + ### fix bugs + - fix abc - - *(big-feature)* this is a breaking change + ### shiny features + - add xyz + - add zyx + - *(random-scope)* add random feature + - *(big-feature)* this is a breaking change - **BREAKING**: this is a breaking change - - *(random-scope)* add random feature- add xyz - - add zyx ## Release v1.0.0 - ### chore - - do nothing + ### chore + - do nothing - ### feat - - add cool features + ### feat + - add cool features - ### fix - - fix stuff - - fix more stuff + ### fix + - fix stuff + - fix more stuff eoc - end of changelog\n", out ); From e1bccf1548967e8beb990c407b44e2c8d910732c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orhun=20Parmaks=C4=B1z?= Date: Tue, 19 Oct 2021 21:36:24 +0300 Subject: [PATCH 3/3] style(tests): update formatting --- git-cliff-core/tests/integration_test.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/git-cliff-core/tests/integration_test.rs b/git-cliff-core/tests/integration_test.rs index 00c93ed651..7c5253a68a 100644 --- a/git-cliff-core/tests/integration_test.rs +++ b/git-cliff-core/tests/integration_test.rs @@ -64,9 +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("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("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"),