From a20c19507d260110315af920ad63512c2eedbc5a Mon Sep 17 00:00:00 2001 From: Alexander Myasoedov Date: Sat, 15 Feb 2025 13:35:36 +0200 Subject: [PATCH] feat(add changelog sh): --- changelog.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 changelog.sh diff --git a/changelog.sh b/changelog.sh new file mode 100644 index 0000000..8dc63fa --- /dev/null +++ b/changelog.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# Get the last tag +LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null) + +if [ -z "$LAST_TAG" ]; then + echo "No tags found. Retrieving all commits." + LOG_RANGE="HEAD" +else + echo "Generating changelog from last tag: $LAST_TAG" + LOG_RANGE="$LAST_TAG..HEAD" +fi + +# Retrieve commit messages excluding merge commits and format them with author names and stripped email domain as nickname +CHANGELOG=$(git log --pretty=format:"- %s by %an, @%ae)" --no-merges $LOG_RANGE | sed -E 's/@([^@]+)@([^@]+)\..*/@\1/') + +# Output the changelog +if [ -n "$CHANGELOG" ]; then + echo "# Changelog" + echo " +## Changes since $LAST_TAG" + echo "$CHANGELOG" +else + echo "No new commits since last tag." +fi