From 92165de6fd0f7715d6a858239f61ea2b4392ecc8 Mon Sep 17 00:00:00 2001
From: Awiteb
Date: Wed, 21 May 2025 21:35:47 +0000
Subject: [PATCH] chore: Improve the changelog
Signed-off-by: Awiteb
---
cliff.toml | 33 +++++++++++++++++----------------
justfile | 8 +++++++-
2 files changed, 24 insertions(+), 17 deletions(-)
diff --git a/cliff.toml b/cliff.toml
index 84463b8..5028913 100644
--- a/cliff.toml
+++ b/cliff.toml
@@ -17,12 +17,13 @@ body = """
{% if version -%}
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
{% else -%}
- ## [Unreleased]
+ ## Unreleased
{% endif -%}
{% for group, commits in commits | group_by(attribute="group") %}
### {{ group | upper_first }}
{% for commit in commits %}
- - {{ commit.message | split(pat="\n") | first | upper_first | trim }}\
+ - {{ commit.message | split(pat="\n") | first | split(pat=":") | slice(start=1) | join(sep=":") | upper_first | trim }} - \
+ ({{ commit.author.name}} at [{{ commit.id | truncate(length=7, end="") }}]($REPO/commit/?id={{ commit.id }}))\
{% endfor %}
{% endfor %}\n
"""
@@ -31,12 +32,7 @@ body = """
footer = """
{% for release in releases -%}
{% if release.version -%}
- {% if release.previous.version -%}
- [{{ release.version | trim_start_matches(pat="v") }}]: \
- https://git.4rs.nl/awiteb/n34/compare/{{ release.previous.version }}..{{ release.version }}
- {% endif -%}
- {% else -%}
- [unreleased]: https://git.4rs.nl/awiteb/n34/compare/{{ release.previous.version }}..HEAD
+ [{{ release.version | trim_start_matches(pat="v") }}]: https://git.4rs.nl/awiteb/n34.git/tag/?h={{ release.version }}
{% endif -%}
{% endfor %}
@@ -44,6 +40,11 @@ footer = """
# Remove leading and trailing whitespaces from the changelog's body.
trim = true
+postprocessors = [
+ # Replace the placeholder `` with a URL.
+ { pattern = '\$REPO', replace = "https://git.4rs.nl/awiteb/n34.git" },
+]
+
[git]
# Parse commits according to the conventional commits specification.
# See https://www.conventionalcommits.org
@@ -54,14 +55,14 @@ filter_unconventional = false
# Assigns commits to groups.
# Optionally sets the commit's scope and can decide to exclude commits from further processing.
commit_parsers = [
- { message = "^.*!:.*$", group = "Breaking Change" },
- { message = "^feat", group = "Added" },
- { message = "^deprecate", group = "Deprecated" },
- { message = "^remove", group = "Removed" },
- { message = "^deps", group = "Dependencies" },
- { message = "^refactor", group = "Refactor" },
- { message = "^fix", group = "Fixed" },
- { message = "^docs", group = "Documentation" },
+ { message = '^.*!:.*$', group = "Breaking Change" },
+ { message = '^feat', group = "Added" },
+ { message = '^deprecate', group = "Deprecated" },
+ { message = '^remove', group = "Removed" },
+ { message = '^deps', group = "Dependencies" },
+ { message = '^refactor', group = "Refactor" },
+ { message = '^fix', group = "Fixed" },
+ { message = '^docs', group = "Documentation" },
]
# Prevent commits that are breaking from being excluded by commit parsers.
filter_commits = false
diff --git a/justfile b/justfile
index c79f130..7135468 100644
--- a/justfile
+++ b/justfile
@@ -14,6 +14,12 @@ JUST_EXECUTABLE := "just -u -f " + justfile()
header := "Available tasks:\n"
# Get the MSRV from the Cargo.toml
msrv := `cat Cargo.toml | grep "rust-version" | sed 's/.*"\(.*\)".*/\1/'`
+tag_change_body := '''{% for group, commits in commits | group_by(attribute="group") %}
+
+{{ group | upper_first }}
+
+{% for commit in commits %}
+- {{ commit.message | split(pat="\n") | first | split(pat=":") | slice(start=1) | join(sep=":") | upper_first | trim }} - (by {{ commit.author.name}}){% endfor %}{% endfor %}'''
export TZ := "UTC"
@@ -58,7 +64,7 @@ changelog:
[script]
release version:
set -e
- TAG_MSG=$(git-cliff --strip all --unreleased --tag "v{{ version }}" | sed -e 's/[]#[]//g' -e 's/^ //g')
+ TAG_MSG=$(git-cliff --strip all --unreleased --body '{{ tag_change_body }}')
sed -i "s/^version\s*= \".*\"/version = \"{{ version }}\"/" ./Cargo.toml
taplo fmt --config ./.taplo.toml ./Cargo.toml
{{ JUST_EXECUTABLE }} ci