From 008b702526937d8a409b97977f738780664bd80b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D1=82=D1=80=D0=B0=D1=85=D0=B8=D1=9A=D0=B0=20=D0=A0?= =?UTF-8?q?=D0=B0=D0=B4=D0=B8=D1=9B?= Date: Mon, 20 May 2024 20:04:21 +0000 Subject: [PATCH] lib/makeversion: Fix version output --- lib/makeversion | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/lib/makeversion b/lib/makeversion index a13a95f..ee14eda 100755 --- a/lib/makeversion +++ b/lib/makeversion @@ -3,15 +3,32 @@ FALLBACKVER=${FALLBACKVER:-unknown} if [ -d .got ] && command -v got >/dev/null 2>&1; then - lastcommit=$(got log | awk '/^commit/ {print substr($2,1,9); exit}') - lasttagcom=$(got tag -l | - awk '/^object: commit/ { print substr($3,1,9); exit}') - ver=$(got tag -l | - awk '/^tag/ { sub(/^v/,"",$2); print $2; exit }') - if [ "$lastcommit" != "$lasttagcom" ]; then - ver="${ver}-$lastcommit" - fi - printf "%s\n" "$ver" >version.new + lastcommit=$(got log | + awk '/^commit/ {print substr($2,1,9); exit}') + got tag -l | + awk -v lastcommit="$lastcommit" ' + /^object: commit/ { + if (!lasttagcom) + { + lasttagcom = substr($3,1,9) + } + next + } + /^tag/ { + if (!ver) + { + sub(/^v/,"",$2) + ver = $2 + } + next + } + END { + printf "%s", ver + if (lastcommit != lasttagcom) + { + printf "-g%s", lastcommit + } + }' >version.new elif [ -d .git ] && command -v git >/dev/null 2>&1; then LC_ALL=C export LC_ALL -- 2.45.2