hack/make: Refactor VERSION normalization

Turn the if-else tree into a `case`.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
Paweł Gronowski 2024-01-05 13:21:13 +01:00
parent 9a5393d500
commit dd41f86339
No known key found for this signature in database
GPG key ID: B85EFCFE26DEF92A

View file

@ -39,15 +39,12 @@ DEFAULT_BUNDLES=(
) )
VERSION=${VERSION:-dev} VERSION=${VERSION:-dev}
if [[ $VERSION == refs/tags/v* ]]; then case "$VERSION" in
VERSION=${VERSION#refs/tags/v} refs/tags/v*) VERSION=${VERSION#refs/tags/v} ;;
else if [[ $VERSION == refs/tags/* ]]; then refs/tags/*) VERSION=${VERSION#refs/tags/} ;;
VERSION=${VERSION#refs/tags/} refs/heads/*) VERSION=$(echo "${VERSION#refs/heads/}" | sed -r 's#/+#-#g') ;;
elif [[ $VERSION == refs/heads/* ]]; then refs/pull/*) VERSION=pr-$(echo "$VERSION" | grep -o '[0-9]\+') ;;
VERSION=$(sed <<< "${VERSION#refs/heads/}" -r 's#/+#-#g') esac
elif [[ $VERSION == refs/pull/* ]]; then
VERSION=pr-$(grep <<< "$VERSION" -o '[0-9]\+')
fi
! BUILDTIME=$(date -u -d "@${SOURCE_DATE_EPOCH:-$(date +%s)}" --rfc-3339 ns 2> /dev/null | sed -e 's/ /T/') ! BUILDTIME=$(date -u -d "@${SOURCE_DATE_EPOCH:-$(date +%s)}" --rfc-3339 ns 2> /dev/null | sed -e 's/ /T/')
if [ "$DOCKER_GITCOMMIT" ]; then if [ "$DOCKER_GITCOMMIT" ]; then