From 09897fcdb35c99b0147415f0118f21d4d90b22ad Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Thu, 15 May 2025 21:51:10 +0200 Subject: [PATCH] Extend autover to work also without git tags --- autover.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/autover.sh b/autover.sh index 48f08ebb..27b7a2c3 100755 --- a/autover.sh +++ b/autover.sh @@ -3,17 +3,22 @@ if [ -d .git ]; then # Get version from git tags, removing the 'v' prefix - VERSION=`git describe --match 'v*' 2>/dev/null | sed 's/^v//'` + VERSION=$(git describe --match 'v*' 2>/dev/null | sed 's/^v//') fi if [ -f .version ]; then # Get version from the .version file - VERSION=`cat .version` + VERSION=$(cat .version) +fi + +if [ -z "$VERSION" ] && [ -d .git ]; then + # Fall back to short commit hash + VERSION=0-$(git rev-parse --short HEAD 2>/dev/null) fi if [ -z $VERSION ]; then - VERSION="none" + # No version, but still use a number + VERSION="0" fi printf '%s' "$VERSION" -