slweb

Једноставни генератор статичких веб страна
git clone https://git.sr.ht/~strahinja/slweb
Дневник | Датотеке | Референце | ПРОЧИТАЈМЕ | ЛИЦЕНЦА

чување c7d49f14a329684bf91e3e38c31180c069a37681
родитељ 34d244e8e1f9606c85e8cb93239a52061172c68b
Аутор: Страхиња Радић <contact@strahinja.org>
Датум:   Mon, 20 May 2024 22:30:03 +0200

lib/make{date,version}: Make version use last commit if ahead of tag

Diffstat:
Mlib/makedate | 4++--
Mlib/makeversion | 31+++++++++++++++++++++++++------
измењених датотека: 2, додавања: 27(+), брисања: 8(-)

diff --git a/lib/makedate b/lib/makedate @@ -5,11 +5,11 @@ LC_ALL=C export LC_ALL if [ -d .got ] && command -v got >/dev/null 2>&1; then - got tag -l | + got log | awk ' /^date: / { sub(/^date: /,"",$0) - print strftime("%B %d, %Y") + print $2 " " $3 ", " $5 exit }' >date.new elif [ -d .git ] && command -v git >/dev/null 2>&1; then diff --git a/lib/makeversion b/lib/makeversion @@ -3,13 +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}') got tag -l | - awk ' - /^tag/ { - sub(/^v/,"",$2) - print $2 - exit - }' >version.new + 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