Skip to content

Commit

Permalink
doc: generate more stylish changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
dnaka91 committed Sep 12, 2023
1 parent 2787b51 commit 5319fb3
Showing 1 changed file with 59 additions and 33 deletions.
92 changes: 59 additions & 33 deletions cliff.toml
Original file line number Diff line number Diff line change
@@ -1,30 +1,55 @@
# git-cliff ~ default configuration file
# https://git-cliff.org/docs/configuration
#
# Lines starting with "#" are comments.
# Configuration options are organized into tables and keys.
# See documentation for more information on available options.
# configuration file for git-cliff
# see https://github.com/orhun/git-cliff#configuration-file

[changelog]
# changelog header
header = """
# Changelog\n
All notable changes to this project will be documented in this file.\n
# Changelog
All notable changes to this project will be documented in this file.
<!-- markdownlint-disable no-duplicate-header -->
<!-- markdownlint-disable no-trailing-spaces -->
"""
# template for the changelog body
# https://tera.netlify.app/docs
# https://keats.github.io/tera/docs/#introduction
body = """
{% if version %}\
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
{% else %}\
## [unreleased]
{% endif %}\
{% if version -%}
{% if previous.version -%}
{% set url = "<REPO>/compare/" ~ previous.version ~ "..." ~ version %}
{% else -%}
{% set url = "<REPO>/releases/tag/" ~ version %}
{% endif -%}
## [{{ version | trim_start_matches(pat="v") }}]({{ url }}) - {{ timestamp | date(format="%Y-%m-%d") }}
{% else -%}
## Unreleased
{% endif -%}
{% macro commit(commit) -%}
{% set id = commit.id | truncate(length=7, end="") -%}
{% set url = "<REPO>/commit/" ~ commit.id -%}
- {% if commit.breaking %}[**breaking**] {% endif -%}
{% if commit.scope %}_{{ commit.scope }}_: {% endif -%}
{{ commit.message | upper_first }} ([{{ id }}]({{ url }}))
{%- if commit.body %}
{{ commit.body | indent(prefix=" > ", first=true, blank=true) }}
{%- endif -%}
{% endmacro -%}
{% for group, commits in commits | group_by(attribute="group") %}
### {{ group | upper_first }}
{% for commit in commits %}
- {% if commit.breaking %}[**breaking**] {% endif %}{{ commit.message | upper_first }}\
{% endfor %}
{% endfor %}\n
{% for commit in commits | filter(attribute="scope") | sort(attribute="scope") -%}
{{ self::commit(commit=commit) }}
{% endfor -%}
{% for commit in commits -%}
{% if not commit.scope -%}
{{ self::commit(commit=commit) }}
{% endif -%}
{% endfor -%}
{% endfor %}
"""
# remove the leading and trailing whitespace from the template
trim = true
Expand All @@ -34,8 +59,9 @@ footer = """
"""
# postprocessors
postprocessors = [
{ pattern = '<REPO>', replace = "https://github.com/dnaka91/stef" }, # replace repository URL
{ pattern = '<REPO>', replace = "https://github.com/dnaka91/wazzup" }, # replace repository URL
]

[git]
# parse the commits based on https://www.conventionalcommits.org
conventional_commits = true
Expand All @@ -49,20 +75,20 @@ commit_preprocessors = [
]
# regex for parsing and grouping commits
commit_parsers = [
{ message = "^feat", group = "Features" },
{ message = "^fix", group = "Bug Fixes" },
{ message = "^doc", group = "Documentation" },
{ message = "^perf", group = "Performance" },
{ message = "^refactor", group = "Refactor" },
{ message = "^style", group = "Styling" },
{ message = "^test", group = "Testing" },
{ message = "^chore\\(release\\): prepare for", skip = true },
{ message = "^chore\\(deps\\)", skip = true },
{ message = "^chore\\(pr\\)", skip = true },
{ message = "^chore\\(pull\\)", skip = true },
{ message = "^chore|ci", group = "Miscellaneous Tasks" },
{ body = ".*security", group = "Security" },
{ message = "^revert", group = "Revert" },
{ message = "^feat", group = "<!-- 0 -->⛰️ Features" },
{ message = "^fix", group = "<!-- 1 -->🐛 Bug Fixes" },
{ message = "^doc", group = "<!-- 2 -->📚 Documentation" },
{ message = "^perf", group = "<!-- 3 -->⚡ Performance" },
{ message = "^refactor", group = "<!-- 4 -->🚜 Refactor" },
{ message = "^style", group = "<!-- 5 -->🎨 Styling" },
{ message = "^test", group = "<!-- 6 -->🧪 Testing" },
{ message = '^chore\(release\): [pP]repare for', skip = true },
{ message = '^chore\(deps\)', skip = true },
{ message = '^chore\(pr\)', skip = true },
{ message = '^chore\(pull\)', skip = true },
{ message = "^chore|ci", group = "<!-- 7 -->⚙️ Miscellaneous Tasks" },
{ body = ".*security", group = "<!-- 8 -->🛡️ Security" },
{ message = "^revert", group = "<!-- 9 -->◀️ Revert" },
]
# protect breaking changes from being skipped due to matching a skipping commit_parser
protect_breaking_commits = false
Expand Down

0 comments on commit 5319fb3

Please sign in to comment.