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