From 66be01548b568eaee1be4ac17b136aa2623040de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20T=C3=B3th?= Date: Thu, 24 May 2018 14:43:15 +0200 Subject: [PATCH] Encforce tag descriptions in tfw.sh releasetfw --- hack/tfw.sh | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/hack/tfw.sh b/hack/tfw.sh index 55e9ac1..f683a5f 100755 --- a/hack/tfw.sh +++ b/hack/tfw.sh @@ -39,7 +39,9 @@ release_baseimage() read -p "Tag and push new TFW version \"${TAG}\"? [y/N]" -r && echo if [[ $REPLY =~ ^(y|Y|yes|Yes|YES)$ ]] then - TAG="$TAG" force_push_tag + description="" + prompt_for_tag_description # This command overwrites $description + TAG="$TAG" DESCRIPTION="$description" force_push_tag fi } @@ -54,11 +56,33 @@ check_drone_releasename() fi } +prompt_for_tag_description() +{ + editor="$(git config --global core.editor)" + tempfile="$(mktemp)" + + printf "\n\n" >> "$tempfile" + echo "# Please enter the description for this release." >> "$tempfile" + echo "# Lines starting with '#' will be ignored." >> "$tempfile" + echo "# An empty description aborts the release." >> "$tempfile" + + $editor "$tempfile" + sed -i -e 's/#.*$//' -e '/^$/d' "$tempfile" + sed -i 's/\n/ /g' "$tempfile" + if [[ ! -s "$tempfile" ]]; then + echo "Aborting release due to empty description." + exit 1 + fi + + description="$(tr '\n' ' ' < "$tempfile")" + rm "$tempfile" +} + force_push_tag() { git tag -d "$TAG" > /dev/null 2>&1 || : git push --delete origin "$TAG" > /dev/null 2>&1 || : - git tag -s -m "TFW version $TAG released at $(date '+%H:%M:%S %Y-%m-%d')" "$TAG" + git tag -s -m "$DESCRIPTION" "$TAG" git push origin "$TAG" }