Files
ViewIT/scripts/hooks/commit-msg

36 lines
1.1 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# commit-msg: Version in Commit-Message aktualisieren und Changelog-Eintrag prependen (nur dev-Branch)
branch=$(git symbolic-ref --short HEAD 2>/dev/null)
[[ "$branch" != "dev" ]] && exit 0
root=$(git rev-parse --show-toplevel)
cd "$root"
# Aktuelle Version aus addon.xml (bereits vom pre-commit Hook hochgezählt)
version=$(grep -oP 'version="\K[0-9]+\.[0-9]+\.[0-9]+[^"]*' addon/addon.xml | head -1)
# Commit-Message: alte Versionsnummern durch aktuelle ersetzen
# z.B. "dev: bump to 0.1.72-dev ..." → "dev: bump to 0.1.73-dev ..."
msg=$(cat "$1")
updated_msg=$(echo "$msg" | sed -E "s/bump to [0-9]+\.[0-9]+\.[0-9]+[^ ]*/bump to ${version}/g")
echo "$updated_msg" > "$1"
today=$(date +%Y-%m-%d)
# Changelog-Eintrag aufbauen
# Jede nicht-leere Zeile der Commit-Message wird ein "- ..." Eintrag
{
echo "## ${version} - ${today}"
echo ""
while IFS= read -r line; do
[[ -z "$line" ]] && continue
echo "- ${line}"
done <<< "$updated_msg"
echo ""
cat CHANGELOG-DEV.md
} > /tmp/changelog_new.md
mv /tmp/changelog_new.md CHANGELOG-DEV.md
git add CHANGELOG-DEV.md