From 5319fb3417a830042e7bc220fe283046923da349 Mon Sep 17 00:00:00 2001 From: Dominik Nakamura Date: Tue, 12 Sep 2023 19:32:44 +0900 Subject: [PATCH] doc: generate more stylish changelog --- cliff.toml | 92 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 59 insertions(+), 33 deletions(-) diff --git a/cliff.toml b/cliff.toml index 14c7b36..d688015 100644 --- a/cliff.toml +++ b/cliff.toml @@ -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. + + + + """ # 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 = "/compare/" ~ previous.version ~ "..." ~ version %} + {% else -%} + {% set url = "/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 = "/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 @@ -34,8 +59,9 @@ footer = """ """ # postprocessors postprocessors = [ - { pattern = '', replace = "https://github.com/dnaka91/stef" }, # replace repository URL + { pattern = '', replace = "https://github.com/dnaka91/wazzup" }, # replace repository URL ] + [git] # parse the commits based on https://www.conventionalcommits.org conventional_commits = true @@ -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 = "โ›ฐ๏ธ 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\): [pP]repare 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" }, ] # protect breaking changes from being skipped due to matching a skipping commit_parser protect_breaking_commits = false