Turn the if-else tree into a `case`.
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
| ... | ... |
@@ -39,15 +39,12 @@ DEFAULT_BUNDLES=( |
| 39 | 39 |
) |
| 40 | 40 |
|
| 41 | 41 |
VERSION=${VERSION:-dev}
|
| 42 |
-if [[ $VERSION == refs/tags/v* ]]; then |
|
| 43 |
- VERSION=${VERSION#refs/tags/v}
|
|
| 44 |
-else if [[ $VERSION == refs/tags/* ]]; then |
|
| 45 |
- VERSION=${VERSION#refs/tags/}
|
|
| 46 |
-elif [[ $VERSION == refs/heads/* ]]; then |
|
| 47 |
- VERSION=$(sed <<< "${VERSION#refs/heads/}" -r 's#/+#-#g')
|
|
| 48 |
-elif [[ $VERSION == refs/pull/* ]]; then |
|
| 49 |
- VERSION=pr-$(grep <<< "$VERSION" -o '[0-9]\+') |
|
| 50 |
-fi |
|
| 42 |
+case "$VERSION" in |
|
| 43 |
+ refs/tags/v*) VERSION=${VERSION#refs/tags/v} ;;
|
|
| 44 |
+ refs/tags/*) VERSION=${VERSION#refs/tags/} ;;
|
|
| 45 |
+ refs/heads/*) VERSION=$(echo "${VERSION#refs/heads/}" | sed -r 's#/+#-#g') ;;
|
|
| 46 |
+ refs/pull/*) VERSION=pr-$(echo "$VERSION" | grep -o '[0-9]\+') ;; |
|
| 47 |
+esac |
|
| 51 | 48 |
|
| 52 | 49 |
! BUILDTIME=$(date -u -d "@${SOURCE_DATE_EPOCH:-$(date +%s)}" --rfc-3339 ns 2> /dev/null | sed -e 's/ /T/')
|
| 53 | 50 |
if [ "$DOCKER_GITCOMMIT" ]; then |