Skip to content

Commit

Permalink
feat(cargo-generate): separate templated and project cliff.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
gibbz00 committed Aug 18, 2024
1 parent a366309 commit 9d8a79b
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 5 deletions.
1 change: 0 additions & 1 deletion cargo-generate.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ ignore = [
"README.md",
"cargo_generate",
]
include = ["cliff.toml"]

[hooks]
pre = ["cargo_generate/script.rhai"]
6 changes: 2 additions & 4 deletions cliff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
trim = true

postprocessors = [
{ pattern = '\$REPO', replace = "https://github.com/{{ repository_path }}" },
{ pattern = '\$REPO', replace = "https://github.com/gibbz00/basic-things" },
]

header = """
Expand All @@ -12,7 +12,6 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html), \
and generated by levaraging [conventional commits](https://www.conventionalcommits.org/).
"""

{% raw %}
body = """
{% if version -%}
Expand Down Expand Up @@ -43,7 +42,6 @@ body = """
{% endfor -%}\
{% endfor %}
"""
{% endraw %}

footer = """
"""
Expand Down Expand Up @@ -72,5 +70,5 @@ commit_parsers = [
{ message = "^test", group = "Test", skip = true },
]
commit_preprocessors = [
{ pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](https://github.com/{{ repository_path }}/issues/${2}))" },
{ pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](https://github.com/gibbz00/basic-things/issues/${2}))" },
]
76 changes: 76 additions & 0 deletions cliff.toml.liquid
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
[changelog]
trim = true

postprocessors = [
{ pattern = '\$REPO', replace = "https://github.com/{{ repository_path }}" },
]

header = """
# Changelog\n
The format is inspired by the latest version of [Keep a Changelog](https://keepachangelog.com/en), \
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html), \
and generated by levaraging [conventional commits](https://www.conventionalcommits.org/).
"""

{% raw %}
body = """
{% if version -%}
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
{% else -%}
## [Unreleased]
{% endif -%}
{% macro print_commit(commit) -%}
- {% if commit.breaking %}[**breaking**] {% endif %}\
{{ commit.message | upper_first }} - \
([{{ commit.id | truncate(length=7, end="") }}]($REPO/commit/{{ commit.id }})) - {{ commit.author.name }}
{% endmacro -%}
{% for group, commits in commits | group_by(attribute="group") %}
### {{ group | upper_first }}
{% for commit in commits %}
{%- if not commit.scope -%}
{% raw %}{% endraw %}
{{ self::print_commit(commit=commit) }}
{%- endif -%}
{%- endfor -%}
{% for group, commits in commits | group_by(attribute="scope") %}
#### {{ group | upper_first }}
{% for commit in commits %}
{{ self::print_commit(commit=commit) }}
{%- endfor -%}
{% endfor -%}\
{% endfor %}
"""
{% endraw %}

footer = """
"""

[git]
conventional_commits = true
filter_commits = true
filter_unconventional = true
protect_breaking_commits = true
sort_commits = "oldest"
tag_pattern = "[0-9]+.[0-9]+.[0-9]+"

commit_parsers = [
{ message = "^doc", group = "Documented" },
{ message = "^feat", group = "Added" },
{ message = "^fix", group = "Fixed" },
{ message = "^perf", group = "Improved" },
{ message = "^revert", group = "Removed" },

# Will be shown if they include breaking changes:
{ message = "^build", group = "Continuous Deployment", skip = true },
{ message = "^chore", group = "Miscellaneous", skip = true },
{ message = "^ci", group = "Continuous Integration", skip = true },
{ message = "^refactor", group = "Refactoring", skip = true },
{ message = "^style", group = "Style", skip = true },
{ message = "^test", group = "Test", skip = true },
]
commit_preprocessors = [
{ pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](https://github.com/{{ repository_path }}/issues/${2}))" },
]

0 comments on commit 9d8a79b

Please sign in to comment.