From c9f86c31f979f3bdbff6be399cd47af749e95719 Mon Sep 17 00:00:00 2001 From: ThetaDev Date: Fri, 22 Mar 2024 03:09:52 +0100 Subject: [PATCH] chore: fix git-cliff --- Justfile | 16 ++++++++-------- cliff.toml | 10 ++++++++-- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/Justfile b/Justfile index 61ad9db..c320b58 100644 --- a/Justfile +++ b/Justfile @@ -68,22 +68,22 @@ release crate="rustypipe": VERSION=$(git-cliff $INCLUDES --bumped-version | grep -Po '\d+\.\d+\.\d+$') echo "Releasing $VERSION:" - # if [ -n "$(git status --porcelain)" ]; then echo "Workdir must be clean"; exit 1; fi + if [ -n "$(git status --porcelain)" ]; then echo "Workdir must be clean"; exit 1; fi if git rev-parse "${CRATE}/v${VERSION}" >/dev/null 2>&1; then echo "version tag v${VERSION} already exists"; exit 1; fi cargo semver -c "$CARGO_TOML" set "$VERSION" - CLIFF_ARGS="--tag v${VERSION}" + CLIFF_ARGS="--tag v${VERSION} --unreleased $INCLUDES" + echo "git-cliff $CLIFF_ARGS" if [ -f "$CHANGELOG" ]; then - CLIFF_ARGS="$CLIFF_ARGS --unreleased $INCLUDES" - CLIFF_OUT="--prepend $CHANGELOG" + git-cliff $CLIFF_ARGS --prepend "$CHANGELOG" else - CLIFF_OUT="--output $CHANGELOG" + git-cliff $CLIFF_ARGS --output "$CHANGELOG" fi - echo "git-cliff $CLIFF_ARGS $CLIFF_OUT" - eval "git-cliff $CLIFF_ARGS $CLIFF_OUT" + editor "$CHANGELOG" + git add "$CHANGELOG" "$CARGO_TOML" git commit -m "chore(release): release $CRATE v$VERSION" - eval "git-cliff $CLIFF_ARGS --strip all" | git tag -a -F - --cleanup whitespace "${CRATE}/v${VERSION}" + awk 'BEGIN{RS="(^|\n)## "} NR==2 { print "##",$0 }' "$CHANGELOG" | git tag -a -F - --cleanup whitespace "${CRATE}/v${VERSION}" diff --git a/cliff.toml b/cliff.toml index ee730e3..32b679a 100644 --- a/cliff.toml +++ b/cliff.toml @@ -14,8 +14,13 @@ All notable changes to this project will be documented in this file.\n # template for the changelog body # https://keats.github.io/tera/docs/#introduction body = """ +{% set repo_url = "https://code.thetadev.de/ThetaDev/rustypipe" %}\ {% if version %}\ - ## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }} + {%if previous.version %}\ + ## [{{ version }}]({{ repo_url }}/compare/{{ previous.version }}..{{ version }})\ + {% else %}\ + ## {{ version }}\ + {% endif %} - {{ timestamp | date(format="%Y-%m-%d") }} {% else %}\ ## [unreleased] {% endif %}\ @@ -25,7 +30,8 @@ body = """ {% for commit in commits %} - {% if commit.scope %}*({{ commit.scope }})* {% endif %}\ {% if commit.breaking %}[**breaking**] {% endif %}\ - {{ commit.message | upper_first }}\ + {{ commit.message | upper_first }} - \ + ([{{ commit.id | truncate(length=7, end="") }}]({{ repo_url }}/commit/{{ commit.id }}))\ {% endfor %} {% endfor %}\ {% else %}