From 635fe0597dab5b651e1a01cd4db68a18adf5bb2a Mon Sep 17 00:00:00 2001 From: Radu Mereuta Date: Thu, 13 Oct 2022 16:26:25 +0300 Subject: [PATCH 1/2] Fix version calculation Fixes #2915 --- .../tests/regression-new/help/check-git-revision-format | 2 +- scripts/get-version-string.sh | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/k-distribution/tests/regression-new/help/check-git-revision-format b/k-distribution/tests/regression-new/help/check-git-revision-format index fc1341da8e9..4165a035a79 100755 --- a/k-distribution/tests/regression-new/help/check-git-revision-format +++ b/k-distribution/tests/regression-new/help/check-git-revision-format @@ -7,5 +7,5 @@ if [ -z "$GIT_REVISION" ]; then exit 0 fi -VERSION_REGEX='v\d+\.\d+\.\d+-\d+-g[0-9a-z]+(-dirty)?$' +VERSION_REGEX='v\d+\.\d+\.\d+(-0-shouldFail|-[1-9]+-g[0-9a-z]+)?(-dirty)?$' echo "$GIT_REVISION" | grep -Pq "$VERSION_REGEX" diff --git a/scripts/get-version-string.sh b/scripts/get-version-string.sh index 0fe5c4f6d89..04b1c8ec450 100755 --- a/scripts/get-version-string.sh +++ b/scripts/get-version-string.sh @@ -23,10 +23,12 @@ VERSION_TAG=$(git describe --contains --always "$MERGE_BASE" | sed 's/~.*//') VERSION_STRING=$VERSION_TAG DISTANCE=$(git rev-list --count "$MERGE_BASE"..HEAD) -VERSION_STRING+="-$DISTANCE" +if [[ $DISTANCE -ne 0 ]]; then + VERSION_STRING+="-$DISTANCE" -SHA=$(git rev-parse --short HEAD) -VERSION_STRING+="-g$SHA" + SHA=$(git rev-parse --short HEAD) + VERSION_STRING+="-g$SHA" +fi DIRTY=$(git diff HEAD) if [ -n "$DIRTY" ]; then From 2e2eb18e3e4b902be21df13104ca50bb3eff0a2c Mon Sep 17 00:00:00 2001 From: Radu Mereuta Date: Thu, 13 Oct 2022 16:38:36 +0300 Subject: [PATCH 2/2] Fix regex --- .../tests/regression-new/help/check-git-revision-format | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/k-distribution/tests/regression-new/help/check-git-revision-format b/k-distribution/tests/regression-new/help/check-git-revision-format index 4165a035a79..412a4f6fb37 100755 --- a/k-distribution/tests/regression-new/help/check-git-revision-format +++ b/k-distribution/tests/regression-new/help/check-git-revision-format @@ -7,5 +7,5 @@ if [ -z "$GIT_REVISION" ]; then exit 0 fi -VERSION_REGEX='v\d+\.\d+\.\d+(-0-shouldFail|-[1-9]+-g[0-9a-z]+)?(-dirty)?$' +VERSION_REGEX='v\d+\.\d+\.\d+(-0-shouldFail|-[1-9][0-9]*-g[0-9a-z]+)?(-dirty)?$' echo "$GIT_REVISION" | grep -Pq "$VERSION_REGEX"