From 671778e0a5a5a4c7034724411eca478d3ca217f4 Mon Sep 17 00:00:00 2001 From: Llewellyn van der Merwe Date: Wed, 25 Oct 2023 13:14:07 +0200 Subject: [PATCH] Fixed getGitCommitComment some more, to get the correct message from the changelog. --- src/octozipo | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/octozipo b/src/octozipo index 6939b21..ae0918c 100755 --- a/src/octozipo +++ b/src/octozipo @@ -3,7 +3,7 @@ # Program name PROGRAM_NAME="Octozipo" PROGRAM_CODE="octozipo" -PROGRAM_VERSION="2.2.3" +PROGRAM_VERSION="2.2.4" PROGRAM_V="2.2" # PROGRAM_URL="https://git.vdm.dev/octoleo/${PROGRAM_CODE}" @@ -663,7 +663,7 @@ function getGitCommitComment() { if [ -z "$current_version" ]; then message="Update" # If tag already exist - elif git tag -l "$current_version" | grep -q "^$current_version$"; then + elif git rev-parse --is-inside-work-tree > /dev/null 2>&1 && git tag -l "$current_version" | grep -q "^$current_version$"; then message="Update on $current_version (beta for next version)\n\nHere's an update on the current version, which includes changes towards the next release still in beta." # if file path exist and the tag was never set before elif [ -f "${file_path}" ]; then @@ -671,8 +671,8 @@ function getGitCommitComment() { version_line=$(grep -n "^#" "$file_path" | head -n 1 | cut -d: -f1) # Extract the first heading/version and assign it to a variable version=$(sed -n "${version_line}p" "$file_path" | sed -e 's/^#\+ *//' -e 's/^[[:space:]]*//' -e 's/^-* \?//' -e 's/[[:space:]]*$//') - # Use sed to extract the message lines after the first header, but stop at the next header or an empty line - message_lines=$(sed -n "$((version_line + 1)),$ p" "$file_path" | awk '/^#/{exit} /^[[:space:]]*$/{exit} {print}') + # Use awk to extract the message lines after the first header, but stop at the next header or an empty line + message_lines=$(awk -v start=$((version_line + 1)) 'NR > start && (/^#/ || !NF) {exit} NR > start {print}' "$file_path") cleaned_lines=$(echo "$message_lines" | sed -e '/^[[:space:]]*$/d' -e 's/^[[:space:]]*//' -e 's/^-* \?//' -e 's/[[:space:]]*$//' -e 's/\.*$//' ) formatted_lines=$(echo "$cleaned_lines" | awk '{printf "%s%s",(NR>1?". ":""),$0} END{printf ".\n"}')