From 54aed4d2605542379685a38b4cd4a2c29eb53633 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Commaille?= Date: Sun, 15 Dec 2024 17:17:33 +0100 Subject: [PATCH] Validate input of generate-changelog script MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Kévin Commaille --- scripts/generate-changelog.sh | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/scripts/generate-changelog.sh b/scripts/generate-changelog.sh index 676c41f0..f95c3e67 100755 --- a/scripts/generate-changelog.sh +++ b/scripts/generate-changelog.sh @@ -8,13 +8,10 @@ set -e VERSION="$1" DATE="$2" -cd `dirname $0`/../changelogs - -# Pre-cleanup just in case it wasn't done on the last run -rm -f rendered.md - -# Generate changelog -towncrier --yes +if [ -z "$VERSION" ]; then + echo "ERROR: The version of the changelog must be provided" + exit 1 +fi if [ "$VERSION" = "vUNSTABLE" ]; then TITLE="Changes since last release" @@ -25,8 +22,26 @@ else TITLE="$VERSION Changelog" LINKTITLE="$VERSION" FILENAME="$VERSION.md" + + if [ -z "$DATE" ]; then + echo "ERROR: The date of the release must be provided for stable releases" + exit 1 + fi + + if [[ ! "$DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then + echo "ERROR: The date does not have the format YYYY-MM-DD" + exit 1 + fi fi +cd `dirname $0`/../changelogs + +# Pre-cleanup just in case it wasn't done on the last run +rm -f rendered.md + +# Generate changelog +towncrier --yes + { # Prepare the header # We include the generation date in the front matter so that we can use it