Skip to content

Commit

Permalink
fix(changelog): add support for special characters in scopes (#26)
Browse files Browse the repository at this point in the history
* 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 <orhunparmaksiz@gmail.com>
  • Loading branch information
pataar and orhun committed Oct 19, 2021
1 parent 2925340 commit 10771f4
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 23 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion git-cliff-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
54 changes: 34 additions & 20 deletions git-cliff-core/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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"),
Expand Down Expand Up @@ -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
);
Expand Down

0 comments on commit 10771f4

Please sign in to comment.