Merge pull request #584 from strukturag/improve-version

Improve get-version.sh
This commit is contained in:
Joachim Bauch 2023-10-26 14:20:06 +02:00 committed by GitHub
commit 825d95c8d7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4,17 +4,20 @@ ROOT="$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)"
VERSION=
if [ -s "$ROOT/../version.txt" ]; then
VERSION=$(cat "$ROOT/../version.txt" | tr -d '[:space:]')
VERSION=$(tr -d '[:space:]' < "$ROOT/../version.txt")
fi
if [ -z $VERSION ] && [ -d "$ROOT/../.git" ]; then
if [ -z "$VERSION" ] && [ -d "$ROOT/../.git" ]; then
TAG=$(git tag --points-at HEAD | sed 's/v//')
if [ "$1" == "--tar" ]; then
VERSION=$(git describe --dirty --tags --always | sed 's/debian\///g')
elif [ -n "$TAG" ]; then
VERSION="$TAG"
else
VERSION=$(git log -1 --pretty=%H)
fi
fi
if [ -z $VERSION ]; then
if [ -z "$VERSION" ]; then
VERSION=unknown
fi