From 1a865898407f5f5444807d98789adb0e2d47f98c Mon Sep 17 00:00:00 2001 From: David Young Date: Thu, 19 Nov 2026 08:40:59 -0700 Subject: [PATCH] Fix empty version when the repo has no tags The describe|sed pipeline took sed's exit status, so with no tags version() returned an empty string instead of the commit date. Co-Authored-By: Claude Opus 5.5 --- lib.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib.sh b/lib.sh index c66f12c..600123f 100644 --- a/lib.sh +++ b/lib.sh @@ -17,8 +17,11 @@ URL="http://localhost:8470" # The version, worked out the way CoreDesktop's `sibling` shows it: the # latest tag, or else the date and short hash of the latest commit. version() { - git -C "$SUPERMARKET_REPO" describe --tags 2> /dev/null \ - | sed -E 's/-([0-9]+)-g[0-9a-f]+$/+\1/' && return + local tag + if tag="$(git -C "$SUPERMARKET_REPO" describe --tags 2> /dev/null)"; then + sed -E 's/-([0-9]+)-g[0-9a-f]+$/+\1/' <<< "$tag" + return + fi git -C "$SUPERMARKET_REPO" log -1 --date=format:%Y.%m.%d --format='%cd (%h)' 2> /dev/null || echo dev }