build: improve git-cliff CHANGELOG output

- Sort sections according to custom preference instead of
  alphabetically. It is ordered according to "most relevant" to "least
  relevant" to users.
- Sort commits alphabetically
- Don't uppercase the first letter of the commit message
This commit is contained in:
dundargoc 2024-05-02 00:15:56 +02:00 committed by dundargoc
parent e5c69df679
commit 01e4a70d66

View File

@ -1,4 +1,4 @@
# configuration file for git-cliff (0.1.0)
# configuration file for git-cliff
[changelog]
# changelog header
@ -7,7 +7,8 @@ header = """
All notable changes to this project will be documented in this file.\n
"""
# template for the changelog body
# https://tera.netlify.app/docs/#introduction
# https://github.com/Keats/tera
# https://keats.github.io/tera/docs/
body = """
{% if version %}\
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
@ -15,25 +16,21 @@ body = """
## [unreleased]
{% endif %}\
{% for group, commits in commits | group_by(attribute="group") %}
### {{ group | upper_first }}
{% for commit in commits%}\
### {{ group | striptags | upper_first }}
{% for commit in commits | sort(attribute="message")%}\
{% if not commit.scope %}\
- {{ commit.message | upper_first }}
- {{ commit.message }}
{% endif %}\
{% endfor %}\
{% for group, commits in commits | group_by(attribute="scope") %}\
{% for commit in commits %}\
- **{{commit.scope}}**: {{ commit.message | upper_first }}
{% for commit in commits | sort(attribute="message") %}\
- **{{commit.scope}}**: {{ commit.message }}
{% endfor %}\
{% endfor %}
{% endfor %}\n
"""
# remove the leading and trailing whitespace from the template
trim = true
# changelog footer
footer = """
<!-- generated by git-cliff -->
"""
[git]
# parse the commits based on https://www.conventionalcommits.org
@ -48,16 +45,18 @@ commit_preprocessors = [
]
# regex for parsing and grouping commits
commit_parsers = [
{ message = "!:", group = "Breaking"},
{ message = "^feat", group = "Features"},
{ message = "^fix", group = "Bug Fixes"},
{ message = "^doc", group = "Documentation"},
{ message = "^perf", group = "Performance"},
{ message = "^refactor", group = "Refactor"},
{ message = "^test", group = "Testing"},
{ message = "^chore", group = "Miscellaneous Tasks"},
{ message = "^build", group = "Build System"},
{ message = "^Revert", group = "Reverted Changes"},
{ message = "!:", group = "<!-- 0 -->Breaking"},
{ message = "^feat", group = "<!-- 1 -->Features"},
{ message = "^fix", group = "<!-- 2 -->Bug Fixes"},
{ message = "^perf", group = "<!-- 3 -->Performance"},
{ message = "^build", group = "<!-- 4 -->Build System"},
{ message = "^vim-patch", group = "<!-- 5 -->Vim patches"},
{ message = "^refactor", group = "<!-- 6 -->Refactor" },
{ message = "^ci", group = "<!-- 8 -->CI" },
{ message = "^test", group = "<!-- 9 -->Testing" },
{ message = "^docs", group = "<!-- 99 -->Documentation" },
{ message = "^revert", group = "<!-- 999 -->Reverted Changes" },
{ message = ".*", group = "<!-- 9999 -->Other"},
]
# filter out the commits that are not matched by commit parsers
filter_commits = true